]> scripts.mit.edu Git - wizard.git/blob - wizard/command/errors.py
10be7aa44a12e7722eaa78e05105318e9996a522
[wizard.git] / wizard / command / errors.py
1 import logging
2
3 from wizard import app, deploy, command
4
5 def main(argv, baton):
6     options, show = parse_args(argv, baton)
7     for e in deploy.parse_install_lines(show, options.versions_path, True):
8         if not isinstance(e, deploy.Error) and not isinstance(e, app.Error):
9             if isinstance(e, Exception):
10                 raise e
11             continue
12         if options.verbose:
13             if isinstance(e, app.NoSuchApplication):
14                 print "Application %s does not exist, at %s" % (e.app, e.location)
15             elif isinstance(e, app.DeploymentParseError):
16                 print "Parse error for line '%s', at %s" % (e.value, e.location)
17             else:
18                 raise e
19         else:
20             print e.location
21
22 def parse_args(argv, baton):
23     usage = """usage: %prog errors [ARGS]
24
25 Lists all errors that occurred while parsing the versions
26 directory."""
27     parser = command.WizardOptionParser(usage)
28     baton.push(parser, "versions_path")
29     options, args = parser.parse_all(argv)
30     if len(args) > 1:
31         parser.error("too many arguments")
32     return options, args
33