Python progress meter
The ASPN Python Cookbook has a pretty cool script to make wget/emerge style, text based progress meters. After importing the necessary class, the actual code to use it is quite simple.
Here’s an example using random update speeds:
#!/usr/bin/env python
import progress
import time
import random
total = 1000
p = progress.ProgressMeter(total=total)
while total > 0:
cnt = random.randint(1, 25)
p.update(cnt)
total -= cnt
time.sleep(random.random())
I noticed that it doesn’t really work in the Windows console, and according to the comments, it doesn’t work in OS X either. So (as written) it’s a Linux thing. If you check out the ASPN page, however, there are some proposed fixes/improvements.
May 8th, 2006 at 8:01 pm
[...] Looks quite a bit better than the ASPN cookbook version I linked to a while back. [...]
February 20th, 2008 at 5:02 am
i’ve tried to implement this peice of code and this error keeps occuring:
Traceback (most recent call last):
File “C:/Python25/progress.py”, line 1, in
import progress
File “C:/Python25\progress.py”, line 6, in
p = progress.progressmeter(total=total)
AttributeError: ‘module’ object has no attribute ‘progressmeter’