Skip to content

Commit

Permalink
add logs folder
Browse files Browse the repository at this point in the history
  • Loading branch information
Dragon2fly committed Nov 15, 2016
1 parent f9c836f commit 9aed7f4
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 6 deletions.
4 changes: 4 additions & 0 deletions logs/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Ignore everything in this directory
*
# Except this file
!.gitignore
21 changes: 18 additions & 3 deletions vpn_indicator.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,13 @@

gi.require_version('Notify', '0.7')
from gi.repository import Notify as notify

satisfied = True
except ImportError:
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()
satisfied = False


class InfoServer:
Expand Down Expand Up @@ -78,12 +80,16 @@ def check_io(self, q_info):
print 'Server: Received dead signal'
self.sock.close()
return 0
else:
elif not self.is_connected:
self.client, addrr = self.sock.accept()
self.readlist.append(self.client)
self.is_connected = True
print 'Server: Connected with %s:%s' % addrr
q_info.put('connected')
else:
# reject all other request
client, addrr = self.sock.accept()
client.close()

else: # client sent something
try:
Expand All @@ -101,6 +107,8 @@ def check_io(self, q_info):
except socket.error as e:
print 'Client die unexpectedly'
self.is_connected = False
except Exception:
sys.exit()

def send(self, msg):
if msg == 'dead':
Expand Down Expand Up @@ -355,7 +363,14 @@ def send_cmd(self, menu_obj, arg):
self.send(arg)

def callback(self):
global t
try:
if not t.isAlive():
self.notifier.update("Error", "Server dead unexpectedly", icon=None)
self.notifier.show()
t = Thread(target=server.check_io, args=(q,))
t.start()

data = self.q_info.get_nowait()
self.reload(data)
except Empty:
Expand All @@ -368,7 +383,7 @@ def callback(self):
return True


if __name__ == '__main__':
if __name__ == '__main__' and satisfied:
another_me = Popen(['pgrep', '-f', 'python vpn_indicator.py'], stdout=PIPE).communicate()[0]
another_me = another_me.strip().split('\n')

Expand Down
2 changes: 1 addition & 1 deletion vpnproxy_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ def vpn_manager(ovpn):
for package in need:
print '\n___Now installing', ctext(package, 'gB')
print
call(['apt-get', 'install', package], env=env)
call(['apt-get', '-y', 'install', package], env=env)

import requests

Expand Down
4 changes: 2 additions & 2 deletions vpnproxy_tui.py
Original file line number Diff line number Diff line change
Expand Up @@ -1001,13 +1001,13 @@ def exit(self, loop, data=None):
ctext("Have you 'sudo apt-get update' recently?", 'B') + "([yes] | no): ") else 'no'

if update_now == 'yes':
call(['apt-get', '-y', 'update'], env=env)
call(['apt-get', 'update'], env=env)

for package in need:
print '\n___Now installing', ctext(package, 'gB')
print
if package in ['openvpn', 'python-pip']:
call(['apt-get', 'install', package], env=env)
call(['apt-get', '-y', 'install', package], env=env)
else:
call(['pip', 'install', package], env=env)
globals()[package] = __import__(package)
Expand Down

0 comments on commit 9aed7f4

Please sign in to comment.