Skip to content

Commit

Permalink
change the way to check for pip, no longer mess up the terminal when …
Browse files Browse the repository at this point in the history
…connection error occur
  • Loading branch information
ductin committed Oct 25, 2017
1 parent e173a46 commit 6e83b8b
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions vpnproxy_tui.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
__author__ = "duc_tin"
__copyright__ = "Copyright 2015+, duc_tin"
__license__ = "GPLv2"
__version__ = "1.35"
__version__ = "1.4"
__maintainer__ = "duc_tin"
__email__ = "nguyenbaduc.tin@gmail.com"

Expand Down Expand Up @@ -284,7 +284,7 @@ def get_data(self):
}

else:
proxies = {'no': 'pass',}
proxies = {'no': 'pass', }

i = 0
while i < len(mirrors):
Expand Down Expand Up @@ -1014,7 +1014,7 @@ def communicator(self):
self.ovpn.kill = True

if cmd == 'reconnect':
self.chosen = max(self.chosen,0)
self.chosen = max(self.chosen, 0)
self.connect2vpn()

self.update_GUI()
Expand All @@ -1036,17 +1036,14 @@ def exit(self, loop, data=None):
# ------------------------- Main -----------------------------------
# dead gracefully


vpn_connect = Connection() # initiate network parameter

# check_dependencies:
required = {'openvpn': 0, 'python-pip': 0, 'requests': 0, 'urwid': 0, 'setuptools':0, 'wmctrl': 0}
for module in ['requests', 'urwid', 'setuptools', 'pip']:
required = {'openvpn': 0, 'requests': 0, 'urwid': 0, 'setuptools': 0, 'wmctrl': 0}
for module in ['requests', 'urwid', 'setuptools']:
try:
__import__(module, globals(), locals(), [], -1)
except ImportError:
if 'pip' in module:
module = 'python-' + module
required[module] = 1

if not os.path.exists('/usr/sbin/openvpn'):
Expand All @@ -1057,6 +1054,11 @@ def exit(self, loop, data=None):

need = sorted([p for p in required if required[p]])
if need:
try:
out = check_output(['pip', '--version'])
except Exception:
need.insert(0, 'python-pip')

print ctext('\n**Lack of dependencies**\n', 'rB')
env = dict(os.environ)
if vpn_connect.use_proxy == 'yes':
Expand Down

0 comments on commit 6e83b8b

Please sign in to comment.