#!/usr/bin/python # Copyright (C) 2006 by Szilveszter Farkas (Phanatic) # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA import os import sys import re try: version_info = sys.version_info except AttributeError: version_info = 1, 5 # 1.5 or older REINVOKE = "__BZR_REINVOKE" NEED_VERS = (2, 4) KNOWN_PYTHONS = ('python2.4',) if version_info < NEED_VERS: if not os.environ.has_key(REINVOKE): # mutating os.environ doesn't work in old Pythons os.putenv(REINVOKE, "1") for python in KNOWN_PYTHONS: try: os.execvp(python, [python] + sys.argv) except OSError: pass print >>sys.stderr, ('bzr: error: cannot find a suitable python interpreter' ' (need %d.%d or later)' ) % NEED_VERS sys.exit(1) try: import pygtk pygtk.require("2.0") except: pass try: import gtk import gtk.glade except: print >>sys.stderr, ('You need to install python-glade2 and/or pygtk2 (gtk2)' ' or set your PYTHONPATH correctly.\n' 'try: export PYTHONPATH=/usr/local/lib/python2.4/site-packages/' ) sys.exit(1) # gettext support import gettext gettext.install('olive-gtk') # make sure we could import bzrlib try: import bzrlib except ImportError: # try to find bzr if it exist in $PATH p = os.popen('bzr version') s = p.read() r = p.close() if r not in (None, 0): print >>sys.stderr, "bzr not found" sys.exit(1) else: bzrlib_match = re.compile(r"bzrlib: (.*)[/\\]bzrlib").search(s) if bzrlib_match: sys.path.append(bzrlib_match.group(1)) else: print >>sys.stderr, "Can't find bzrlib location" sys.exit(1) from bzrlib.plugin import load_plugins load_plugins() import bzrlib.ui import bzrlib.plugins.gtk.ui as ui bzrlib.ui.ui_factory = ui.GtkUIFactory() from olive import OliveGtk app = OliveGtk() gtk.main()