2 import wizard.deploy as wd
5 # XXX: Migrate this to use logger
7 def __init__(self, quiet, verbose):
10 self.verbose = verbose
14 if not self.quiet and self.i % 10 == 0:
22 def write(self, str = ""):
25 def qwrite(self, str = ""):
29 def tweet(self, str = ""):
32 print str, # note comma
33 def chat(self, str = ""):
38 def summary(argv, global_options):
39 usage = """usage: %prog summary [ARGS] APPS
41 Scans all of the collected data from parallel-find.pl, and
42 determines version histograms for our applications. You may
43 optionally pass application parameters to filter the installs.
48 %prog summary mediawiki
49 Displays only MediaWiki statistics
50 %prog summary -v -q mediawiki-1.2.3
51 Displays all deployments of this version"""
52 parser = optparse.OptionParser(usage)
53 parser.add_option("-v", "--verbose", dest="verbose", action="store_true",
54 default=False, help="Print interesting directories")
55 parser.add_option("-q", "--quiet", dest="quiet", action="store_true",
56 default=False, help="Suppresses progress output")
57 parser.add_option("--count-exists", dest="count_exists",
58 default=False, help="Count deployments that contain a file")
59 options, show = parser.parse_args(argv)
60 fi = wd.getInstallLines(global_options)
61 if not show: show = wd.applications.keys()
62 show = frozenset(show)
66 printer = Printer(options.quiet, options.verbose)
67 printer.tweet("Processing")
71 deploy = wd.Deployment.parse(line)
72 except wd.DeploymentParseError:
75 except wd.NoSuchApplication:
78 name = deploy.getApplication().name
79 if name + "-" + str(deploy.getVersion()) in show:
80 printer.write("%s-%s deployment at %s" \
81 % (name, deploy.getVersion(), deploy.location))
87 if options.count_exists:
88 r = deploy.count_exists(options.count_exists)
90 printer.chat("Found " + options.count_exists + " in " + deploy.location)
92 for app in wd.applications.values():
93 if app.name not in show: continue
94 printer.write(app.report())
96 printer.write("With %d errors and %d unrecognized applications" % (errors, unrecognized))