Updates for injector 0.17:
[zeroinstall.git] / 0launch-gui
blob5dd755a560222be6480da9ee98342068155df51d
1 #!/usr/bin/env python
2 import os, sys
3 from optparse import OptionParser
4 import gui
6 __builtins__._ = lambda x: x
8 parser = OptionParser(usage="usage: %prog [options] interface [args]")
9 parser.add_option("-d", "--download-only", help="fetch but don't run", action='store_true')
10 parser.add_option("-m", "--main", help="name of the file to execute")
11 parser.add_option("-n", "--no-self-update", help="don't check for updates to the GUI itself", action='store_true')
12 parser.add_option("-r", "--refresh", help="check for updates of all interfaces", action='store_true')
13 parser.add_option("-v", "--verbose", help="more verbose output", action='count')
14 parser.add_option("-V", "--version", help="display version information", action='store_true')
16 parser.disable_interspersed_args()
18 (options, args) = parser.parse_args()
20 if options.verbose:
21 import logging
22 logger = logging.getLogger()
23 if options.verbose == 1:
24 logger.setLevel(logging.INFO)
25 else:
26 logger.setLevel(logging.DEBUG)
28 if options.version:
29 print "0launch-gui (zero-install) " + gui.version
30 print "Copyright (C) 2005 Thomas Leonard"
31 print "This program comes with ABSOLUTELY NO WARRANTY,"
32 print "to the extent permitted by law."
33 print "You may redistribute copies of this program"
34 print "under the terms of the GNU General Public License."
35 print "For more information about these matters, see the file named COPYING."
36 sys.exit(0)
38 if len(args) < 1:
39 parser.print_help()
40 sys.exit(1)
42 interface_uri = args[0]
43 prog_args = args[1:]
45 from zeroinstall.injector import model, autopolicy, namespaces
46 import gtk
48 if not hasattr(gtk, 'combo_box_new_text'):
49 import combo_compat
51 gtk.rc_parse_string('style "scrolled" { '
52 'GtkScrolledWindow::scrollbar-spacing = 0}\n'
53 'class "GtkScrolledWindow" style : gtk "scrolled"\n')
55 if options.no_self_update is not True:
56 gui_policy = autopolicy.AutoPolicy(namespaces.injector_gui_uri)
57 if gui_policy.need_download():
58 # Need to refresh the GUI itself first!
59 prog_args = ['--no-self-update']
60 if options.main:
61 prog_args += ['--main', options.main]
62 options.main = None
63 prog_args += sys.argv[1:]
65 interface_uri = namespaces.injector_gui_uri
66 options.download_only = False
68 policy = gui.GUIPolicy(interface_uri, prog_args,
69 download_only = bool(options.download_only),
70 refresh = bool(options.refresh),
71 main = options.main)
72 policy.main()