Spaces:
Build error
Build error
| import os | |
| import paramiko | |
| def upload_file(file): | |
| #创建ssh对象 | |
| ssh = paramiko.SSHClient() | |
| ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) | |
| filename=file.name.split('/')[-1][0:4] | |
| filenamepdb=filename+".pdb" | |
| #本地文件路径 | |
| localpath = file.name | |
| os.system("mkdir /home/bio/workshop/zhang/input/input_pdb/{}".format(filename)) | |
| #服务器的文件路径 | |
| remotepath = "/home/bio/workshop/zhang/input/input_pdb"+'/'+filename+'/'+filenamepdb | |
| #可设置多台服务器,尽量服务器的密码保持一致 | |
| server = "10.13.106.252" | |
| # words = server.split(",") | |
| # for word in words: | |
| #连接服务器 | |
| ssh.connect(server, username="bio", password="gromacs") | |
| sftp = ssh.open_sftp() | |
| sftp.put(localpath, remotepath, callback = None) | |
| #关闭连接 | |
| ssh.close() | |
| return | |