This patch only makes sure that a newline is inserted before the 'Fetching 
binary packages 
info ...' line, and changes the yellow and green x's and o's to a single line, 
with a 
counter variable for each. Example:

These are the packages that would be merged, in order:

Calculating dependencies /
Fetching binary packages info...
cache miss: '532' --- cache hit: '0'
  -- DONE!

I only did this because we use a binhost here on our network and the colors and 
extremely 
long string were pretty glaring. I added sys.stderr.flush() after each of the 
sys.stderr.write() lines to allow for updating the screen live. The preformance 
hit for 
flushing every write is fairly negligible on my machine which is a 2.5Ghz P4 w/ 
1G of ram.
YMMV.

The version string on the patch is from the portage version I'm using and 
patched against, 
which is portage-2.1.3.5.

Cheers,
Mike "Fuzzy" Partin
--- /usr/lib/portage/pym/getbinpkg.py   2007-08-14 09:22:46.000000000 -0500
+++ getbinpkg.py        2007-08-21 10:01:22.000000000 -0500
@@ -544,13 +544,17 @@
                                sys.stderr.write("!!! "+str(e)+"\n")
                        break
        # We may have metadata... now we run through the tbz2 list and check.
-       sys.stderr.write(yellow("cache miss: 'x'")+" --- "+green("cache hit: 
'o'")+"\n")
+       ext_miss = 0
+       ext_hit = 0
+       sys.stderr.write(yellow("cache miss: '"+str(ext_miss)+"'")+" --- 
"+green("cache hit: '"+str(ext_hit)+"'")+"\r")
        binpkg_filenames = set()
        for x in tbz2list:
                x = os.path.basename(x)
                binpkg_filenames.add(x)
                if x not in metadata[baseurl]["data"]:
-                       sys.stderr.write(yellow("x"))
+                       ext_miss += 1
+                       sys.stderr.write(yellow("cache miss: 
'"+str(ext_miss)+"'")+" --- "+green("cache hit: '"+str(ext_hit)+"'")+"\r")
+                       sys.stderr.flush()
                        metadata[baseurl]["modified"] = 1
                        myid = None
                        for retry in xrange(3):
@@ -572,7 +576,9 @@
                        elif verbose:
                                sys.stderr.write(red("!!! Failed to retrieve 
metadata on: ")+str(x)+"\n")
                else:
-                       sys.stderr.write(green("o"))
+                       ext_hit += 1
+                       sys.stderr.write(yellow("cache miss: 
'"+str(ext_miss)+"'")+" --- "+green("cache hit: '"+str(ext_hit)+"'")+"\r")
+                       sys.stderr.flush()
        # Cleanse stale cache for files that don't exist on the server anymore.
        stale_cache = 
set(metadata[baseurl]["data"]).difference(binpkg_filenames)
        if stale_cache:

Reply via email to