Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Progress indicator during FTP upload

4 views
Skip to first unread message

Frantisek Fuka

unread,
Jan 4, 2004, 1:31:34 PM1/4/04
to
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

--
Frantisek Fuka
(yes, that IS my real name)
(and it's pronounced "Fran-tjee-shek Foo-kah")
----------------------------------------------------
My E-mail: fu...@fuxoft.cz
My Homepage: http://www.fuxoft.cz
My ICQ: 2745855

Christophe Delord

unread,
Jan 4, 2004, 4:10:12 PM1/4/04
to
On Sun, 04 Jan 2004 19:31:34 +0100, Frantisek Fuka wrote:

> 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.

Dave Kuhlman

unread,
Jan 4, 2004, 7:42:59 PM1/4/04
to
Christophe Delord <no.spam> wrote:

> On Sun, 04 Jan 2004 19:31:34 +0100, Frantisek Fuka wrote:
>
>> 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 :

Slick. Thank you.

Dave

[snip]


--
http://www.rexx.com/~dkuhlman
dkuh...@rexx.com

Samuel Walters

unread,
Jan 5, 2004, 1:39:00 PM1/5/04
to
|Thus Spake Christophe Delord On the now historical date of Sun, 04 Jan
2004 22:10:12 +0100|

> 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 :
(code snipped)
Combine with this recipe:
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/168639
Salt to taste and serve with red wine.

--
Never forget the halloween documents.
http://www.opensource.org/halloween/
""" Where will Microsoft try to drag you today?
Do you really want to go there?"""

0 new messages