Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using the clint progress bar to show the status of urllib.urlretrieve()

The clint progress bar is based on an iterator.
urllib.urlretrieve() has a callback that reports the completion of a chunk downloading.
Can I set the iterator to be in a certain position everytime the callback is called?

like image 372
the_drow Avatar asked Nov 18 '25 01:11

the_drow


1 Answers

Looking at the source, i see that it only goes up. To start at a specific value, use:

for i in progress.dots(range(your_start_value)): pass

To backspace, try:

sys.stderr.write(' \b\b' * amount); sys.stderr.flush()

That probably won't work without using the colorama module's locate feature, in which case you'd be better off simply writing ("=" * percent_done + " " * percent_left).

like image 146
Cees Timmerman Avatar answered Nov 19 '25 16:11

Cees Timmerman



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!