diff options
author | Walter Purcaro <vuolter@gmail.com> | 2014-09-08 01:08:03 +0200 |
---|---|---|
committer | Walter Purcaro <vuolter@gmail.com> | 2014-09-14 11:03:20 +0200 |
commit | 91115fd577f20704ef7f2e74c4527ffbb0730a09 (patch) | |
tree | 198fc68f1eb6f42e220d0f1c68499f48ae70543c /pyload/remote | |
parent | Project __init__ with info (diff) | |
download | pyload-91115fd577f20704ef7f2e74c4527ffbb0730a09.tar.xz |
Restructure pyload file tree (1)
Diffstat (limited to 'pyload/remote')
-rw-r--r-- | pyload/remote/ClickAndLoadBackend.py | 2 | ||||
-rw-r--r-- | pyload/remote/RemoteManager.py | 91 | ||||
-rw-r--r-- | pyload/remote/SocketBackend.py | 2 | ||||
-rw-r--r-- | pyload/remote/ThriftBackend.py | 2 |
4 files changed, 3 insertions, 94 deletions
diff --git a/pyload/remote/ClickAndLoadBackend.py b/pyload/remote/ClickAndLoadBackend.py index 82167f6e3..365364a3b 100644 --- a/pyload/remote/ClickAndLoadBackend.py +++ b/pyload/remote/ClickAndLoadBackend.py @@ -27,7 +27,7 @@ try: except: pass -from RemoteManager import BackendBase +from pyload.manager.RemoteManager import BackendBase core = None js = None diff --git a/pyload/remote/RemoteManager.py b/pyload/remote/RemoteManager.py deleted file mode 100644 index e53e317e3..000000000 --- a/pyload/remote/RemoteManager.py +++ /dev/null @@ -1,91 +0,0 @@ -# -*- coding: utf-8 -*- -""" - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, - or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see <http://www.gnu.org/licenses/>. - - @author: mkaay -""" - -from threading import Thread -from traceback import print_exc - -class BackendBase(Thread): - def __init__(self, manager): - Thread.__init__(self) - self.m = manager - self.core = manager.core - self.enabled = True - self.running = False - - def run(self): - self.running = True - try: - self.serve() - except Exception, e: - self.core.log.error(_("Remote backend error: %s") % e) - if self.core.debug: - print_exc() - finally: - self.running = False - - def setup(self, host, port): - pass - - def checkDeps(self): - return True - - def serve(self): - pass - - def shutdown(self): - pass - - def stop(self): - self.enabled = False# set flag and call shutdowm message, so thread can react - self.shutdown() - - -class RemoteManager: - available = [] - - def __init__(self, core): - self.core = core - self.backends = [] - - if self.core.remote: - self.available.append("ThriftBackend") -# else: -# self.available.append("SocketBackend") - - - def startBackends(self): - host = self.core.config["remote"]["listenaddr"] - port = self.core.config["remote"]["port"] - - for b in self.available: - klass = getattr(__import__("pyload.remote.%s" % b, globals(), locals(), [b], -1), b) - backend = klass(self) - if not backend.checkDeps(): - continue - try: - backend.setup(host, port) - self.core.log.info(_("Starting %(name)s: %(addr)s:%(port)s") % {"name": b, "addr": host, "port": port}) - except Exception, e: - self.core.log.error(_("Failed loading backend %(name)s | %(error)s") % {"name": b, "error": str(e)}) - if self.core.debug: - print_exc() - else: - backend.start() - self.backends.append(backend) - - port += 1 diff --git a/pyload/remote/SocketBackend.py b/pyload/remote/SocketBackend.py index 1a157cf1d..c85e59f42 100644 --- a/pyload/remote/SocketBackend.py +++ b/pyload/remote/SocketBackend.py @@ -2,7 +2,7 @@ import SocketServer -from RemoteManager import BackendBase +from pyload.manager.RemoteManager import BackendBase class RequestHandler(SocketServer.BaseRequestHandler): diff --git a/pyload/remote/ThriftBackend.py b/pyload/remote/ThriftBackend.py index 2c65578be..609a3c158 100644 --- a/pyload/remote/ThriftBackend.py +++ b/pyload/remote/ThriftBackend.py @@ -17,7 +17,7 @@ """ from os.path import exists -from pyload.remote.RemoteManager import BackendBase +from pyload.manager.RemoteManager import BackendBase from thriftbackend.Processor import Processor from thriftbackend.Protocol import ProtocolFactory |