Skip to content
This repository has been archived by the owner on Jan 17, 2021. It is now read-only.

Commit

Permalink
fix python2 run goagent-gtk and change file path
Browse files Browse the repository at this point in the history
  • Loading branch information
xyuanmu committed Apr 3, 2016
1 parent 02271bb commit 2dd8c5b
Show file tree
Hide file tree
Showing 35 changed files with 13 additions and 15 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 压缩包
Expand Down
4 changes: 2 additions & 2 deletions addto-startup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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']):
Expand Down
20 changes: 10 additions & 10 deletions goagent-gtk.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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):
Expand All @@ -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:
Expand Down
3 changes: 0 additions & 3 deletions proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 2dd8c5b

Please sign in to comment.