how to accomplish dl progress bars?

flamesrock flamesrock at gmail.com
Wed May 25 20:31:52 EDT 2005


Certain web applications, everything from wget to downloader for X has
this nifty feature I'd like to accomplish in python.

Its the progress bar/time elapsed/time remaining scheme

Filename  | Progress    | Speed (kB/s) | T/Elapsed | T/Remaining
----------------------------------------------------------------------------
blah.bin  |------>45%   |     56.6     |   02:39   |   02:45
file2.bz2 |--->33%      |     35.0     |   05:22   |   11:24
etc       |-------->60% |     47.5     |   00:14   |   00:08

(could be either text or a gui..)

So where would one begin to accomplish this sort of thing efficiently?

I've searched the web and there are plenty of resources on network
programming in python, but how could I
1) keep track of download speed
2) calculate t/elapsed/remaining
3) output that to a progress bar

w/o spawning countless threads to do the many calculations and avoid
eating up the entire CPU.

This seems like it would require a lot of resources and easily go out
of sync with the real world file transfer. To compound problems, I have
a very limited understanding of threads and using multiple threads that
rely on eachother doesn't make very much sense.

Can anyone point me in the right direction?

-thanks in advance




More information about the Python-list mailing list