Fixed Python 3 whitespace error in 0alias
[zeroinstall/solver.git] / zeroinstall / cmd / download.py
blobf3bc20015ac068d9d31ea64cf63c53af7c0b24dd
1 """
2 The B{0install download} command-line interface.
3 """
5 # Copyright (C) 2011, Thomas Leonard
6 # See the README file for details, or visit http://0install.net.
8 import sys
10 from zeroinstall import _
11 from zeroinstall.cmd import UsageError, select
12 from zeroinstall.injector import model
14 syntax = "URI"
16 def add_options(parser):
17 select.add_options(parser)
18 parser.add_option("", "--show", help=_("show where components are installed"), action='store_true')
20 def handle(config, options, args):
21 if len(args) != 1:
22 raise UsageError()
24 app = config.app_mgr.lookup_app(args[0], missing_ok = True)
25 if app is not None:
26 sels = app.get_selections()
28 r = app.get_requirements()
29 do_select = r.parse_update_options(options)
30 iface_uri = sels.interface
31 else:
32 iface_uri = model.canonical_iface_uri(args[0])
33 do_select = True
35 if do_select or options.gui:
36 sels = select.get_selections(config, options, iface_uri,
37 select_only = False, download_only = True, test_callback = None)
38 if not sels:
39 sys.exit(1) # Aborted by user
40 else:
41 dl = app.download_selections(sels)
42 if dl:
43 tasks.wait_for_blocker(dl)
44 tasks.check(dl)
46 if options.xml:
47 select.show_xml(sels)
48 if options.show:
49 select.show_human(sels, config.stores)
50 if app is not None and do_select:
51 print(_("(use '0install update' to save the new parameters)"))