]> scripts.mit.edu Git - wizard.git/blob - wizard/command/configure.py
Remove unnecessary imports.
[wizard.git] / wizard / command / configure.py
1 import optparse
2 import distutils.version
3
4 from wizard import app, command, git, shell, util
5
6 def main(argv, baton):
7
8     usage = """usage: %prog configure [ARGS]
9
10 Takes an already cloned working copy and configures the
11 application, running any installer scripts and creating
12 configuration files.  Options change depending on what
13 application is being configured in the current working directory.
14
15 This is a plumbing command, normal users should use
16 `%prog install`."""
17
18     # XXX: squick squick squick
19     if argv and argv[0][0] != '-':
20         if '--help' not in argv and '-h' not in argv:
21             argv.append('--help')
22     if '--help' in argv or '-h' in argv:
23         # Do a "fake parse" in order to get out the application name
24         parser = optparse.OptionParser(usage, add_help_option=False)
25         parser.add_option("--help", "-h", action="store_true")
26         options, args = parser.parse_args(argv)
27         try:
28             application = args[0]
29         except IndexError:
30             parser.error("Use 'wizard configure --help APP' to see APP-specific options.")
31         version = None # not relevant
32     else:
33         tag = git.describe()
34         application, _, version = tag.partition('-')
35
36     application = app.applications()[application]
37     handler = application.install_handler
38
39     parser = command.WizardOptionParser(usage)
40     handler.push(parser)
41     options, args = parser.parse_all(argv)
42     handler.handle(options)
43
44     application.install(distutils.version.LooseVersion(version), options)
45
46     sh = shell.Shell()
47     message = "Autoinstall configuration of %s locker.\n\n%s" % (util.get_dir_owner(), util.get_git_footer())
48     util.set_git_env()
49     try:
50         message += "\nConfigured-by: " + util.get_operator_git()
51     except util.NoOperatorInfo:
52         pass
53     sh.call("git", "commit", "--allow-empty", "-a", "-m", message)
54