mrzhang commited on
Commit
3094872
·
1 Parent(s): b57802f

Upload upload_file.py

Browse files
Files changed (1) hide show
  1. upload_file.py +27 -0
upload_file.py ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import paramiko
3
+ def upload_file(file):
4
+ #创建ssh对象
5
+ ssh = paramiko.SSHClient()
6
+
7
+ ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
8
+ filename=file.name.split('/')[-1][0:4]
9
+ filenamepdb=filename+".pdb"
10
+ #本地文件路径
11
+ localpath = file.name
12
+ os.system("mkdir /home/bio/workshop/zhang/input/input_pdb/{}".format(filename))
13
+ #服务器的文件路径
14
+ remotepath = "/home/bio/workshop/zhang/input/input_pdb"+'/'+filename+'/'+filenamepdb
15
+ #可设置多台服务器,尽量服务器的密码保持一致
16
+ server = "10.13.106.252"
17
+ # words = server.split(",")
18
+ # for word in words:
19
+ #连接服务器
20
+ ssh.connect(server, username="bio", password="gromacs")
21
+ sftp = ssh.open_sftp()
22
+
23
+ sftp.put(localpath, remotepath, callback = None)
24
+ #关闭连接
25
+ ssh.close()
26
+ return
27
+