return " %-12s %3d %s" \
% (self.version, self.c, self.application._graph(self.c))
+class Printer(object):
+ def __init__(self, quiet, verbose):
+ self.i = 0
+ self.quiet = quiet
+ self.verbose = verbose
+ self.hanging = False
+ def tick(self):
+ self.i += 1
+ if not self.quiet and self.i % 10 == 0:
+ sys.stdout.write(".")
+ sys.stdout.flush()
+ self.hanging = True
+ def _hang(self):
+ if self.hanging:
+ self.hanging = False
+ print
+ def write(self, str = ""):
+ self._hang()
+ print str
+ def qwrite(self, str = ""):
+ if not self.quiet:
+ self._hang
+ print str
+ def tweet(self, str = ""):
+ if not self.quiet:
+ self._hang()
+ print str, # note comma
+ def chat(self, str = ""):
+ if self.verbose:
+ self._hang()
+ print str
+
application_list = [
"mediawiki", "wordpress", "joomla", "e107", "gallery2",
"phpBB", "advancedbook", "phpical", "trac", "turbogears", "django",
Scans all of the collected data from parallel-find.pl, and
determines version histograms for our applications. You may
-optionally pass application parameters to filter the installs."""
+optionally pass application parameters to filter the installs.
+
+Examples:
+ %prog
+ Basic usage
+ %prog mediawiki
+ Displays only MediaWiki statistics
+ %prog -v -q mediawiki-1.2.3
+ Displays all deployments of this version"""
parser = optparse.OptionParser(usage)
parser.add_option("-v", "--verbose", dest="verbose", action="store_true",
default=False, help="Print interesting directories")
errors = 0
unrecognized = 0
processed = 0
+ printer = Printer(options.quiet, options.verbose)
# I really don't like this boolean
hanging = False # whether or not we last outputted a newline
- if not options.quiet: print "Processing",
+ printer.tweet("Processing")
for line in fi:
- processed += 1
- if not options.quiet and processed % 10 == 0:
- sys.stdout.write(".")
- sys.stdout.flush()
- hanging = True
+ printer.tick()
try:
deploy = Deployment.parse(line)
except DeploymentParseError:
unrecognized += 1
continue
if deploy.application.name + "-" + str(deploy.version.version) in show:
- if hanging:
- hanging = False
- print
- print "%s-%s deployment at %s" \
- % (deploy.application.name, deploy.version.version, deploy.location)
+ printer.write("%s-%s deployment at %s" \
+ % (deploy.application.name, deploy.version.version, deploy.location))
elif deploy.application.name in show:
pass
else:
deploy.count()
if options.count_exists:
r = deploy.count_exists(options.count_exists)
- if r and options.verbose:
- if hanging:
- hanging = False
- print
- print "Found " + options.count_exists + " in " + deploy.location
- if hanging: print
- print
+ if r:
+ printer.chat("Found " + options.count_exists + " in " + deploy.location)
+ printer.write()
for app in applications.values():
if app.name not in show: continue
- print app
- print
- print "With %d errors and %d unrecognized applications" % (errors, unrecognized)
+ printer.write(app)
+ printer.write()
+ printer.write("With %d errors and %d unrecognized applications" % (errors, unrecognized))
if __name__ == "__main__":
main()