7 sys.path.insert(0,os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
10 from wizard import command
13 usage = """usage: %prog COMMAND [ARGS]
15 Wizard is a Git-based autoinstall management system for scripts.
18 configure Configures an autoinstall (database, etc) to work
19 errors Lists all broken autoinstall metadata
20 install Installs an application
21 list Lists autoinstalls, with optional filtering
22 mass-migrate Performs mass migration of autoinstalls of an application
23 migrate Migrate autoinstalls from old format to Git-based format
24 prepare-config Prepares configuration files for versioning
25 research Print statistics about a possible upgrade
26 summary Generate statistics (see help for subcommands)
27 upgrade Upgrades an autoinstall to the latest version
29 See '%prog help COMMAND' for more information on a specific command."""
31 parser = optparse.OptionParser(usage)
32 parser.disable_interspersed_args()
33 _, args = parser.parse_args() # no global options
35 baton = command.OptionBaton()
36 baton.add("--versions-path", dest="versions_path", metavar="PATH",
37 default=getenvpath("WIZARD_VERSIONS_PATH") or "/afs/athena.mit.edu/contrib/scripts/sec-tools/store/versions",
38 help="Location of parallel-find output directory, or a file containing a newline separated list of 'all autoinstalls' (for development work). Environment variable is WIZARD_VERSIONS_PATH.")
39 baton.add("--srv-path", dest="srv_path", metavar="PATH",
40 default=getenvpath("WIZARD_SRV_PATH") or "/afs/athena.mit.edu/contrib/scripts/git/autoinstalls",
41 help="Location of autoinstall Git repositories, such that $REPO_PATH/$APP.git is a repository (for development work). Environment variable is WIZARD_SRV_PATH.")
42 baton.add("--dry-run", dest="dry_run", action="store_true",
43 default=False, help="Print the results of the operation without actually executing them")
44 # common variables for mass commands
45 baton.add("--seen", dest="seen",
46 default=None, help="File to read/write paths of already processed installs."
47 "These will be skipped.")
48 baton.add("--no-parallelize", dest="no_parallelize", action="store_true",
49 default=False, help="Turn off parallelization")
50 baton.add("--max-processes", dest="max_processes", type="int", metavar="N",
51 default=10, help="Maximum subprocesses to run concurrently")
52 baton.add("--limit", dest="limit", type="int",
53 default=None, help="Limit the number of autoinstalls to look at.")
55 command_name = args[0]
59 baton.add("--log-dir", dest="log_dir",
60 default=getenvpath("WIZARD_LOG_DIR") or "/tmp/wizard-%s" % command_name,
61 help="Log files for Wizard children processes are placed here.")
62 if command_name == "help":
64 help_module = get_command(rest_argv[0])
66 parser.error("invalid action")
70 help_module.main(['--help'], baton)
73 command_module = get_command(command_name)
75 parser.error("invalid action")
76 command_module.main(rest_argv, baton)
78 def get_command(name):
79 name = name.replace("-", "_")
80 __import__("wizard.command." + name)
81 return getattr(wizard.command, name)
86 val = os.path.abspath(val)
89 if __name__ == "__main__":