Python 3: the GUI now works well enough to run programs
[zeroinstall/solver.git] / zeroinstall / 0launch-gui / 0launch-gui
blob0aec0df4de8c6547415d736c3b402143f9a5a33b
1 #!/usr/bin/env python
2 # Copyright (C) 2009, Thomas Leonard
3 # See the README file for details, or visit http://0install.net.
4 import os, sys
5 from os.path import dirname
7 import gettext
8 import locale
9 from logging import warn
10 try:
11 locale.setlocale(locale.LC_ALL, '')
12 except locale.Error:
13 warn('Error setting locale (eg. Invalid locale)')
15 # This is for pycentral on Debian-type systems. 0launch-gui is a symlink to the
16 # copy in the pycentral source directory. Python does a realpath() on this
17 # before adding the containing directory to sys.path, which means we don't see
18 # the .pyc files. If run as root, this also causes .pyc files to be created in
19 # the source directory, leaving a mess when the package is removed.
20 _mydir = dirname(__file__)
21 sys.path.insert(0, _mydir)
23 # Make sure we're using our bundled copy of Zero Install, not the system version
24 # (if different)
25 sys.path.insert(0, dirname(dirname(_mydir)))
27 from zeroinstall import localedir
29 if localedir:
30 # Tell GTK where to find the translations, if they're not in
31 # the default system location.
32 if hasattr(locale, 'bindtextdomain'):
33 locale.bindtextdomain('zero-install', localedir)
35 if sys.version_info[0] < 3:
36 import pygtk; pygtk.require('2.0')
38 import main
40 try:
41 main.run_gui(sys.argv[1:])
42 except KeyboardInterrupt:
43 sys.exit(1)