From 3c984a7c2728144fffd47f8d3e054e7e2d62e9f7 Mon Sep 17 00:00:00 2001 From: Phus Lu Date: Fri, 26 Oct 2012 00:17:07 +0800 Subject: [PATCH] refine goagent-gtk.py --- local/goagent-gtk.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/local/goagent-gtk.py b/local/goagent-gtk.py index 7d611015b..da93d02b1 100755 --- a/local/goagent-gtk.py +++ b/local/goagent-gtk.py @@ -3,7 +3,7 @@ # Contributor: # Phus Lu -__version__ = '1.0' +__version__ = '1.1' import sys import os @@ -13,8 +13,11 @@ import pygtk pygtk.require('2.0') import gtk -import appindicator +try: + import appindicator +except ImportError: + sys.exit(gtk.MessageDialog (None, gtk.DIALOG_MODAL, gtk.MESSAGE_ERROR, gtk.BUTTONS_OK, u'\u8bf7\u5b89\u88c5 python-appindicator').run()) try: import vte except ImportError: @@ -63,7 +66,10 @@ def quit(self, widget, data=None): def main(): - os.chdir(os.path.abspath(os.path.dirname(__file__))) + global __file__ + if os.path.islink(__file__): + __file__ = getattr(os, 'readlink', lambda x:x)(__file__) + os.chdir(os.path.dirname(os.path.abspath(__file__))) os.system('chmod +x proxy.py') v = vte.Terminal () v.connect ("child-exited", lambda term: gtk.main_quit())