X-Git-Url: https://scripts.mit.edu/gitweb/wizard.git/blobdiff_plain/e3bc19b85eb7e4bc77c2a24baab9747fe5aadb7c..b82e2a15589e2c0ac3cbaec09905c6d1ca913810:/wizard/command/summary/version.py diff --git a/wizard/command/summary/version.py b/wizard/command/summary/version.py new file mode 100644 index 0000000..c0e59e8 --- /dev/null +++ b/wizard/command/summary/version.py @@ -0,0 +1,44 @@ +import math + +from wizard.command import _command +from wizard.command.summary import _summary + +def main(argv, baton): + options, show = parse_args(argv, baton) + HISTOGRAM_WIDTH = 30 + show = set() + c_version = _summary.Counter() + c_application = _summary.Counter() + for d in _summary.parse_install_lines(show, options): + version = d.getAppVersion() + c_version.count(version) + c_application.count(version.application) + show.add(version.application) + if not show: + print "No applications found" + for application in show: + print "%-16s %3d installs" % (application.name, c_application[application]) + vmax = max(c_version[x] for x in application.versions.values()) + for version in sorted(application.versions.values()): + v = c_version[version] + graph = '+' * int(math.ceil(float(v)/vmax * HISTOGRAM_WIDTH)) + print " %-12s %3d %s" % (version.version, v, graph) + print + +def parse_args(argv, baton): + usage = """usage: %prog summary version [ARGS] [APP] + +Prints graphs of version usage in autoinstallers + +Examples: + %prog summary list + Show graphs for all autoinstall versions + %prog summary list mediawiki + Show graph for MediaWiki autoinstall versions""" + parser = _command.WizardOptionParser(usage) + baton.push(parser, "versions_path") + options, args = parser.parse_all(argv) + if len(args) > 1: + parser.error("too many arguments") + return options, args +