2 The B{0install download} command-line interface.
5 # Copyright (C) 2011, Thomas Leonard
6 # See the README file for details, or visit http://0install.net.
8 from __future__
import print_function
12 from zeroinstall
import SafeException
, _
13 from zeroinstall
.injector
import model
14 from zeroinstall
.cmd
import UsageError
, select
18 add_options
= select
.add_generic_select_options
20 def handle(config
, options
, args
):
24 assert not options
.offline
26 iface_uri
= model
.canonical_iface_uri(args
[0])
30 # Select once in offline console mode to get the old values
31 options
.offline
= True
33 options
.refresh
= False
36 old_sels
= select
.get_selections(config
, options
, iface_uri
,
37 select_only
= True, download_only
= False, test_callback
= None)
44 old_selections
= old_sels
.selections
46 # Download in online mode to get the new values
47 config
.network_use
= model
.network_full
48 options
.offline
= False
50 options
.refresh
= True
52 sels
= select
.get_selections(config
, options
, iface_uri
,
53 select_only
= False, download_only
= True, test_callback
= None)
55 sys
.exit(1) # Aborted by user
59 for iface
, old_sel
in old_selections
.iteritems():
60 new_sel
= sels
.selections
.get(iface
, None)
62 print(_("No longer used: %s") % iface
)
64 elif old_sel
.version
!= new_sel
.version
:
65 print(_("%s: %s -> %s") % (iface
, old_sel
.version
, new_sel
.version
))
68 for iface
, new_sel
in sels
.selections
.iteritems():
69 if iface
not in old_selections
:
70 print(_("%s: new -> %s") % (iface
, new_sel
.version
))
74 print(_("No updates found."))