4 # This is for pycentral on Debian-type systems. 0launch-gui is a symlink to the
5 # copy in the pycentral source directory. Python does a realpath() on this
6 # before adding the containing directory to sys.path, which means we don't see
7 # the .pyc files. If run as root, this also causes .pyc files to be created in
8 # the source directory, leaving a mess when the package is removed.
9 sys
.path
.insert(0, os
.path
.dirname(__file__
))
11 from optparse
import OptionParser
12 import pygtk
; pygtk
.require('2.0')
14 __builtins__
._ = lambda x
: x
16 parser
= OptionParser(usage
="usage: %prog [options] interface")
17 parser
.add_option("", "--before", help="choose a version before this", metavar
='VERSION')
18 parser
.add_option("-c", "--cache", help="show the cache", action
='store_true')
19 parser
.add_option("-d", "--download-only", help="fetch but don't run", action
='store_true')
20 parser
.add_option("", "--not-before", help="minimum version to choose", metavar
='VERSION')
21 parser
.add_option("-r", "--refresh", help="check for updates of all interfaces", action
='store_true')
22 parser
.add_option("-s", "--source", help="select source code", action
='store_true')
23 parser
.add_option("-v", "--verbose", help="more verbose output", action
='count')
24 parser
.add_option("-V", "--version", help="display version information", action
='store_true')
26 parser
.disable_interspersed_args()
28 (options
, args
) = parser
.parse_args()
34 logger
= logging
.getLogger()
35 if options
.verbose
== 1:
36 logger
.setLevel(logging
.INFO
)
38 logger
.setLevel(logging
.DEBUG
)
41 # Must fork before importing gtk, or ATK dies
43 # We exit, so our parent can call waitpid and unblock.
45 # The grandchild continues...
50 print "0launch-gui (zero-install) " + gui
.version
51 print "Copyright (C) 2007 Thomas Leonard"
52 print "This program comes with ABSOLUTELY NO WARRANTY,"
53 print "to the extent permitted by law."
54 print "You may redistribute copies of this program"
55 print "under the terms of the GNU General Public License."
56 print "For more information about these matters, see the file named COPYING."
60 if gtk
.gdk
.get_display() is None:
61 print >>sys
.stderr
, "Failed to connect to display. Aborting."
64 if not hasattr(gtk
, 'combo_box_new_text'):
69 cache_explorer
= cache
.CacheExplorer()
71 cache_explorer
.window
.set_cursor(gtk
.gdk
.Cursor(gtk
.gdk
.WATCH
))
73 cache_explorer
.populate_model()
74 cache_explorer
.window
.set_cursor(None)
82 interface_uri
= args
[0]
88 from zeroinstall
.injector
import model
, autopolicy
, namespaces
89 from zeroinstall
.support
import tasks
92 if options
.before
or options
.not_before
:
93 restrictions
.append(model
.Restriction(model
.parse_version(options
.before
),
94 model
.parse_version(options
.not_before
)))
96 policy
= gui
.GUIPolicy(interface_uri
,
97 download_only
= bool(options
.download_only
),
98 refresh
= bool(options
.refresh
),
100 restrictions
= restrictions
)
101 main
= tasks
.Task(policy
.main(), "main")
102 policy
.handler
.wait_for_blocker(main
.finished
)