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 optparse
import OptionParser
12 from zeroinstall
import cmd
, 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)
38 except SafeException
, ex
:
44 old_selections
= old_sels
.selections
46 # Download in online mode to get the new values
47 options
.offline
= False
49 options
.refresh
= True
51 sels
= select
.get_selections(config
, options
, iface_uri
,
52 select_only
= False, download_only
= True, test_callback
= None)
54 sys
.exit(1) # Aborted by user
58 for iface
, old_sel
in old_selections
.iteritems():
59 new_sel
= sels
.selections
.get(iface
, None)
61 print _("No longer used: %s") % iface
63 elif old_sel
.version
!= new_sel
.version
:
64 print _("%s: %s -> %s") % (iface
, old_sel
.version
, new_sel
.version
)
67 for iface
, new_sel
in sels
.selections
.iteritems():
68 if iface
not in old_selections
:
69 print _("%s: new -> %s") % (iface
, new_sel
.version
)
73 print _("No updates found.")