-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsearchUrl_sftp.py
30 lines (29 loc) · 1.06 KB
/
searchUrl_sftp.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import db,time
import paramiko
from ftplib import FTP_TLS
FTPSERVERADDR = "ip"
def getTimestamp():
return time.strftime('%Y%m%d%H%M%S',time.localtime(time.time()))
def send2FTP(path,filename):
tran = paramiko.Transport((FTPSERVERADDR, 60522))
#tran.connect(username="boce", password='')
private = paramiko.RSAKey.from_private_key_file('/data/data/com.termux/files/home/.ssh/id_rsa')
tran.connect(username="boce", pkey=private)
sftp = paramiko.SFTPClient.from_transport(tran)
localpath = path+filename
remotepath = "/home/boce/"+filename
sftp.put(localpath, remotepath)
#sftp.get(remotepath, localpath)
tran.close()
def filesend(filename,mediatype):
path = "/data/data/com.termux/files/home/scripts/file2send/"
data = db.search(mediatype)
with open(path+filename,"w",encoding = "utf-8") as f:
for t in data:
f.write(",".join(t)+"\n")
send2FTP(path, filename)
if __name__ == "__main__":
filesend("dy_vod.csv",'douyin_vod')
filesend("ks_vod.csv",'kuaishou_vod')
filesend("ks_live.csv",'kuaishou_live')
filesend("dy_live.csv",'douyin_live')