]> scripts.mit.edu Git - wizard.git/blob - wizard/command/summary/__init__.py
Move a bunch of summary items to full class commands.
[wizard.git] / wizard / command / summary / __init__.py
1 import optparse
2 import os
3 import logging
4
5 import wizard
6 from wizard import command, deploy
7
8 def main(argv, baton):
9     usage = """usage: %prog summary [ARGS] APPS
10
11 Scans all of the collected data from parallel-find.pl, and
12 calculates interesting information about them.
13
14 Its subcommands are:
15     version         Breakdown of autoinstalls by version (default)
16
17 Use %prog summary SUBCOMMAND --help for more information."""
18     parser = command.WizardOptionParser(usage)
19     parser.disable_interspersed_args()
20     baton.push(parser, "versions_path")
21     _, args = parser.parse_all(argv)
22     rest_argv = args[1:]
23     try:
24         command_name = args[0]
25     except IndexError:
26         command_name = "version"
27     def get_command(name):
28         member = name.replace("-", "_")
29         module = "wizard.command.summary." + member
30         __import__(module)
31         return getattr(wizard.command.summary, member)
32     if command == "help":
33         try:
34             get_command(rest_argv[0]).main(['--help'], baton)
35         except ImportError:
36             parser.error("invalid action")
37         except IndexError:
38             parser.print_help()
39             raise SystemExit(1)
40     try:
41         command_module = get_command(command_name)
42     except ImportError:
43         parser.error("invalid action")
44     command_module.main(rest_argv, baton)
45