Commit 30853e2d authored by Taddeus Kroes's avatar Taddeus Kroes

Cleanup

parent 75382d1a
...@@ -5,9 +5,10 @@ import json ...@@ -5,9 +5,10 @@ import json
import re import re
import psutil import psutil
import platform import platform
import sys
from subprocess import check_output from subprocess import check_output
from threading import Thread from threading import Thread
from wspy import websocket, Frame, OPCODE_TEXT, WebkitDeflateFrame from wspy import websocket, Frame, OPCODE_TEXT
def osname(): def osname():
...@@ -20,7 +21,6 @@ def osname(): ...@@ -20,7 +21,6 @@ def osname():
return name return name
#return '%s %s' % (platform.system(), platform.release())
return platform.platform() return platform.platform()
...@@ -72,12 +72,11 @@ if __name__ == '__main__': ...@@ -72,12 +72,11 @@ if __name__ == '__main__':
try: try:
client.send(status) client.send(status)
except socket.error: except socket.error:
print 'Client disconnected' print >>sys.stderr, 'Client disconnected'
clients.remove(client) clients.remove(client)
time.sleep(1) time.sleep(1)
#server = websocket(extensions=[WebkitDeflateFrame()])
server = websocket() server = websocket()
server.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) server.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
server.bind(('', 8100)) server.bind(('', 8100))
...@@ -90,12 +89,10 @@ if __name__ == '__main__': ...@@ -90,12 +89,10 @@ if __name__ == '__main__':
while True: while True:
try: try:
sock, address = server.accept() sock, address = server.accept()
except KeyboardInterrupt: except socket.error:
raise
except:
continue continue
print 'Client connected at %s:%d' % address print >>sys.stderr, 'Client connected at %s:%d' % address
clients.append(sock) clients.append(sock)
if not t.is_alive(): if not t.is_alive():
...@@ -103,5 +100,6 @@ if __name__ == '__main__': ...@@ -103,5 +100,6 @@ if __name__ == '__main__':
t.daemon = True t.daemon = True
t.start() t.start()
except KeyboardInterrupt: except KeyboardInterrupt:
print 'Stopping server' print >>sys.stderr, 'Stopping server'
finally:
server.close() server.close()
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment