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.
10 from zeroinstall
import SafeException
, _
11 from zeroinstall
.injector
import model
12 from zeroinstall
.cmd
import UsageError
, select
16 add_options
= select
.add_generic_select_options
18 def handle(config
, options
, args
):
22 assert not options
.offline
24 iface_uri
= model
.canonical_iface_uri(args
[0])
28 # Select once in offline console mode to get the old values
29 options
.offline
= True
31 options
.refresh
= False
34 old_sels
= select
.get_selections(config
, options
, iface_uri
,
35 select_only
= True, download_only
= False, test_callback
= None)
42 old_selections
= old_sels
.selections
44 # Download in online mode to get the new values
45 options
.offline
= False
47 options
.refresh
= True
49 sels
= select
.get_selections(config
, options
, iface_uri
,
50 select_only
= False, download_only
= True, test_callback
= None)
52 sys
.exit(1) # Aborted by user
56 for iface
, old_sel
in old_selections
.iteritems():
57 new_sel
= sels
.selections
.get(iface
, None)
59 print _("No longer used: %s") % iface
61 elif old_sel
.version
!= new_sel
.version
:
62 print _("%s: %s -> %s") % (iface
, old_sel
.version
, new_sel
.version
)
65 for iface
, new_sel
in sels
.selections
.iteritems():
66 if iface
not in old_selections
:
67 print _("%s: new -> %s") % (iface
, new_sel
.version
)
71 print _("No updates found.")