From 2dd8c5b220d2d7869b636c68de42dffd5bdb27a7 Mon Sep 17 00:00:00 2001 From: xyuanmu Date: Sun, 3 Apr 2016 16:21:27 +0800 Subject: [PATCH] fix python2 run goagent-gtk and change file path --- README.md | 1 + addto-startup.py | 4 ++-- goagent-gtk.py | 20 +++++++++---------- proxy.py | 3 --- pythonlib/{lib => }/pyasn1/__init__.py | 0 pythonlib/{lib => }/pyasn1/codec/__init__.py | 0 .../{lib => }/pyasn1/codec/ber/__init__.py | 0 .../{lib => }/pyasn1/codec/ber/decoder.py | 0 .../{lib => }/pyasn1/codec/ber/encoder.py | 0 pythonlib/{lib => }/pyasn1/codec/ber/eoo.py | 0 .../{lib => }/pyasn1/codec/cer/__init__.py | 0 .../{lib => }/pyasn1/codec/cer/decoder.py | 0 .../{lib => }/pyasn1/codec/cer/encoder.py | 0 .../{lib => }/pyasn1/codec/der/__init__.py | 0 .../{lib => }/pyasn1/codec/der/decoder.py | 0 .../{lib => }/pyasn1/codec/der/encoder.py | 0 pythonlib/{lib => }/pyasn1/compat/__init__.py | 0 pythonlib/{lib => }/pyasn1/compat/octets.py | 0 pythonlib/{lib => }/pyasn1/debug.py | 0 pythonlib/{lib => }/pyasn1/error.py | 0 pythonlib/{lib => }/pyasn1/type/__init__.py | 0 pythonlib/{lib => }/pyasn1/type/base.py | 0 pythonlib/{lib => }/pyasn1/type/char.py | 0 pythonlib/{lib => }/pyasn1/type/constraint.py | 0 pythonlib/{lib => }/pyasn1/type/error.py | 0 pythonlib/{lib => }/pyasn1/type/namedtype.py | 0 pythonlib/{lib => }/pyasn1/type/namedval.py | 0 pythonlib/{lib => }/pyasn1/type/tag.py | 0 pythonlib/{lib => }/pyasn1/type/tagmap.py | 0 pythonlib/{lib => }/pyasn1/type/univ.py | 0 pythonlib/{lib => }/pyasn1/type/useful.py | 0 pythonlib/{lib => }/simple_http_client.py | 0 pythonlib/{lib => }/simple_http_server.py | 0 pythonlib/{lib => }/socks.py | 0 pythonlib/{lib => }/xlog.py | 0 35 files changed, 13 insertions(+), 15 deletions(-) rename pythonlib/{lib => }/pyasn1/__init__.py (100%) rename pythonlib/{lib => }/pyasn1/codec/__init__.py (100%) rename pythonlib/{lib => }/pyasn1/codec/ber/__init__.py (100%) rename pythonlib/{lib => }/pyasn1/codec/ber/decoder.py (100%) rename pythonlib/{lib => }/pyasn1/codec/ber/encoder.py (100%) rename pythonlib/{lib => }/pyasn1/codec/ber/eoo.py (100%) rename pythonlib/{lib => }/pyasn1/codec/cer/__init__.py (100%) rename pythonlib/{lib => }/pyasn1/codec/cer/decoder.py (100%) rename pythonlib/{lib => }/pyasn1/codec/cer/encoder.py (100%) rename pythonlib/{lib => }/pyasn1/codec/der/__init__.py (100%) rename pythonlib/{lib => }/pyasn1/codec/der/decoder.py (100%) rename pythonlib/{lib => }/pyasn1/codec/der/encoder.py (100%) rename pythonlib/{lib => }/pyasn1/compat/__init__.py (100%) rename pythonlib/{lib => }/pyasn1/compat/octets.py (100%) rename pythonlib/{lib => }/pyasn1/debug.py (100%) rename pythonlib/{lib => }/pyasn1/error.py (100%) rename pythonlib/{lib => }/pyasn1/type/__init__.py (100%) rename pythonlib/{lib => }/pyasn1/type/base.py (100%) rename pythonlib/{lib => }/pyasn1/type/char.py (100%) rename pythonlib/{lib => }/pyasn1/type/constraint.py (100%) rename pythonlib/{lib => }/pyasn1/type/error.py (100%) rename pythonlib/{lib => }/pyasn1/type/namedtype.py (100%) rename pythonlib/{lib => }/pyasn1/type/namedval.py (100%) rename pythonlib/{lib => }/pyasn1/type/tag.py (100%) rename pythonlib/{lib => }/pyasn1/type/tagmap.py (100%) rename pythonlib/{lib => }/pyasn1/type/univ.py (100%) rename pythonlib/{lib => }/pyasn1/type/useful.py (100%) rename pythonlib/{lib => }/simple_http_client.py (100%) rename pythonlib/{lib => }/simple_http_server.py (100%) rename pythonlib/{lib => }/socks.py (100%) rename pythonlib/{lib => }/xlog.py (100%) diff --git a/README.md b/README.md index a287c71..f0638eb 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,7 @@ * 之后设置浏览器代理为:127.0.0.1,端口:8087,支持pac自动代理的设置为 `http://127.0.0.1:8086/proxy.pac` * 接下来即可使用浏览器翻墙,但公共appid不允许观看视频和下载 * 在 XX-Mini 目录,输入 `python addto-startup.py` 可以添加系统启动项 +* 在 XX-Mini 目录,输入 `python goagent-gtk.py` 可以显示系统托盘 ### egg 文件打包方法: * 将pythonlib文件夹里的文件打包成 pythonlib.zip 压缩包 diff --git a/addto-startup.py b/addto-startup.py index 2866b9c..cc22436 100644 --- a/addto-startup.py +++ b/addto-startup.py @@ -28,8 +28,8 @@ def addto_startup_linux(): Hidden=false NoDisplay=false X-GNOME-Autostart-enabled=true -Name=GoAgent GTK -Comment=GoAgent GTK Launcher +Name=XX-Mini GTK +Comment=XX-Mini GTK Launcher ''' % (python2, dirname , scriptname , dirname) #sometimes maybe /etc/xdg/autostart , ~/.kde/Autostart/ , ~/.config/openbox/autostart for dirname in map(os.path.expanduser, ['~/.config/autostart']): diff --git a/goagent-gtk.py b/goagent-gtk.py index c2f86b0..a429407 100644 --- a/goagent-gtk.py +++ b/goagent-gtk.py @@ -57,10 +57,10 @@ import gtk # gtk.gdk.threads_init() except Exception: - sys.exit(os.system(u'gdialog --title "GoAgent GTK" --msgbox "\u8bf7\u5b89\u88c5 python-gtk2" 15 60'.encode(sys.getfilesystemencoding() or sys.getdefaultencoding(), 'replace'))) + sys.exit(os.system(u'gdialog --title "XX-Mini GTK" --msgbox "\u8bf7\u5b89\u88c5 python-gtk2" 15 60'.encode(sys.getfilesystemencoding() or sys.getdefaultencoding(), 'replace'))) try: import pynotify - pynotify.init('GoAgent Notify') + pynotify.init('XX-Mini Notify') except ImportError: pynotify = None try: @@ -88,10 +88,10 @@ def drop_desktop(): #!/usr/bin/env xdg-open [Desktop Entry] Type=Application -Name=GoAgent GTK -Comment=GoAgent GTK Launcher +Name=XX-Mini GTK +Comment=XX-Mini GTK Launcher Categories=Network;Proxy; -Exec=/usr/bin/env python3 "%s" +Exec=/usr/bin/env python "%s" Icon=%s/goagent-logo.png Terminal=false StartupNotify=true @@ -119,8 +119,8 @@ def should_visible(): class GoAgentGTK: command = ['/usr/bin/env', 'python3', 'proxy.py'] - message = u'GoAgent已经启动,单击托盘图标可以最小化' - fail_message = u'GoAgent启动失败,请查看控制台窗口的错误信息。' + message = u'XX-Mini已经启动,单击托盘图标可以最小化' + fail_message = u'XX-Mini启动失败,请查看控制台窗口的错误信息。' def __init__(self, window, terminal): self.window = window @@ -154,7 +154,7 @@ def __init__(self, window, terminal): self.window.set_icon_from_file(logo_filename) if appindicator: - self.trayicon = appindicator.Indicator('GoAgent', 'indicator-messages', appindicator.CATEGORY_APPLICATION_STATUS) + self.trayicon = appindicator.Indicator('XX-Mini', 'indicator-messages', appindicator.CATEGORY_APPLICATION_STATUS) self.trayicon.set_status(appindicator.STATUS_ACTIVE) self.trayicon.set_attention_icon('indicator-messages-new') self.trayicon.set_icon(logo_filename) @@ -164,7 +164,7 @@ def __init__(self, window, terminal): self.trayicon.set_from_file(logo_filename) self.trayicon.connect('popup-menu', lambda i, b, t: self.make_menu().popup(None, None, gtk.status_icon_position_menu, b, t, self.trayicon)) self.trayicon.connect('activate', self.show_hide_toggle) - self.trayicon.set_tooltip('GoAgent') + self.trayicon.set_tooltip('XX-Mini') self.trayicon.set_visible(True) def make_menu(self): @@ -184,7 +184,7 @@ def make_menu(self): def show_notify(self, message=None, timeout=None): if pynotify and message: - notification = pynotify.Notification('GoAgent Notify', message) + notification = pynotify.Notification('XX-Mini Notify', message) notification.set_hint('x', 200) notification.set_hint('y', 400) if timeout: diff --git a/proxy.py b/proxy.py index c366103..ebc7c2b 100644 --- a/proxy.py +++ b/proxy.py @@ -50,16 +50,13 @@ # add python lib path sys.path.append(os.path.join(work_path, 'pythonlib')) -sys.path.append(os.path.join(work_path, 'pythonlib', 'lib')) if sys.platform.startswith("linux"): sys.path.append(os.path.join(work_path, 'pythonlib.egg')) - sys.path.append(os.path.join(work_path, 'pythonlib.egg', 'lib')) # reduce resource request for threading, for OpenWrt import threading threading.stack_size(128*1024) elif sys.platform == "darwin": sys.path.append(os.path.join(work_path, 'pythonlib.egg')) - sys.path.append(os.path.join(work_path, 'pythonlib.egg', 'lib')) from local.config import config diff --git a/pythonlib/lib/pyasn1/__init__.py b/pythonlib/pyasn1/__init__.py similarity index 100% rename from pythonlib/lib/pyasn1/__init__.py rename to pythonlib/pyasn1/__init__.py diff --git a/pythonlib/lib/pyasn1/codec/__init__.py b/pythonlib/pyasn1/codec/__init__.py similarity index 100% rename from pythonlib/lib/pyasn1/codec/__init__.py rename to pythonlib/pyasn1/codec/__init__.py diff --git a/pythonlib/lib/pyasn1/codec/ber/__init__.py b/pythonlib/pyasn1/codec/ber/__init__.py similarity index 100% rename from pythonlib/lib/pyasn1/codec/ber/__init__.py rename to pythonlib/pyasn1/codec/ber/__init__.py diff --git a/pythonlib/lib/pyasn1/codec/ber/decoder.py b/pythonlib/pyasn1/codec/ber/decoder.py similarity index 100% rename from pythonlib/lib/pyasn1/codec/ber/decoder.py rename to pythonlib/pyasn1/codec/ber/decoder.py diff --git a/pythonlib/lib/pyasn1/codec/ber/encoder.py b/pythonlib/pyasn1/codec/ber/encoder.py similarity index 100% rename from pythonlib/lib/pyasn1/codec/ber/encoder.py rename to pythonlib/pyasn1/codec/ber/encoder.py diff --git a/pythonlib/lib/pyasn1/codec/ber/eoo.py b/pythonlib/pyasn1/codec/ber/eoo.py similarity index 100% rename from pythonlib/lib/pyasn1/codec/ber/eoo.py rename to pythonlib/pyasn1/codec/ber/eoo.py diff --git a/pythonlib/lib/pyasn1/codec/cer/__init__.py b/pythonlib/pyasn1/codec/cer/__init__.py similarity index 100% rename from pythonlib/lib/pyasn1/codec/cer/__init__.py rename to pythonlib/pyasn1/codec/cer/__init__.py diff --git a/pythonlib/lib/pyasn1/codec/cer/decoder.py b/pythonlib/pyasn1/codec/cer/decoder.py similarity index 100% rename from pythonlib/lib/pyasn1/codec/cer/decoder.py rename to pythonlib/pyasn1/codec/cer/decoder.py diff --git a/pythonlib/lib/pyasn1/codec/cer/encoder.py b/pythonlib/pyasn1/codec/cer/encoder.py similarity index 100% rename from pythonlib/lib/pyasn1/codec/cer/encoder.py rename to pythonlib/pyasn1/codec/cer/encoder.py diff --git a/pythonlib/lib/pyasn1/codec/der/__init__.py b/pythonlib/pyasn1/codec/der/__init__.py similarity index 100% rename from pythonlib/lib/pyasn1/codec/der/__init__.py rename to pythonlib/pyasn1/codec/der/__init__.py diff --git a/pythonlib/lib/pyasn1/codec/der/decoder.py b/pythonlib/pyasn1/codec/der/decoder.py similarity index 100% rename from pythonlib/lib/pyasn1/codec/der/decoder.py rename to pythonlib/pyasn1/codec/der/decoder.py diff --git a/pythonlib/lib/pyasn1/codec/der/encoder.py b/pythonlib/pyasn1/codec/der/encoder.py similarity index 100% rename from pythonlib/lib/pyasn1/codec/der/encoder.py rename to pythonlib/pyasn1/codec/der/encoder.py diff --git a/pythonlib/lib/pyasn1/compat/__init__.py b/pythonlib/pyasn1/compat/__init__.py similarity index 100% rename from pythonlib/lib/pyasn1/compat/__init__.py rename to pythonlib/pyasn1/compat/__init__.py diff --git a/pythonlib/lib/pyasn1/compat/octets.py b/pythonlib/pyasn1/compat/octets.py similarity index 100% rename from pythonlib/lib/pyasn1/compat/octets.py rename to pythonlib/pyasn1/compat/octets.py diff --git a/pythonlib/lib/pyasn1/debug.py b/pythonlib/pyasn1/debug.py similarity index 100% rename from pythonlib/lib/pyasn1/debug.py rename to pythonlib/pyasn1/debug.py diff --git a/pythonlib/lib/pyasn1/error.py b/pythonlib/pyasn1/error.py similarity index 100% rename from pythonlib/lib/pyasn1/error.py rename to pythonlib/pyasn1/error.py diff --git a/pythonlib/lib/pyasn1/type/__init__.py b/pythonlib/pyasn1/type/__init__.py similarity index 100% rename from pythonlib/lib/pyasn1/type/__init__.py rename to pythonlib/pyasn1/type/__init__.py diff --git a/pythonlib/lib/pyasn1/type/base.py b/pythonlib/pyasn1/type/base.py similarity index 100% rename from pythonlib/lib/pyasn1/type/base.py rename to pythonlib/pyasn1/type/base.py diff --git a/pythonlib/lib/pyasn1/type/char.py b/pythonlib/pyasn1/type/char.py similarity index 100% rename from pythonlib/lib/pyasn1/type/char.py rename to pythonlib/pyasn1/type/char.py diff --git a/pythonlib/lib/pyasn1/type/constraint.py b/pythonlib/pyasn1/type/constraint.py similarity index 100% rename from pythonlib/lib/pyasn1/type/constraint.py rename to pythonlib/pyasn1/type/constraint.py diff --git a/pythonlib/lib/pyasn1/type/error.py b/pythonlib/pyasn1/type/error.py similarity index 100% rename from pythonlib/lib/pyasn1/type/error.py rename to pythonlib/pyasn1/type/error.py diff --git a/pythonlib/lib/pyasn1/type/namedtype.py b/pythonlib/pyasn1/type/namedtype.py similarity index 100% rename from pythonlib/lib/pyasn1/type/namedtype.py rename to pythonlib/pyasn1/type/namedtype.py diff --git a/pythonlib/lib/pyasn1/type/namedval.py b/pythonlib/pyasn1/type/namedval.py similarity index 100% rename from pythonlib/lib/pyasn1/type/namedval.py rename to pythonlib/pyasn1/type/namedval.py diff --git a/pythonlib/lib/pyasn1/type/tag.py b/pythonlib/pyasn1/type/tag.py similarity index 100% rename from pythonlib/lib/pyasn1/type/tag.py rename to pythonlib/pyasn1/type/tag.py diff --git a/pythonlib/lib/pyasn1/type/tagmap.py b/pythonlib/pyasn1/type/tagmap.py similarity index 100% rename from pythonlib/lib/pyasn1/type/tagmap.py rename to pythonlib/pyasn1/type/tagmap.py diff --git a/pythonlib/lib/pyasn1/type/univ.py b/pythonlib/pyasn1/type/univ.py similarity index 100% rename from pythonlib/lib/pyasn1/type/univ.py rename to pythonlib/pyasn1/type/univ.py diff --git a/pythonlib/lib/pyasn1/type/useful.py b/pythonlib/pyasn1/type/useful.py similarity index 100% rename from pythonlib/lib/pyasn1/type/useful.py rename to pythonlib/pyasn1/type/useful.py diff --git a/pythonlib/lib/simple_http_client.py b/pythonlib/simple_http_client.py similarity index 100% rename from pythonlib/lib/simple_http_client.py rename to pythonlib/simple_http_client.py diff --git a/pythonlib/lib/simple_http_server.py b/pythonlib/simple_http_server.py similarity index 100% rename from pythonlib/lib/simple_http_server.py rename to pythonlib/simple_http_server.py diff --git a/pythonlib/lib/socks.py b/pythonlib/socks.py similarity index 100% rename from pythonlib/lib/socks.py rename to pythonlib/socks.py diff --git a/pythonlib/lib/xlog.py b/pythonlib/xlog.py similarity index 100% rename from pythonlib/lib/xlog.py rename to pythonlib/xlog.py