How to see (log) file transfer progress using paramiko?

不问归期 提交于 2019-12-06 19:29:38

问题


I'm using Paramiko's SFTPClient to transfer file between hosts. I want my script to print the file transfer progress similar to the output seen using scp.

$ scp my_file user@host

user@host password: 

my_file                          100%  816KB 815.8KB/s   00:00

$

Any idea?

Thanks in advance


回答1:


Use the optional callback parameter of the put function. Something like this:

def printTotals(transferred, toBeTransferred):
    print "Transferred: {0}\tOut of: {1}".format(transferred, toBeTransferred)

sftp.put("myfile","myRemoteFile",callback=printTotals)


来源:https://stackoverflow.com/questions/8313080/how-to-see-log-file-transfer-progress-using-paramiko

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!