]> scripts.mit.edu Git - wizard.git/blob - wizard/command/list.py
Remove unnecessary imports.
[wizard.git] / wizard / command / list.py
1 import logging
2 import os.path
3
4 from wizard import command, deploy
5
6 def main(argv, baton):
7     options, show = parse_args(argv, baton)
8     errors = 0
9     for d in deploy.parse_install_lines(show, options.versions_path, True, user=options.user):
10         if isinstance(d, Exception):
11             errors += 1
12             continue
13         if options.exists and not os.path.exists(os.path.join(d.location, options.exists)):
14             continue
15         print d.location
16     if errors:
17         logging.warning("%d errors, see 'wizard errors --verbose' for details" % errors)
18
19 def parse_args(argv, baton):
20     usage = """usage: %prog list [ARGS] [APP[-VERSION]]
21
22 Lists the locations of all autoinstalls, optionally
23 filtered on parameters such as application name and version.
24
25 Examples:
26     %prog list
27         List all autoinstalls
28     %prog list --exists php.ini
29         List all autoinstalls with php.ini
30     %prog list mediawiki
31         List only MediaWiki autoinstalls
32     %prog list mediawiki-1.11.0
33         List only Mediawiki 1.11.0 autoinstalls"""
34     parser = command.WizardOptionParser(usage)
35     parser.add_option("-e", "--exists", dest="exists",
36             help="only print deployment if FILE exists", metavar="FILE")
37     baton.push(parser, "versions_path")
38     baton.push(parser, "user")
39     options, args = parser.parse_all(argv)
40     if len(args) > 1:
41         parser.error("too many arguments")
42     return options, args
43