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 config
.network_use
= model
.network_full
46 options
.offline
= False
48 options
.refresh
= True
50 sels
= select
.get_selections(config
, options
, iface_uri
,
51 select_only
= False, download_only
= True, test_callback
= None)
53 sys
.exit(1) # Aborted by user
57 for iface
, old_sel
in old_selections
.iteritems():
58 new_sel
= sels
.selections
.get(iface
, None)
60 print _("No longer used: %s") % iface
62 elif old_sel
.version
!= new_sel
.version
:
63 print _("%s: %s -> %s") % (iface
, old_sel
.version
, new_sel
.version
)
66 for iface
, new_sel
in sels
.selections
.iteritems():
67 if iface
not in old_selections
:
68 print _("%s: new -> %s") % (iface
, new_sel
.version
)
72 print _("No updates found.")