Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do i monitor the progress of a file transfer through pysftp

I'm using python 3.3.2 and pysftp to make a back-up utility that stores copies of files on another computer on my network.

I already know how to use pysftp to transfer theses files however i would like to see the progress of the transfer (bytes per second, percent completion, time remaining) instead of some static print statement indicating that the transfer has started or finished

something like this maybe ( filename: 3.4MiB/s | 40%<#########=============> | 0:03:54 remaining )

Edit: I could probably build a progress bar if i just knew how to get pysftp's put command to yeild the information, THAT is what i want to know how to do

Edit: I think i found my answer on another question after extensive digging:

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

like image 958
user3751069 Avatar asked Jun 18 '14 06:06

user3751069


1 Answers

There exists a call back function in both get/put methods (see the official documentation)

get(remotepath, localpath=None, callback=None, preserve_mtime=False)

where callback can look like:

lambda x,y: print("{} transfered out of {}".format(x,y))
like image 77
Manolis M. Tsangaris Avatar answered Nov 08 '22 15:11

Manolis M. Tsangaris