Hello,
I'm using the module paramiko to transfer files via sftp (see code below).
I would like to specify the maximum amount of bytes to be transferred
(say 10MB, if the file is bigger just transfer up to these many bytes).
From the docs of paramiko
(http://www.lag.net/paramiko/docs/paramiko.SFTPClient-class.html#get)
I see that the method get() can take an optional callback parameter
which is a "function that accepts the bytes transferred so far and the
total bytes to be transferred". This seems to do what I need but I
don't know how to specify such callback function. Any idea?
This is my code:
------------[ Cut here ]-------------
import paramiko
host = "my.host"
port = 22
transport = paramiko.Transport((host, port))
password = "mypassword"
username = "myname"
transport.connect(username = username, password = password)
sftp = paramiko.SFTPClient.from_transport(transport)
filepath = 'file/to/myfile.txt'
localpath = 'D:/Tritume/myfile.txt'
sftp.get(filepath, localpath) ## <-- Calback function should go here
------------[ cut here]-----------
Many thanks
Dario
--
Dr. Dario Beraldi
Institute of Evolutionary Biology
University of Edinburgh
West Mains Road
Edinburgh EH9 3JT
Scotland, UK
--
Dr. Dario Beraldi
Institute of Evolutionary Biology
University of Edinburgh
West Mains Road
Edinburgh EH9 3JT
Scotland, UK
--
The University of Edinburgh is a charitable body, registered in
Scotland, with registration number SC005336.
--
http://mail.python.org/mailman/listinfo/python-list