Progress indicator during FTP upload

F

Frantisek Fuka

My application uses ftplib to upload files to remote server. What is the
cleanest way to provide progress indicator for long files? What exactly
should I override in the ftplib (I am not very proficient in the FTP
protocol)?

Thanks
 
C

Christophe Delord

My application uses ftplib to upload files to remote server. What is
the cleanest way to provide progress indicator for long files? What
exactly should I override in the ftplib (I am not very proficient in
the FTP protocol)?

Hello,

To update my web site I wrote a script in wich I have overriden
ftplib.FTP to print a dot when a block of bytes is sent. Here is my
dot_FTP class :

class dot_FTP(ftplib.FTP):
def storbinary(self, cmd, fp, blocksize=8192):
''' Store a file in binary mode.'''
self.voidcmd('TYPE I')
conn = self.transfercmd(cmd)
while 1:
buf = fp.read(blocksize)
if not buf: break
conn.send(buf)
sys.stdout.write('.')
sys.stdout.flush()
conn.close()
return self.voidresp()

I just took the code of storbinary in ftplib.py and added the wanted
output.


Christophe.
 
D

Dave Kuhlman

Christophe Delord said:
Hello,

To update my web site I wrote a script in wich I have overriden
ftplib.FTP to print a dot when a block of bytes is sent. Here is
my dot_FTP class :

Slick. Thank you.

Dave

[snip]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top