From cd99410a04685bbffed04091a7ad03e017140277 Mon Sep 17 00:00:00 2001 From: RaNaN Date: Mon, 10 Sep 2012 13:36:09 +0200 Subject: cosmetic fixed, changed default server to threaded --- module/config/default.py | 2 +- module/remote/socketbackend/create_ttypes.py | 2 +- module/remote/socketbackend/ttypes.py | 2 +- module/web/ServerThread.py | 26 ++++++++------------------ module/web/utils.py | 12 ++++++------ 5 files changed, 17 insertions(+), 27 deletions(-) (limited to 'module') diff --git a/module/config/default.py b/module/config/default.py index 085061653..a9fad675c 100644 --- a/module/config/default.py +++ b/module/config/default.py @@ -67,7 +67,7 @@ def make_config(config): ("template", "str", _("Template"), _("Tooltip"), "default"), ("activated", "bool", _("Activated"), _("Tooltip"), True), ("prefix", "str", _("Path Prefix"), _("Tooltip"), ""), - ("server", "builtin;threaded;fastcgi;lightweight", _("Server"), _("Tooltip"), "builtin"), + ("server", "threaded;fastcgi;fallback;lightweight", _("Server"), _("Tooltip"), "threaded"), ("host", "ip", _("IP"), _("Tooltip"), "0.0.0.0"), ("https", "bool", _("Use HTTPS"), _("Tooltip"), False), ("port", "int", _("Port"), _("Tooltip"), 8001), diff --git a/module/remote/socketbackend/create_ttypes.py b/module/remote/socketbackend/create_ttypes.py index 05662cb50..8fd59f194 100644 --- a/module/remote/socketbackend/create_ttypes.py +++ b/module/remote/socketbackend/create_ttypes.py @@ -74,7 +74,7 @@ class BaseObject(object): f.write("\n") - f.write("class Iface:\n") + f.write("class Iface(object):\n") for name in dir(Iface): if name.startswith("_"): continue diff --git a/module/remote/socketbackend/ttypes.py b/module/remote/socketbackend/ttypes.py index f4697e39e..06f051fc7 100644 --- a/module/remote/socketbackend/ttypes.py +++ b/module/remote/socketbackend/ttypes.py @@ -325,7 +325,7 @@ class UserDoesNotExists(Exception): def __init__(self, user=None): self.user = user -class Iface: +class Iface(object): def addFromCollector(self, name, paused): pass def addLinks(self, pid, links): diff --git a/module/web/ServerThread.py b/module/web/ServerThread.py index 8b59ca01b..bf5ba8373 100644 --- a/module/web/ServerThread.py +++ b/module/web/ServerThread.py @@ -35,13 +35,6 @@ class WebServer(threading.Thread): log.warning(_("SSL certificates not found.")) self.https = False - if self.server in ("lighttpd", "nginx"): - log.warning(_("Sorry, we dropped support for starting %s directly within pyLoad") % self.server) - log.warning(_("You can use the threaded server which offers good performance and ssl,")) - log.warning(_("of course you can still use your existing %s with pyLoads fastcgi server") % self.server) - log.warning(_("sample configs are located in the module/web/servers directory")) - self.server = "builtin" - if self.server == "fastcgi": try: import flup @@ -59,12 +52,10 @@ class WebServer(threading.Thread): log.warning(_("Of course you need to be familiar with linux and know how to compile software")) self.server = "builtin" - if os.name == "nt": - self.core.log.info(_("Server set to threaded, due to known performance problems on windows.")) - self.core.config['webinterface']['server'] = "threaded" + # threaded is the new default server + if self.server == "builtin": self.server = "threaded" - if self.server == "fastcgi": self.start_fcgi() elif self.server == "threaded": @@ -72,9 +63,9 @@ class WebServer(threading.Thread): elif self.server == "lightweight": self.start_lightweight() else: - self.start_builtin() + self.start_fallback() - def start_builtin(self): + def start_fallback(self): if self.https: log.warning(_("This server offers no SSL, please consider using threaded instead")) @@ -93,13 +84,12 @@ class WebServer(threading.Thread): webinterface.run_threaded(host=self.host, port=self.port, cert=self.cert, key=self.key) def start_fcgi(self): - - from flup.server.threadedserver import ThreadedServer - def noop(*args, **kwargs): - pass + from flup.server.threadedserver import ThreadedServer + def noop(*args, **kwargs): + pass - ThreadedServer._installSignalHandlers = noop + ThreadedServer._installSignalHandlers = noop self.core.log.info(_("Starting fastcgi server: %(host)s:%(port)d") % {"host": self.host, "port": self.port}) webinterface.run_fcgi(host=self.host, port=self.port) diff --git a/module/web/utils.py b/module/web/utils.py index d0c782b68..967fc3412 100644 --- a/module/web/utils.py +++ b/module/web/utils.py @@ -51,14 +51,14 @@ def is_mobile(): return True else: return False - mobile_ua = request.headers.get('User-Agent').lower() - if (mobile_ua.find('opera mini') > 0): + mobile_ua = request.headers.get('User-Agent', '').lower() + if mobile_ua.find('opera mini') > 0: return True - if (mobile_ua.find('windows') > 0): + if mobile_ua.find('windows') > 0: return False - if (request.headers.get('Accept').lower().find('application/vnd.wap.xhtml+xml') > 0): + if request.headers.get('Accept', '').lower().find('application/vnd.wap.xhtml+xml') > 0: return True - if (re.search('(up.browser|up.link|mmp|symbian|smartphone|midp|wap|phone|android)', mobile_ua) is not None): + if re.search('(up.browser|up.link|mmp|symbian|smartphone|midp|wap|phone|android)', mobile_ua) is not None: return True mobile_ua = mobile_ua[:4] mobile_agents = ['w3c ','acs-','alav','alca','amoi','audi','avan','benq','bird','blac','blaz','brew','cell','cldc','cmd-', @@ -67,7 +67,7 @@ def is_mobile(): 'phil','play','port','prox','qwap','sage','sams','sany','sch-','sec-','send','seri','sgh-','shar','sie-', 'siem','smal','smar','sony','sph-','symb','t-mo','teli','tim-','tosh','tsm-','upg1','upsi','vk-v','voda', 'wap-','wapa','wapi','wapp','wapr','webc','winw','winw','xda ','xda-'] - if (mobile_ua in mobile_agents): + if mobile_ua in mobile_agents: return True return False -- cgit v1.2.3