From adbc8c2b8c95a3fb44b6225affe6c446ab9e2745 Mon Sep 17 00:00:00 2001 From: Dragon2fly Date: Mon, 14 Nov 2016 00:35:08 +0900 Subject: [PATCH] test running the program through bash script --- run | 3 +++ vpn_indicator.py | 24 +++++++++++++++++++----- vpnproxy_tui.py | 4 +++- 3 files changed, 25 insertions(+), 6 deletions(-) create mode 100644 run diff --git a/run b/run new file mode 100644 index 0000000..ad3eb48 --- /dev/null +++ b/run @@ -0,0 +1,3 @@ +#!/bin/bash +stdbuf -oL python vpn_indicator.py > indicator.log & +sudo python vpnproxy_tui.py \ No newline at end of file diff --git a/vpn_indicator.py b/vpn_indicator.py index b1dce7f..5206779 100755 --- a/vpn_indicator.py +++ b/vpn_indicator.py @@ -4,20 +4,34 @@ from Queue import Empty, Queue from threading import Thread -from subprocess import call +from subprocess import call, Popen, PIPE import select -import signal, os +import signal, os, sys import socket, errno import time +import platform + +if 'buntu' in platform.platform() and \ + not Popen(['pgrep', '-f', 'python vpn_indicator.py'], stdout=PIPE).communicate()[0]: + print 'Launch vpn_indicator' +else: + sys.exit() try: + import gi + gi.require_version('Gtk', '3.0') from gi.repository import Gtk, GLib + + gi.require_version('AppIndicator3', '0.1') from gi.repository import AppIndicator3 as appindicator + + gi.require_version('Notify', '0.7') from gi.repository import Notify as notify except ImportError: - print 'Lack of Gtk related modules!' - print 'VPN indicator will not run!' - print 'You should try "sudo apt-get install gir1.2-appindicator3-0.1"' + print >> sys.stderr, 'Lack of Gtk related modules!' + print >> sys.stderr, 'VPN indicator will not run!' + print >> sys.stderr, 'You should try "sudo apt-get install gir1.2-appindicator3-0.1 python-gobject"' + sys.exit() class InfoServer: diff --git a/vpnproxy_tui.py b/vpnproxy_tui.py index 68074bc..71273ae 100755 --- a/vpnproxy_tui.py +++ b/vpnproxy_tui.py @@ -1022,7 +1022,9 @@ def exit(self, loop, data=None): from ui_elements import * # -------- all dependencies should be available after this line -------- -# raw_input('haha') +# raw_input('for debugging') + +# clear system proxy so that request only go through the one specified screen = Display(vpn_connect) screen.get_data_status = 'call' screen.run()