summaryrefslogtreecommitdiffstats
path: root/module/web
diff options
context:
space:
mode:
authorGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2012-09-10 13:36:09 +0200
committerGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2012-09-10 13:36:09 +0200
commitcd99410a04685bbffed04091a7ad03e017140277 (patch)
tree5de430aad1d8c411fc665c38b994a59d52450c92 /module/web
parentchanged config + progress api (diff)
downloadpyload-cd99410a04685bbffed04091a7ad03e017140277.tar.xz
cosmetic fixed, changed default server to threaded
Diffstat (limited to 'module/web')
-rw-r--r--module/web/ServerThread.py26
-rw-r--r--module/web/utils.py12
2 files changed, 14 insertions, 24 deletions
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