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