From 9871f3f1b709a67777ed2721cf4e969f55205a5a Mon Sep 17 00:00:00 2001 From: Brian Warner <warner@allmydata.com> Date: Tue, 18 Nov 2008 20:17:36 -0700 Subject: [PATCH] cli: 'tahoe stats': add abbreviated size to the histogram. Not sure this actually improves things. --- src/allmydata/scripts/tahoe_manifest.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/allmydata/scripts/tahoe_manifest.py b/src/allmydata/scripts/tahoe_manifest.py index c7aac42c..7469f9e9 100644 --- a/src/allmydata/scripts/tahoe_manifest.py +++ b/src/allmydata/scripts/tahoe_manifest.py @@ -1,5 +1,6 @@ from allmydata.util import base32 +from allmydata.util.abbreviate import abbreviate_space_both from allmydata import uri from allmydata.scripts.slow_operation import SlowOperationRunner @@ -59,14 +60,19 @@ class StatsGrabber(SlowOperationRunner): maxlen = max([len(str(maxsize)) for (minsize, maxsize, count) in data["size-files-histogram"]]) + maxcountlen = max([len(str(count)) + for (minsize, maxsize, count) + in data["size-files-histogram"]]) minfmt = "%" + str(maxlen) + "d" maxfmt = "%-" + str(maxlen) + "d" - linefmt = minfmt + "-" + maxfmt + " : %d" + countfmt = "%-" + str(maxcountlen) + "d" + linefmt = minfmt + "-" + maxfmt + " : " + countfmt + " %s" for (minsize, maxsize, count) in data["size-files-histogram"]: if prevmax is not None and minsize != prevmax+1: print >>stdout, " "*(maxlen-1) + "..." prevmax = maxsize - print >>stdout, linefmt % (minsize, maxsize, count) + print >>stdout, linefmt % (minsize, maxsize, count, + abbreviate_space_both(maxsize)) def stats(options): return StatsGrabber().run(options) -- 2.45.2