summaryrefslogtreecommitdiffstats
path: root/module
diff options
context:
space:
mode:
authorGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2011-02-14 15:17:07 +0100
committerGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2011-02-14 15:17:07 +0100
commit1ecd9254b361d4e026e7a25f1b47382d1015e63c (patch)
tree183e5215126435b5b9bc986d86e616bafccb1645 /module
parentsome parts of cli working again (diff)
downloadpyload-1ecd9254b361d4e026e7a25f1b47382d1015e63c.tar.xz
default thrift backend
Diffstat (limited to 'module')
-rw-r--r--module/config/default.conf1
-rw-r--r--module/remote/RemoteManager.py18
-rw-r--r--module/remote/ThriftBackend.py4
-rw-r--r--module/remote/XMLRPCBackend.py4
-rw-r--r--module/remote/thriftbackend/ThriftClient.py2
-rw-r--r--module/web/ServerThread.py7
-rw-r--r--module/web/webinterface.py5
7 files changed, 26 insertions, 15 deletions
diff --git a/module/config/default.conf b/module/config/default.conf
index ab9afaca0..5c90888e9 100644
--- a/module/config/default.conf
+++ b/module/config/default.conf
@@ -3,6 +3,7 @@ version: 1
remote - "Remote":
int port : "Port" = 7227
ip listenaddr : "Adress" = 0.0.0.0
+ bool xmlrpc : "Activate old XMLRPC Backend" = False
bool nolocalauth : "No authentication on local connections" = True
ssl - "SSL":
bool activated : "Activated"= False
diff --git a/module/remote/RemoteManager.py b/module/remote/RemoteManager.py
index e0e5cdccf..e57424eed 100644
--- a/module/remote/RemoteManager.py
+++ b/module/remote/RemoteManager.py
@@ -26,7 +26,6 @@ class BackendBase(Thread):
self.core = manager.core
def run(self):
- self.core.log.info(_("Starting %s") % self.__class__.__name__)
try:
self.serve()
except:
@@ -34,7 +33,7 @@ class BackendBase(Thread):
if self.core.debug:
print_exc()
- def setup(self):
+ def setup(self, host, port):
pass
def checkDeps(self):
@@ -47,21 +46,28 @@ class BackendBase(Thread):
return self.manager.checkAuth(user, password, remoteip)
class RemoteManager():
- available = ("XMLRPCBackend", "ThriftBackend")
- #available = ("ThriftBackend", )
+ available = ["ThriftBackend"]
def __init__(self, core):
self.core = core
self.backends = []
def startBackends(self):
+
+ host = self.core.config["remote"]["listenaddr"]
+ port = self.core.config["remote"]["port"]
+
+ if self.core.config["remote"]["xmlrpc"]:
+ self.available.append("XMLRPCBackend")
+
for b in self.available:
klass = getattr(__import__("module.remote.%s" % b, globals(), locals(), [b] , -1), b)
backend = klass(self)
if not backend.checkDeps():
continue
try:
- backend.setup()
+ backend.setup(host, port)
+ self.core.log.info(_("Starting %(name)s: %(addr)s:%(port)s") % {"name": b, "addr": host, "port": port})
except:
self.core.log.error(_("Failed loading backend %s") % b)
if self.core.debug:
@@ -70,6 +76,8 @@ class RemoteManager():
backend.start()
self.backends.append(backend)
+ port += 1
+
def checkAuth(self, user, password, remoteip=None):
if self.core.config["remote"]["nolocalauth"] and remoteip == "127.0.0.1":
return True
diff --git a/module/remote/ThriftBackend.py b/module/remote/ThriftBackend.py
index 208fb8c72..ac7d1f857 100644
--- a/module/remote/ThriftBackend.py
+++ b/module/remote/ThriftBackend.py
@@ -28,7 +28,7 @@ from thriftbackend.Transport import TransportFactory
from thrift.server import TServer
class ThriftBackend(BackendBase):
- def setup(self):
+ def setup(self, host, port):
handler = Handler(self)
processor = Processor(handler)
@@ -41,7 +41,7 @@ class ThriftBackend(BackendBase):
key = self.core.config['ssl']['key']
cert = self.core.config['ssl']['cert']
- transport = ServerSocket(int(self.core.config['remote']['port'])+1, self.core.config["remote"]["listenaddr"], key, cert)
+ transport = ServerSocket(port, host, key, cert)
tfactory = TransportFactory()
pfactory = ProtocolFactory()
diff --git a/module/remote/XMLRPCBackend.py b/module/remote/XMLRPCBackend.py
index 08803df23..50b37f17b 100644
--- a/module/remote/XMLRPCBackend.py
+++ b/module/remote/XMLRPCBackend.py
@@ -21,8 +21,8 @@ import module.lib.SecureXMLRPCServer as Server
from module.remote.RemoteManager import BackendBase
class XMLRPCBackend(BackendBase):
- def setup(self):
- server_addr = (self.core.config['remote']['listenaddr'], int(self.core.config['remote']['port']))
+ def setup(self, host, port):
+ server_addr = (host, port)
if self.core.config['ssl']['activated']:
if exists(self.core.config['ssl']['cert']) and exists(self.core.config['ssl']['key']):
self.core.log.info(_("Using SSL XMLRPCBackend"))
diff --git a/module/remote/thriftbackend/ThriftClient.py b/module/remote/thriftbackend/ThriftClient.py
index c6a48df2b..c5beec96e 100644
--- a/module/remote/thriftbackend/ThriftClient.py
+++ b/module/remote/thriftbackend/ThriftClient.py
@@ -30,7 +30,7 @@ class NoSSL(Exception):
pass
class ThriftClient:
- def __init__(self, host="localhost", port=7228, user="", password=""):
+ def __init__(self, host="localhost", port=7227, user="", password=""):
self.createConnection(host, port)
try:
diff --git a/module/web/ServerThread.py b/module/web/ServerThread.py
index 297eb2f8f..9af888c6e 100644
--- a/module/web/ServerThread.py
+++ b/module/web/ServerThread.py
@@ -1,6 +1,7 @@
#!/usr/bin/env python
from __future__ import with_statement
-from os.path import exists
+from os import makedirs
+from os.path import exists, join
import threading
import logging
@@ -27,6 +28,10 @@ class WebServer(threading.Thread):
import webinterface
global webinterface
+ cache = join("tmp", "jinja_cache")
+ if not exists(cache):
+ makedirs(cache)
+
if self.https:
if not exists(self.cert) or not exists(self.key):
log.warning(_("SSL certificates not found."))
diff --git a/module/web/webinterface.py b/module/web/webinterface.py
index dd5920486..ef5046f44 100644
--- a/module/web/webinterface.py
+++ b/module/web/webinterface.py
@@ -85,9 +85,6 @@ LOG_ROOT = config.get('log', 'log_folder')
DEBUG = config.get("general","debug_mode")
bottle.debug(DEBUG)
-if not exists(join("tmp", "jinja_cache")):
- makedirs(join("tmp", "jinja_cache"))
-
bcc = FileSystemBytecodeCache(join("tmp","jinja_cache"))
loader = PrefixLoader({
"default": FileSystemLoader(join(PROJECT_DIR, "templates", "jinja", "default"))
@@ -112,7 +109,7 @@ from beaker.middleware import SessionMiddleware
session_opts = {
'session.type': 'file',
- # 'session.cookie_expires': -1,
+ 'session.cookie_expires': False,
'session.data_dir': './tmp',
'session.auto': False
}