python 使用paramiko传输大文件暂停的解决方案

#!/usr/bin/python
#-*- encoding: utf8 -*-

import paramiko,os
import socket


host = '1.1.1.1'
port = 22
user = 'testuser'
passwd = 'testpass'

tcpsock = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
tcpsock.settimeout(None)
tcpsock.connect((host,port),)

testssh = paramiko.Transport(tcpsock)

testssh.connect(username=user,password=passwd)
testsftp = paramiko.SFTPClient.from_transport(testssh)

localfiles = os.popen('ls %s' %(localdir))

for lfile in localfiles.readlines():
    rfile = lfile
    testsftp.put(lfile.strip(),rfile)
   
testsftp.close()
testssh.close()
tcpsock.close()


你可能感兴趣的:(python 使用paramiko传输大文件暂停的解决方案)