[yum-git] 2 commits - output.py yum/__init__.py

James Antill james at linux.duke.edu
Tue Apr 22 23:04:50 UTC 2008


 output.py       |   55 +++++++++++++++++++++++++++++++++++++++++++++++++++----
 yum/__init__.py |    3 +++
 2 files changed, 54 insertions(+), 4 deletions(-)

New commits:
commit e985627f074202e2f1a5bcd221079c16b288b13e
Author: James Antill <james at and.org>
Date:   Tue Apr 22 18:59:02 2008 -0400

     Fix translated process name chopping, for another 5 chars, fixes bug#442935.
     Don't chop pkg names on 100%, ala. downloads.
     Don't chop name in progressbar, ala. downloads.
     Add tester "output.py progress"

diff --git a/output.py b/output.py
index c0cbb02..0f312b9 100644
--- a/output.py
+++ b/output.py
@@ -729,7 +729,7 @@ class YumCliRPMCallBack(RPMBaseCallback):
         
         # for a progress bar
         self.mark = "#"
-        self.marks = 27
+        self.marks = 22
         
         
     def event(self, package, action, te_current, te_total, ts_current, ts_total):
@@ -770,12 +770,18 @@ class YumCliRPMCallBack(RPMBaseCallback):
         marks = self.marks - (2 * l)
         width = "%s.%s" % (marks, marks)
         fmt_bar = "%-" + width + "s"
-        if progress:
+        pnl = str(28 + marks + 1)
+
+        if progress and percent == 100: # Don't chop pkg name on 100%
+            fmt = "\r  %-15.15s: %-" + pnl + '.' + pnl + "s " + done
+        elif progress:
             bar = fmt_bar % (self.mark * int(marks * (percent / 100.0)), )
-            fmt = "\r  %-10.10s: %-28.28s " + bar + " " + done
+            fmt = "\r  %-15.15s: %-28.28s " + bar + " " + done
+        elif percent == 100:
+            fmt = "  %-15.15s: %-" + pnl + '.' + pnl + "s " + done
         else:
             bar = fmt_bar % (self.mark * marks, )
-            fmt = "  %-10.10s: %-28.28s "  + bar + " " + done
+            fmt = "  %-15.15s: %-28.28s "  + bar + " " + done
         return fmt
 
 
@@ -798,6 +804,8 @@ def progressbar(current, total, name=None):
     hashbar = mark * numblocks
     if name is None:
         output = '\r%-50s %d/%d' % (hashbar, current, total)
+    elif current == total: # Don't chop name on 100%
+        output = '\r%-62.62s %d/%d' % (name, current, total)
     else:
         output = '\r%-10.10s: %-50s %d/%d' % (name, hashbar, current, total)
      
@@ -809,3 +817,42 @@ def progressbar(current, total, name=None):
 
     sys.stdout.flush()
         
+
+if __name__ == "__main__":
+    if len(sys.argv) > 1 and sys.argv[1] == "progress":
+        print ""
+        print " Doing progress, small name"
+        print ""
+        for i in xrange(0, 101):
+            progressbar(i, 100, "abcd")
+            time.sleep(0.1)
+        print ""
+        print " Doing progress, big name"
+        print ""
+        for i in xrange(0, 101):
+            progressbar(i, 100, "_%s_" % ("123456789 " * 5))
+            time.sleep(0.1)
+        print ""
+        print " Doing progress, no name"
+        print ""
+        for i in xrange(0, 101):
+            progressbar(i, 100)
+            time.sleep(0.1)
+
+        cb = YumCliRPMCallBack()
+        cb.action["foo"] = "abcd"
+        cb.action["bar"] = "_12345678_.end"
+        print ""
+        print " Doing CB, small proc / small pkg"
+        print ""
+        for i in xrange(0, 101):
+            cb.event("spkg", "foo", i, 100, i, 100)
+            time.sleep(0.1)        
+        print ""
+        print " Doing CB, big proc / big pkg"
+        print ""
+        for i in xrange(0, 101):
+            cb.event("lpkg" + "-=" * 15 + ".end", "bar", i, 100, i, 100)
+            time.sleep(0.1)
+        print ""
+        
commit 9c059691a1323304de76b9a68a12df2a063ec3bb
Author: James Antill <james at and.org>
Date:   Mon Apr 21 11:53:13 2008 -0400

    Download pkgs smallest to largest, to get full pkg downloads sooner

diff --git a/yum/__init__.py b/yum/__init__.py
index 6b2945d..efee839 100644
--- a/yum/__init__.py
+++ b/yum/__init__.py
@@ -1026,6 +1026,9 @@ class YumBase(depsolve.Depsolve):
             # could conceivably ping-pong between different disc1's
             a = a.getDiscNum()
             b = b.getDiscNum()
+            if a is None and b is None:
+                # Download smallest pkgs first
+                return a.size - b.size
             if a is None:
                 return -1
             if b is None:



More information about the Yum-cvs-commits mailing list