diff options
author | mkaay <mkaay@mkaay.de> | 2009-11-12 22:54:29 +0100 |
---|---|---|
committer | mkaay <mkaay@mkaay.de> | 2009-11-12 22:54:29 +0100 |
commit | b7dff98c2e76b28422d40076273753b4216a819a (patch) | |
tree | e2a24cdde775792624f30b7c24624c7c57068209 | |
parent | shareonline.biz premium (diff) | |
download | pyload-b7dff98c2e76b28422d40076273753b4216a819a.tar.xz |
better exception handling for sockets
-rw-r--r-- | module/remote/SocketServer.py | 9 | ||||
-rw-r--r-- | module/web/WebServer.py | 6 | ||||
-rwxr-xr-x | pyLoadCore.py | 6 |
3 files changed, 15 insertions, 6 deletions
diff --git a/module/remote/SocketServer.py b/module/remote/SocketServer.py index d2fa912dd..2edd1d9f3 100644 --- a/module/remote/SocketServer.py +++ b/module/remote/SocketServer.py @@ -46,9 +46,12 @@ class MainServerSocket(asyncore.dispatcher): asyncore.dispatcher.__init__(self) pycore.logger.info('initing Remote-Server') self.pycore = pycore - self.create_socket(socket.AF_INET, socket.SOCK_STREAM) - self.bind(('', port)) - self.listen(5) + try: + self.create_socket(socket.AF_INET, socket.SOCK_STREAM) + self.bind(('', port)) + self.listen(5) + except: + raise Exception("Can't create socket") def handle_accept(self): newSocket, address = self.accept() self.pycore.logger.info("Connected from " + str(address)) diff --git a/module/web/WebServer.py b/module/web/WebServer.py index 5497439da..8cef0de2f 100644 --- a/module/web/WebServer.py +++ b/module/web/WebServer.py @@ -283,4 +283,8 @@ class WebServer(threading.Thread): def run(self): self.core.logger.info("Starting Webinterface on %s port %s" % (self.core.config['webinterface']['listenaddr'],self.core.config['webinterface']['port'])) - run(host=self.core.config['webinterface']['listenaddr'], port=int(self.core.config['webinterface']['port']), quiet=True) + try: + run(host=self.core.config['webinterface']['listenaddr'], port=int(self.core.config['webinterface']['port']), quiet=True) + except: + self.core.logger.error("Failed starting webserver, no webinterface available: Can't create socket") + exit() diff --git a/pyLoadCore.py b/pyLoadCore.py index 9c9d468b4..a88589926 100755 --- a/pyLoadCore.py +++ b/pyLoadCore.py @@ -288,7 +288,8 @@ class Core(object): self.server = ServerThread(self) self.server.start() except Exception, e: - self.logger.error("failed starting socket server, CLi and Gui will not be available: %s" % str(e)) + self.logger.error("Failed starting socket server, CLI and GUI will not be available: %s" % str(e)) + exit() def init_webserver(self): @@ -299,7 +300,8 @@ class Core(object): self.webserver = WebServer(self) self.webserver.start() except Exception, e: - self.looger.error("failed starting webserver, no webinterface available: %s" % str(e)) + self.logger.error("Failed starting webserver, no webinterface available: %s" % str(e)) + exit() def kill(self): self.do_kill = True |