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