]> scripts.mit.edu Git - wizard.git/blobdiff - wizard/command/summary/version.py
Set admin e-mail address properly on MediaWiki >= 1.18.0
[wizard.git] / wizard / command / summary / version.py
index 2dc29c834eefc14d44be3fc8ad277c9b429ff9de..92890cf703f5d51360d07ffb9403e0374f7389bb 100644 (file)
@@ -1,27 +1,44 @@
 import math
+import distutils.version
+import logging
+import traceback
 
-from wizard import command, deploy, util
+from wizard import app, command, deploy, util
 
 def main(argv, baton):
-    options, show = parse_args(argv, baton)
+    options, str_show = parse_args(argv, baton)
     HISTOGRAM_WIDTH = 30
-    show = set()
-    c_version = util.Counter()
-    c_application = util.Counter()
-    for d in deploy.parse_install_lines(show, options):
-        version = d.app_version
-        c_version.count(version)
-        c_application.count(version.application)
-        show.add(version.application)
+    if str_show:
+        apps = app.applications()
+        show = set(apps[x] for x in str_show)
+        accumulate = False
+    else:
+        str_show = []
+        show = set()
+        accumulate = True
+    c_application = {}
+    for d in deploy.parse_install_lines(str_show, options.versions_path):
+        try:
+            c_application.setdefault(d.application, util.Counter())
+            version = util.truncate(d.app_version.version)
+            c_application[d.application].count(version)
+            if accumulate:
+                show.add(d.application)
+        except KeyboardInterrupt:
+            raise
+        except:
+            logging.error("%s in %s" % (traceback.format_exc(), d.location))
     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]
+        counter = c_application[application]
+        total = counter.sum()
+        print "%-20s %3d installs" % (application.name, total)
+        vmax = counter.max()
+        for version in sorted(counter.keys(), key=distutils.version.LooseVersion):
+            v = counter[version]
             graph = '+' * int(math.ceil(float(v)/vmax * HISTOGRAM_WIDTH))
-            print "    %-12s %3d  %s" % (version.version, v, graph)
+            print "    %-16s %3d  %s" % (version, v, graph)
         print
 
 def parse_args(argv, baton):
@@ -30,9 +47,9 @@ def parse_args(argv, baton):
 Prints graphs of version usage in autoinstallers
 
 Examples:
-    %prog summary list
+    %prog summary
         Show graphs for all autoinstall versions
-    %prog summary list mediawiki
+    %prog summary version mediawiki
         Show graph for MediaWiki autoinstall versions"""
     parser = command.WizardOptionParser(usage)
     baton.push(parser, "versions_path")