This patch fixes the progress bar UI, the first most important bit is showing enough of the name for things like php-pear-Str*, but the others are nice too.
Add main() to progress, and tweak output:
. Now shows more of the pkg name when it's finished.
. Now shows hours instead of hundreds of minutes.
. Also allows upto 999 hours, welcome to the large pkgs :)
. Now shows the rate of download for the pkg, on update only.
It's available from:
http://people.redhat.com/jantill/yum/patches/urlgrabber-progress-ui.patch
--
James Antill <[EMAIL PROTECTED]>
Red Hat
Index: urlgrabber/progress.py
===================================================================
RCS file: /home/groups/urlgrabber/cvs-root/urlgrabber/urlgrabber/progress.py,v
retrieving revision 1.7
diff -u -r1.7 progress.py
--- urlgrabber/progress.py 19 Aug 2005 21:59:07 -0000 1.7
+++ urlgrabber/progress.py 13 Mar 2008 18:48:56 -0000
@@ -90,7 +90,7 @@
def _do_update(self, amount_read, now=None):
etime = self.re.elapsed_time()
- fetime = format_time(etime)
+ fetime = format_time(etime, 1, False)
fread = format_number(amount_read)
#self.size = None
if self.text is not None:
@@ -102,18 +102,19 @@
(text, fread, fetime)
else:
rtime = self.re.remaining_time()
- frtime = format_time(rtime)
+ frtime = format_time(rtime, 1, False)
frac = self.re.fraction_read()
- bar = '='*int(25 * frac)
- out = '\r%-25.25s %3i%% |%-25.25s| %5sB %8s ETA ' % \
- (text, frac*100, bar, fread, frtime)
+ bar = '='*int(14 * frac)
+ ave_dl = format_number(self.re.average_rate())
+ out = '\r%-25.25s %3i%% |%-14.14s| %5sB/s | %5sB %9s ETA ' % \
+ (text, frac*100, bar, ave_dl, fread, frtime)
self.fo.write(out)
self.fo.flush()
def _do_end(self, amount_read, now=None):
- total_time = format_time(self.re.elapsed_time())
+ total_time = format_time(self.re.elapsed_time(), 1, False)
total_size = format_number(amount_read)
if self.text is not None:
text = self.text
@@ -123,9 +124,9 @@
out = '\r%-60.60s %5sB %s ' % \
(text, total_size, total_time)
else:
- bar = '='*25
- out = '\r%-25.25s %3i%% |%-25.25s| %5sB %8s ' % \
- (text, 100, bar, total_size, total_time)
+ out = '\r%-56.56s | %5sB %9s ' % \
+ (text, total_size, total_time)
+
self.fo.write(out + '\n')
self.fo.flush()
@@ -475,10 +476,10 @@
return float(int(rt) >> shift << shift)
-def format_time(seconds, use_hours=0):
+def format_time(seconds, use_hours=0, zero_expand=True):
if seconds is None or seconds < 0:
- if use_hours: return '--:--:--'
- else: return '--:--'
+ if use_hours and zero_expand: return '--:--:--'
+ else: return '--:--'
else:
seconds = int(seconds)
minutes = seconds / 60
@@ -486,9 +487,10 @@
if use_hours:
hours = minutes / 60
minutes = minutes % 60
- return '%02i:%02i:%02i' % (hours, minutes, seconds)
- else:
- return '%02i:%02i' % (minutes, seconds)
+ if zero_expand or hours >= 1:
+ return '%02i:%02i:%02i' % (hours, minutes, seconds)
+ # Always include minutes and seconds
+ return '%02i:%02i' % (minutes, seconds)
def format_number(number, SI=0, space=' '):
"""Turn numbers into human-readable metric-like numbers"""
@@ -528,3 +530,47 @@
format = '%.0f%s%s'
return(format % (float(number or 0), space, symbols[depth]))
+
+def _tst(fn, cur, tot, beg, size, *args):
+ tm = TextMeter()
+ text = "(%d/%d): %s" % (cur, tot, fn)
+ tm.start(fn, "http://www.example.com/path/to/fn/" + fn, fn, size, text=text)
+ num = beg
+ off = 0
+ for (inc, delay) in args:
+ off += 1
+ while num < ((size * off) / len(args)):
+ num += inc
+ tm.update(num)
+ time.sleep(delay)
+ tm.end(size)
+
+if __name__ == "__main__":
+ # (1/2): subversion-1.4.4-7.x86_64.rpm 2.4 MB / 85 kB/s 00:28
+ # (2/2): mercurial-0.9.5-6.fc8.x86_64.rpm 924 kB / 106 kB/s 00:08
+
+ _tst("sm-1.0.0-1.fc8.i386.rpm", 1, 10, 0, 1000,
+ (10, 0.2), (10, 0.1), (100, 0.25))
+ _tst("s-1.0.1-1.fc8.i386.rpm", 2, 10, 0, 10000,
+ (10, 0.2), (100, 0.1), (100, 0.1), (100, 0.25))
+ _tst("m-1.0.1-2.fc8.i386.rpm", 3, 10, 5000, 10000,
+ (10, 0.2), (100, 0.1), (100, 0.1), (100, 0.25))
+ _tst("large-file-name-Foo-11.8.7-4.5.6.1.fc8.x86_64.rpm", 4, 10, 0, 1000000,
+ (1000, 0.2), (1000, 0.1), (10000, 0.1))
+ _tst("large-file-name-Foo2-11.8.7-4.5.6.2.fc8.x86_64.rpm", 5, 10,
+ 500001, 1000000, (1000, 0.2), (1000, 0.1), (10000, 0.1))
+ _tst("large-file-name-Foo3-11.8.7-4.5.6.3.fc8.x86_64.rpm", 6, 10,
+ 750002, 1000000, (1000, 0.2), (1000, 0.1), (10000, 0.1))
+ _tst("large-file-name-Foo4-10.8.7-4.5.6.1.fc8.x86_64.rpm", 7, 10, 0, 10000,
+ (100, 0.1))
+ _tst("large-file-name-Foo5-10.8.7-4.5.6.2.fc8.x86_64.rpm", 8, 10,
+ 5001, 10000, (100, 0.1))
+ _tst("large-file-name-Foo6-10.8.7-4.5.6.3.fc8.x86_64.rpm", 9, 10,
+ 7502, 10000, (100, 0.1))
+ _tst("large-file-name-Foox-9.8.7-4.5.6.1.fc8.x86_64.rpm", 10, 10,
+ 0, 1000000, (10, 0.5),
+ (10000, 0.1), (10000, 0.1), (10000, 0.1), (10000, 0.1),
+ (10000, 0.1), (10000, 0.1), (10000, 0.1), (10000, 0.1),
+ (10000, 0.1), (10000, 0.1), (10000, 0.1), (10000, 0.1),
+ (10000, 0.1), (10000, 0.1), (10000, 0.1), (10000, 0.1),
+ (10000, 0.1), (10000, 0.25))
signature.asc
Description: This is a digitally signed message part
_______________________________________________ Yum-devel mailing list [email protected] https://lists.dulug.duke.edu/mailman/listinfo/yum-devel
