From: Zac Medico Date: Wed, 22 Aug 2007 04:05:38 +0000 (-0000) Subject: Show cache miss/hit counts all on one line, using \r to return to the beginning of... X-Git-Tag: v2.2_pre1~869 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=213d6dffe3ee2083b9435cbbde659d04afb9b691;p=portage.git Show cache miss/hit counts all on one line, using \r to return to the beginning of he line and rewrite it each time that a counter is updated. Thanks to Mike "Fuzzy" Partin for this patch (submitted on the gentoo-portage-dev mailing list). svn path=/main/trunk/; revision=7655 --- diff --git a/pym/portage/getbinpkg.py b/pym/portage/getbinpkg.py index 6e0ab5168..8ca6642d2 100644 --- a/pym/portage/getbinpkg.py +++ b/pym/portage/getbinpkg.py @@ -541,13 +541,17 @@ def dir_get_metadata(baseurl, conn=None, chunk_size=3000, verbose=1, usingcache= 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)+"'")) 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("\r"+yellow("cache miss: '"+str(ext_miss)+"'")+" --- "+green("cache hit: '"+str(ext_hit)+"'")) + sys.stderr.flush() metadata[baseurl]["modified"] = 1 myid = None for retry in xrange(3): @@ -569,7 +573,9 @@ def dir_get_metadata(baseurl, conn=None, chunk_size=3000, verbose=1, usingcache= 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("\r"+yellow("cache miss: '"+str(ext_miss)+"'")+" --- "+green("cache hit: '"+str(ext_hit)+"'")) + 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: