Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
ftp callback
#1
Hello,
I want to use a callback when upload of a file to ftp . Here is my code:

from ftplib import FTP
def UploadTracker():
print "HELLO"
myftp = FTP()
myftp.connect(host='mysite.com')
myftp.login('me','mypw')
myftp.storbinary('STOR mydata.txt', open('mydata.txt', 'rb'), callback=UploadTracker())
myftp.quit()

Upload of mydata.txt works ok , but the result shows only one "HELLO" at start of upload ...
mydata.txt weigth is 1800ko . So I was waiting for many many HELLO message , each time a block of 8192 bytes is uploaded , but it does'nt works. Did I make a error ?

I have tried different ways of writing this code (with global variables to follow upload, etc ...) but no differences, only one callback to UploadTracker is made . What is my error ?

Many thanks for your help .
Roberto
Larz60+ wrote Sep-13-2018, 10:57 PM:
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
Quote

Top Page

Forum Jump:


Users browsing this thread: 1 Guest(s)