3 from optparse
import OptionParser
5 from zeroinstall
.injector
import model
, download
, autopolicy
, run
7 parser
= OptionParser(usage
="usage: %prog [options] interface [args]\n"
8 " %prog --list [search-term]")
9 parser
.add_option("-g", "--gui", help="show graphical policy editor", action
='store_true')
10 parser
.add_option("-l", "--list", help="list all known interfaces", action
='store_true')
11 parser
.add_option("-r", "--refresh", help="refresh all used interfaces", action
='store_true')
12 parser
.add_option("-v", "--version", help="display version information", action
='store_true')
13 parser
.disable_interspersed_args()
15 (options
, args
) = parser
.parse_args()
21 match
= args
[0].lower()
25 from zeroinstall
.injector
import reader
26 for i
in reader
.list_all_interfaces():
27 if match
and match
not in i
.lower(): continue
33 print "0launch (zero-install) " + zeroinstall
.version
34 print "Copyright (C) 2005 Thomas Leonard"
35 print "This program comes with ABSOLUTELY NO WARRANTY,"
36 print "to the extent permitted by law."
37 print "You may redistribute copies of this program"
38 print "under the terms of the GNU General Public License."
39 print "For more information about these matters, see the file named COPYING."
47 interface_uri
= 'http://0install.net/2005/interfaces/injector-gui'
50 interface_uri
= args
[0]
53 if not interface_uri
.startswith('http:'):
54 interface_uri
= os
.path
.realpath(interface_uri
) # For testing
56 # Singleton instance used everywhere...
57 policy
= autopolicy
.AutoPolicy(interface_uri
)
61 for x
in policy
.walk_interfaces():
62 policy
.begin_iface_download(x
, False)
66 policy
.wait_for_downloads()
67 except model
.SafeException
, ex
:
68 print >>sys
.stderr
, ex
72 policy
.execute(prog_args
)
73 except model
.SafeException
, ex
:
74 if policy
.network_use
!= model
.network_full
:
75 print >>sys
.stderr
, "Error. Retrying with network use = full"
76 policy
.network_use
= model
.network_full
79 policy
.execute(prog_args
)
80 except model
.SafeException
, ex
:
81 print >>sys
.stderr
, ex
83 print >>sys
.stderr
, ex