]> scripts.mit.edu Git - wizard.git/blob - wizard/command/blacklist.py
Nicer errors if not in autoinstall directory.
[wizard.git] / wizard / command / blacklist.py
1 import os
2
3 from wizard import command, deploy, shell, util
4
5 def main(argv, baton):
6     options, args = parse_args(argv, baton)
7     reason = args[0]
8     # Directory information not transferred via command line, so this
9     # will not error due to the changed directory.
10     shell.drop_priviledges(".", options.log_file)
11     # XXX: this should be abstracted away!
12     if os.path.exists(".git/WIZARD_REPO"):
13         util.chdir(shell.eval('git', 'config', 'remote.origin.url'))
14     production = deploy.ProductionCopy(".")
15     production.verify()
16     open('.scripts/blacklisted', 'w').write(reason + "\n")
17
18 def parse_args(argv, baton):
19     usage = """usage: %prog blacklist [ARGS] REASON
20
21 Touches .scripts/blacklisted so that we don't attempt
22 to upgrade the script in the future."""
23     parser = command.WizardOptionParser(usage)
24     options, args = parser.parse_all(argv)
25     if len(args) > 2:
26         parser.error("too many arguments")
27     if len(args) < 1:
28         parser.error("must specify reason")
29     return options, args
30