diff options
Diffstat (limited to 'pyload/webui')
-rw-r--r-- | pyload/webui/App/__init__.py | 3 | ||||
-rw-r--r-- | pyload/webui/App/api.py (renamed from pyload/webui/app/api.py) | 20 | ||||
-rw-r--r-- | pyload/webui/App/app.py (renamed from pyload/webui/app/pyload.py) | 4 | ||||
-rw-r--r-- | pyload/webui/App/cnl.py (renamed from pyload/webui/app/cnl.py) | 0 | ||||
-rw-r--r-- | pyload/webui/App/json.py (renamed from pyload/webui/app/json.py) | 2 | ||||
-rw-r--r-- | pyload/webui/App/utils.py (renamed from pyload/webui/app/utils.py) | 2 | ||||
-rw-r--r-- | pyload/webui/__init__.py | 12 | ||||
-rw-r--r-- | pyload/webui/app/__init__.py | 3 |
8 files changed, 23 insertions, 23 deletions
diff --git a/pyload/webui/App/__init__.py b/pyload/webui/App/__init__.py new file mode 100644 index 000000000..f48708914 --- /dev/null +++ b/pyload/webui/App/__init__.py @@ -0,0 +1,3 @@ +# -*- coding: utf-8 -*- + +from pyload.webui.App import app, api, cnl, json diff --git a/pyload/webui/app/api.py b/pyload/webui/App/api.py index 99a7c2998..31366b902 100644 --- a/pyload/webui/app/api.py +++ b/pyload/webui/App/api.py @@ -8,9 +8,9 @@ import SafeEval import bottle from pyload.Api import BaseObject -from pyload.utils import json +from pyload.utils import json, json_dumps from pyload.webui import PYLOAD -from pyload.webui.app.utils import toDict, set_session +from pyload.webui.App.utils import toDict, set_session # json encoder that accepts TBase objects @@ -34,10 +34,10 @@ def call_api(func, args=""): s = s.get_by_id(request.POST['session']) if not s or not s.get("authenticated", False): - return bottle.HTTPError(403, json.dumps("Forbidden")) + return bottle.HTTPError(403, json_dumps("Forbidden")) if not PYLOAD.isAuthorized(func, {"role": s['role'], "permission": s['perms']}): - return bottle.HTTPError(401, json.dumps("Unauthorized")) + return bottle.HTTPError(401, json_dumps("Unauthorized")) args = args.split("/")[1:] kwargs = {} @@ -51,19 +51,19 @@ def call_api(func, args=""): return callApi(func, *args, **kwargs) except Exception, e: traceback.print_exc() - return bottle.HTTPError(500, json.dumps({"error": e.message, "traceback": traceback.format_exc()})) + return bottle.HTTPError(500, json_dumps({"error": e.message, "traceback": traceback.format_exc()})) def callApi(func, *args, **kwargs): if not hasattr(PYLOAD.EXTERNAL, func) or func.startswith("_"): print "Invalid API call", func - return bottle.HTTPError(404, json.dumps("Not Found")) + return bottle.HTTPError(404, json_dumps("Not Found")) result = getattr(PYLOAD, func)(*[SafeEval.const_eval(x) for x in args], **dict((x, SafeEval.const_eval(y)) for x, y in kwargs.iteritems())) # null is invalid json response - return json.dumps(result or True, cls=TBaseEncoder) + return json_dumps(result or True, cls=TBaseEncoder) # post -> username, password @@ -78,16 +78,16 @@ def login(): info = PYLOAD.checkAuth(user, password) if not info: - return json.dumps(False) + return json_dumps(False) s = set_session(request, info) # get the session id by dirty way, documentations seems wrong try: sid = s._headers['cookie_out'].split("=")[1].split(";")[0] - return json.dumps(sid) + return json_dumps(sid) except Exception: - return json.dumps(True) + return json_dumps(True) @bottle.route('/api/logout') diff --git a/pyload/webui/app/pyload.py b/pyload/webui/App/app.py index 58acdf12c..9d031e659 100644 --- a/pyload/webui/app/pyload.py +++ b/pyload/webui/App/app.py @@ -12,7 +12,7 @@ import bottle from pyload.webui import PYLOAD, PYLOAD_DIR, THEME_DIR, THEME, SETUP, env -from pyload.webui.app.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.utils.filters import relpath, unquotepath @@ -298,7 +298,7 @@ def config(): @bottle.route('/filechooser/<file:path>') @bottle.route('/pathchooser/<path:path>') @login_required('STATUS') -def os.path(file="", path=""): +def path(file="", path=""): type = "file" if file else "folder" path = os.path.normpath(unquotepath(path)) diff --git a/pyload/webui/app/cnl.py b/pyload/webui/App/cnl.py index 07b966f5e..07b966f5e 100644 --- a/pyload/webui/app/cnl.py +++ b/pyload/webui/App/cnl.py diff --git a/pyload/webui/app/json.py b/pyload/webui/App/json.py index a7fe8dcfb..98eb8c4f2 100644 --- a/pyload/webui/app/json.py +++ b/pyload/webui/App/json.py @@ -10,7 +10,7 @@ import bottle from pyload.utils import decode, formatSize from pyload.webui import PYLOAD -from pyload.webui.app.utils import login_required, render_to_response, toDict +from pyload.webui.App.utils import login_required, render_to_response, toDict def format_time(seconds): diff --git a/pyload/webui/app/utils.py b/pyload/webui/App/utils.py index 5663c6f58..18d66c302 100644 --- a/pyload/webui/app/utils.py +++ b/pyload/webui/App/utils.py @@ -115,7 +115,7 @@ def toDict(obj): return dict((att, getattr(obj, att)) for att in obj.__slots__) -class CherryPyWSGI(ServerAdapter): +class CherryPyWSGI(bottle.ServerAdapter): def run(self, handler): from wsgiserver import CherryPyWSGIServer diff --git a/pyload/webui/__init__.py b/pyload/webui/__init__.py index e1fe6738f..1dcd6bb6e 100644 --- a/pyload/webui/__init__.py +++ b/pyload/webui/__init__.py @@ -4,11 +4,11 @@ import os import sys -import beaker +import beaker.middleware import bottle import jinja2 -import pyload.utils.pylgettext as gettext +from pyload.utils import pylgettext as gettext from pyload.Thread import Server from pyload.utils.middlewares import StripPathMiddleware, GZipMiddleWare, PrefixMiddleware @@ -16,7 +16,7 @@ from pyload.network.JsEngine import JsEngine from pyload.utils import decode, formatSize -THEME_DIR = os.path.abspath(os.path.join(dirname(__file__), "themes")) +THEME_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__), "themes")) PYLOAD_DIR = os.path.abspath(os.path.join(THEME_DIR, "..", "..", "..")) sys.path.append(PYLOAD_DIR) @@ -76,7 +76,7 @@ if PREFIX: else: env.filters['url'] = lambda x: PREFIX + x if x.startswith("/") else x -gettext.setpaths([join(os.sep, "usr", "share", "pyload", "locale"), None]) +gettext.setpaths([os.path.join(os.sep, "usr", "share", "pyload", "locale"), None]) translation = gettext.translation("django", os.path.join(PYLOAD_DIR, "locale"), languages=[config.get("general", "language"), "en"],fallback=True) translation.install(True) @@ -95,7 +95,7 @@ web = GZipMiddleWare(web) if PREFIX: web = PrefixMiddleware(web, prefix=PREFIX) -import pyload.webui.app +from pyload.webui import App def run_auto(host="0.0.0.0", port="8000"): @@ -115,7 +115,7 @@ def run_threaded(host="0.0.0.0", port="8000", theads=3, cert="", key=""): wsgiserver.CherryPyWSGIServer.numthreads = theads - from pyload.webui.app.utils import CherryPyWSGI + from pyload.webui.App.utils import CherryPyWSGI bottle.run(app=web, host=host, port=port, server=CherryPyWSGI, quiet=True) diff --git a/pyload/webui/app/__init__.py b/pyload/webui/app/__init__.py deleted file mode 100644 index 39d0fadd5..000000000 --- a/pyload/webui/app/__init__.py +++ /dev/null @@ -1,3 +0,0 @@ -# -*- coding: utf-8 -*- - -from pyload.webui.app import api, cnl, json, pyload |