summaryrefslogtreecommitdiffstats
path: root/pyload
diff options
context:
space:
mode:
Diffstat (limited to 'pyload')
-rwxr-xr-x[-rw-r--r--]pyload/Core.py0
-rw-r--r--pyload/__init__.py2
-rw-r--r--pyload/config/Setup.py16
-rw-r--r--pyload/manager/Plugin.py6
-rw-r--r--pyload/network/JsEngine.py12
-rw-r--r--pyload/utils/__init__.py10
-rw-r--r--pyload/webui/__init__.py16
-rw-r--r--pyload/webui/app/__init__.py2
-rw-r--r--pyload/webui/app/api.py2
-rw-r--r--pyload/webui/app/json.py2
-rw-r--r--pyload/webui/app/pyloadweb.py (renamed from pyload/webui/app/pyload.py)10
11 files changed, 41 insertions, 37 deletions
diff --git a/pyload/Core.py b/pyload/Core.py
index 9588c9485..9588c9485 100644..100755
--- a/pyload/Core.py
+++ b/pyload/Core.py
diff --git a/pyload/__init__.py b/pyload/__init__.py
index e29c81ad7..c89e55a3c 100644
--- a/pyload/__init__.py
+++ b/pyload/__init__.py
@@ -84,7 +84,7 @@ try:
except IOError:
if os.name == "posix":
- configdir = os.path.join(homedir, ".pyload")
+ configdir = os.path.join(homedir, ".pyload-beta")
else:
configdir = os.path.join(homedir, "pyload")
diff --git a/pyload/config/Setup.py b/pyload/config/Setup.py
index d2bcef9e5..081184652 100644
--- a/pyload/config/Setup.py
+++ b/pyload/config/Setup.py
@@ -326,8 +326,8 @@ class SetupAssistant(object):
print
print _("Listen address, if you use 127.0.0.1 or localhost, the webinterface will only accessible locally.")
- self.config.set("webui", "host", self.ask(_("Address"), "0.0.0.0"))
- self.config.set("webui", "port", self.ask(_("Port"), "8000"))
+ self.config.set("webinterface", "host", self.ask(_("Address"), "0.0.0.0"))
+ self.config.set("webinterface", "port", self.ask(_("Port"), "8000"))
print
print _("pyLoad offers several server backends, now following a short explanation.")
print "- auto:", _("Automatically choose the best webserver for your platform.")
@@ -347,7 +347,7 @@ class SetupAssistant(object):
else:
servers = ["auto", "builtin", "threaded", "fastcgi", "lightweight"]
- self.config.set("webui", "server", self.ask(_("Choose webserver"), "auto", servers))
+ self.config.set("webinterface", "server", self.ask(_("Choose webserver"), "auto", servers))
def conf_ssl(self):
@@ -363,7 +363,7 @@ class SetupAssistant(object):
ssl = self.ask(_("Activate SSL?"), self.yes, bool=True)
self.config.set("remote", "ssl", ssl)
- self.config.set("webui", "ssl", ssl)
+ self.config.set("webinterface", "ssl", ssl)
def set_user(self):
@@ -457,13 +457,13 @@ class SetupAssistant(object):
def print_dep(self, name, value, false="MISSING", true="OK"):
""" Print Status of dependency """
if value and isinstance(value, basestring):
- msg = "%(dep)-12s %(bool)s (%(info)s)"
+ info = ", ".join(value)
else:
- msg = "%(dep)-12s %(bool)s"
+ info = ""
- print msg % {'dep': name + ':',
+ print "%(dep)-12s %(bool)s (%(info)s)" % {'dep': name + ':',
'bool': _(true if value else false).upper(),
- 'info': ", ".join(value)}
+ 'info': info}
def check_module(self, module):
diff --git a/pyload/manager/Plugin.py b/pyload/manager/Plugin.py
index 08fbcc953..72fabb33a 100644
--- a/pyload/manager/Plugin.py
+++ b/pyload/manager/Plugin.py
@@ -37,14 +37,14 @@ class PluginManager(object):
def loadTypes(self):
- rootdir = join(pypath, "pyload", "plugins")
+ rootdir = join(pypath, "pyload", "plugin")
userdir = "userplugins"
types = set().union(*[[d for d in listdir(p) if isdir(join(p, d))]
for p in (rootdir, userdir) if exists(p)])
if not types:
- self.log.critical(_("No plugins found!"))
+ self.core.log.critical(_("No plugins found!"))
self.TYPES = list(set(self.TYPES) | types)
@@ -90,7 +90,7 @@ class PluginManager(object):
return rootplugins
else:
- pfolder = join(pypath, "pyload", "plugins", folder)
+ pfolder = join(pypath, "pyload", "plugin", folder)
for f in listdir(pfolder):
if isfile(join(pfolder, f)) and f.endswith(".py") and not f.startswith("_"):
diff --git a/pyload/network/JsEngine.py b/pyload/network/JsEngine.py
index 2e98fa37d..6ae90f299 100644
--- a/pyload/network/JsEngine.py
+++ b/pyload/network/JsEngine.py
@@ -110,9 +110,9 @@ class AbstractEngine(object):
__name = ""
- def __init__(self):
+ def __init__(self, force=False):
self.setup()
- self.available = self.find()
+ self.available = True if force else self.find()
def setup(self):
@@ -126,7 +126,7 @@ class AbstractEngine(object):
__import__(cls.__name)
except Exception:
try:
- out, err = cls().eval("print(23+19)")
+ out, err = cls(True).eval("23+19")
except Exception:
res = False
else:
@@ -137,7 +137,7 @@ class AbstractEngine(object):
return res
- def _eval(args):
+ def _eval(self, args):
if not self.available:
return None, "JS Engine \"%s\" not found" % self.__name
@@ -151,7 +151,7 @@ class AbstractEngine(object):
return None, e
- def eval(script):
+ def eval(self, script):
raise NotImplementedError
@@ -211,7 +211,7 @@ class RhinoEngine(AbstractEngine):
def setup(self):
jspath = [
- "/usr/share/java*/js.jar",
+ "/usr/share/java/js.jar",
"js.jar",
path.join(pypath, "js.jar")
]
diff --git a/pyload/utils/__init__.py b/pyload/utils/__init__.py
index bfcc48621..46b375e7a 100644
--- a/pyload/utils/__init__.py
+++ b/pyload/utils/__init__.py
@@ -8,7 +8,8 @@ import re
import sys
import time
-from gettext import gettext
+#from gettext import gettext
+import pylgettext as gettext
from htmlentitydefs import name2codepoint
from os.path import join
from string import maketrans
@@ -252,11 +253,14 @@ def versiontuple(v): #: By kindall (http://stackoverflow.com/a/11887825)
def load_translation(name, locale, default="en"):
""" Load language and return its translation object or None """
+ from traceback import print_exc
+ from os.path import join
try:
- gettext.setpaths([path.join(os.sep, "usr", "share", "pyload", "locale"), None])
- translation = gettext.translation(name, self.path("locale"),
+ gettext.setpaths([join(os.sep, "usr", "share", "pyload", "locale"), None])
+ translation = gettext.translation(name, join(pypath, "locale"),
languages=[locale, default], fallback=True)
except Exception:
+ print_exc()
return None
else:
translation.install(True)
diff --git a/pyload/webui/__init__.py b/pyload/webui/__init__.py
index 0d2f1ca36..1310c629d 100644
--- a/pyload/webui/__init__.py
+++ b/pyload/webui/__init__.py
@@ -24,20 +24,20 @@ from middlewares import StripPathMiddleware, GZipMiddleWare, PrefixMiddleware
SETUP = None
PYLOAD = None
-from pyload.manager.thread import ServerThread
+from pyload.manager.thread import Server
from pyload.network.JsEngine import JsEngine
-if not ServerThread.core:
- if ServerThread.setup:
- SETUP = ServerThread.setup
+if not Server.core:
+ if Server.setup:
+ SETUP = Server.setup
config = SETUP.config
JS = JsEngine(SETUP)
else:
raise Exception("Could not access pyLoad Core")
else:
- PYLOAD = ServerThread.core.api
- config = ServerThread.core.config
- JS = JsEngine(ServerThread.core)
+ PYLOAD = Server.core.api
+ config = Server.core.config
+ JS = JsEngine(Server.core)
THEME = config.get('webinterface', 'theme')
DL_ROOT = config.get('general', 'download_folder')
@@ -58,7 +58,7 @@ if not exists(cache):
bcc = FileSystemBytecodeCache(cache, '%s.cache')
-loader = FileSystemLoader(THEME_DIR)
+loader = FileSystemLoader([THEME_DIR, join(THEME_DIR, THEME)])
env = Environment(loader=loader, extensions=['jinja2.ext.i18n', 'jinja2.ext.autoescape'], trim_blocks=True, auto_reload=False,
bytecode_cache=bcc)
diff --git a/pyload/webui/app/__init__.py b/pyload/webui/app/__init__.py
index 39d0fadd5..43c9ecbe9 100644
--- a/pyload/webui/app/__init__.py
+++ b/pyload/webui/app/__init__.py
@@ -1,3 +1,3 @@
# -*- coding: utf-8 -*-
-from pyload.webui.app import api, cnl, json, pyload
+from pyload.webui.app import api, cnl, json, pyloadweb
diff --git a/pyload/webui/app/api.py b/pyload/webui/app/api.py
index 1ee4b1608..ceee50c8a 100644
--- a/pyload/webui/app/api.py
+++ b/pyload/webui/app/api.py
@@ -6,7 +6,7 @@ from traceback import format_exc, print_exc
from bottle import route, request, response, HTTPError
-from pyload.utils import toDict, set_session
+from pyload.webui.app.utils import toDict, set_session
from pyload.webui import PYLOAD
from pyload.utils import json
diff --git a/pyload/webui/app/json.py b/pyload/webui/app/json.py
index c347c25e3..b61f57a8c 100644
--- a/pyload/webui/app/json.py
+++ b/pyload/webui/app/json.py
@@ -8,7 +8,7 @@ from bottle import route, request, HTTPError
from pyload.webui import PYLOAD
-from pyload.utils import login_required, render_to_response, toDict
+from pyload.webui.app.utils import login_required, render_to_response, toDict
from pyload.utils import decode, formatSize
diff --git a/pyload/webui/app/pyload.py b/pyload/webui/app/pyloadweb.py
index a52f9d05f..d7604918b 100644
--- a/pyload/webui/app/pyload.py
+++ b/pyload/webui/app/pyloadweb.py
@@ -14,9 +14,9 @@ from urllib import unquote
from bottle import route, static_file, request, response, redirect, error
-from pyload.webui import PYLOAD, PYLOAD_DIR, THEME_DIR, SETUP, env
+from pyload.webui import PYLOAD, PYLOAD_DIR, THEME_DIR, THEME, SETUP, env
-from pyload.utils import render_to_response, parse_permissions, parse_userdata, \
+from pyload.webui.app.utils import render_to_response, parse_permissions, parse_userdata, \
login_required, get_permission, set_permission, permlist, toDict, set_session
from pyload.webui.filters import relpath, unquotepath
@@ -81,7 +81,7 @@ def error500(error):
@route('/<theme>/<file:re:(.+/)?[^/]+\.min\.[^/]+>')
def server_min(theme, file):
- filename = join(THEME_DIR, theme, file)
+ filename = join(THEME_DIR, THEME, theme, file)
if not isfile(filename):
file = file.replace(".min.", ".")
if file.endswith(".js"):
@@ -90,7 +90,7 @@ def server_min(theme, file):
return server_static(theme, file)
-@route('/<theme>/<file_static:re:.+\.js>')
+@route('/<theme>/<file:re:.+\.js>')
def server_js(theme, file):
response.headers['Content-Type'] = "text/javascript; charset=UTF-8"
@@ -111,7 +111,7 @@ def server_static(theme, file):
time.gmtime(time.time() + 24 * 7 * 60 * 60))
response.headers['Cache-control'] = "public"
- return static_file(file, root=join(THEME_DIR, theme))
+ return static_file(file, root=join(THEME_DIR, THEME, theme))
@route('/favicon.ico')