diff options
Diffstat (limited to 'pyload/webui/app')
-rw-r--r-- | pyload/webui/app/api.py | 4 | ||||
-rw-r--r-- | pyload/webui/app/cnl.py | 4 | ||||
-rw-r--r-- | pyload/webui/app/json.py | 62 | ||||
-rw-r--r-- | pyload/webui/app/pyloadweb.py | 52 | ||||
-rw-r--r-- | pyload/webui/app/utils.py | 16 |
5 files changed, 69 insertions, 69 deletions
diff --git a/pyload/webui/app/api.py b/pyload/webui/app/api.py index dd8521a07..2ec342fe2 100644 --- a/pyload/webui/app/api.py +++ b/pyload/webui/app/api.py @@ -37,7 +37,7 @@ def call_api(func, args=""): if not s or not s.get("authenticated", False): return HTTPError(403, json.dumps("Forbidden")) - if not PYLOAD.isAuthorized(func, {"role": s["role"], "permission": s["perms"]}): + if not PYLOAD.isAuthorized(func, {"role": s['role'], "permission": s['perms']}): return HTTPError(401, json.dumps("Unauthorized")) args = args.split("/")[1:] @@ -86,7 +86,7 @@ def login(): # get the session id by dirty way, documentations seems wrong try: - sid = s._headers["cookie_out"].split("=")[1].split(";")[0] + sid = s._headers['cookie_out'].split("=")[1].split(";")[0] return json.dumps(sid) except Exception: return json.dumps(True) diff --git a/pyload/webui/app/cnl.py b/pyload/webui/app/cnl.py index 51767033f..73087ad2d 100644 --- a/pyload/webui/app/cnl.py +++ b/pyload/webui/app/cnl.py @@ -73,8 +73,8 @@ def addcrypted(): @local_check def addcrypted2(): package = request.forms.get("source", None) - crypted = request.forms["crypted"] - jk = request.forms["jk"] + crypted = request.forms['crypted'] + jk = request.forms['jk'] crypted = standard_b64decode(unquote(crypted.replace(" ", "+"))) if JS: diff --git a/pyload/webui/app/json.py b/pyload/webui/app/json.py index 700b310a0..51159ddf3 100644 --- a/pyload/webui/app/json.py +++ b/pyload/webui/app/json.py @@ -22,7 +22,7 @@ def format_time(seconds): def get_sort_key(item): - return item["order"] + return item['order'] @route('/json/status') @@ -87,29 +87,29 @@ def packages(): def package(id): try: data = toDict(PYLOAD.getPackageData(id)) - data["links"] = [toDict(x) for x in data["links"]] - - for pyfile in data["links"]: - if pyfile["status"] == 0: - pyfile["icon"] = "status_finished.png" - elif pyfile["status"] in (2, 3): - pyfile["icon"] = "status_queue.png" - elif pyfile["status"] in (9, 1): - pyfile["icon"] = "status_offline.png" - elif pyfile["status"] == 5: - pyfile["icon"] = "status_waiting.png" - elif pyfile["status"] == 8: - pyfile["icon"] = "status_failed.png" - elif pyfile["status"] == 4: - pyfile["icon"] = "arrow_right.png" - elif pyfile["status"] in (11, 13): - pyfile["icon"] = "status_proc.png" + data['links'] = [toDict(x) for x in data['links']] + + for pyfile in data['links']: + if pyfile['status'] == 0: + pyfile['icon'] = "status_finished.png" + elif pyfile['status'] in (2, 3): + pyfile['icon'] = "status_queue.png" + elif pyfile['status'] in (9, 1): + pyfile['icon'] = "status_offline.png" + elif pyfile['status'] == 5: + pyfile['icon'] = "status_waiting.png" + elif pyfile['status'] == 8: + pyfile['icon'] = "status_failed.png" + elif pyfile['status'] == 4: + pyfile['icon'] = "arrow_right.png" + elif pyfile['status'] in (11, 13): + pyfile['icon'] = "status_proc.png" else: - pyfile["icon"] = "status_downloading.png" + pyfile['icon'] = "status_downloading.png" - tmp = data["links"] + tmp = data['links'] tmp.sort(key=get_sort_key) - data["links"] = tmp + data['links'] = tmp return data except Exception: @@ -217,7 +217,7 @@ def edit_package(): def set_captcha(): if request.environ.get('REQUEST_METHOD', "GET") == "POST": try: - PYLOAD.setCaptchaResult(request.forms["cap_id"], request.forms["cap_result"]) + PYLOAD.setCaptchaResult(request.forms['cap_id'], request.forms['cap_result']) except Exception: pass @@ -243,10 +243,10 @@ def load_config(category, section): for key, option in conf[section].iteritems(): if key in ("desc", "outline"): continue - if ";" in option["type"]: - option["list"] = option["type"].split(";") + if ";" in option['type']: + option['list'] = option['type'].split(";") - option["value"] = decode(option["value"]) + option['value'] = decode(option['value']) return render_to_response("settings_item.html", {"skey": section, "section": conf[section]}) @@ -268,9 +268,9 @@ def save_config(category): @route('/json/add_account', method='POST') @login_required("ACCOUNTS") def add_account(): - login = request.POST["account_login"] - password = request.POST["account_password"] - type = request.POST["account_type"] + login = request.POST['account_login'] + password = request.POST['account_password'] + type = request.POST['account_type'] PYLOAD.updateAccount(type, login, password) @@ -302,9 +302,9 @@ def update_accounts(): @route('/json/change_password', method='POST') def change_password(): - user = request.POST["user_login"] - oldpw = request.POST["login_current_password"] - newpw = request.POST["login_new_password"] + user = request.POST['user_login'] + oldpw = request.POST['login_current_password'] + newpw = request.POST['login_new_password'] if not PYLOAD.changePassword(user, oldpw, newpw): print "Wrong password" diff --git a/pyload/webui/app/pyloadweb.py b/pyload/webui/app/pyloadweb.py index cc2185fd4..1604bd576 100644 --- a/pyload/webui/app/pyloadweb.py +++ b/pyload/webui/app/pyloadweb.py @@ -34,16 +34,16 @@ def pre_processor(): captcha = False update = False plugins = False - if user["is_authenticated"]: + if user['is_authenticated']: status = PYLOAD.statusServer() info = PYLOAD.getInfoByPlugin("UpdateManager") captcha = PYLOAD.isCaptchaWaiting() # check if update check is available if info: - if info["pyload"] == "True": - update = info["version"] - if info["plugins"] == "True": + if info['pyload'] == "True": + update = info['version'] + if info['plugins'] == "True": plugins = True return {"user": user, @@ -165,8 +165,8 @@ def home(): return redirect("/login") for link in res: - if link["status"] == 12: - link["information"] = "%s kB @ %s kB/s" % (link["size"] - link["bleft"], link["speed"]) + if link['status'] == 12: + link['information'] = "%s kB @ %s kB/s" % (link['size'] - link['bleft'], link['speed']) return render_to_response("home.html", {"res": res}, [pre_processor]) @@ -282,14 +282,14 @@ def config(): data.validuntil = time.strftime("%d.%m.%Y - %H:%M:%S", t) try: - data.options["time"] = data.options["time"][0] + data.options['time'] = data.options['time'][0] except Exception: - data.options["time"] = "0:00-0:00" + data.options['time'] = "0:00-0:00" if "limitDL" in data.options: - data.options["limitdl"] = data.options["limitDL"][0] + data.options['limitdl'] = data.options['limitDL'][0] else: - data.options["limitdl"] = "0" + data.options['limitdl'] = "0" return render_to_response('settings.html', {'conf': {'plugin': plugin_menu, 'general': conf_menu, 'accs': accs}, 'types': PYLOAD.getAccountTypes()}, @@ -482,30 +482,30 @@ def admin(): perms = permlist() for data in user.itervalues(): - data["perms"] = {} - get_permission(data["perms"], data["permission"]) - data["perms"]["admin"] = True if data["role"] is 0 else False + data['perms'] = {} + get_permission(data['perms'], data['permission']) + data['perms']['admin'] = True if data['role'] is 0 else False s = request.environ.get('beaker.session') if request.environ.get('REQUEST_METHOD', "GET") == "POST": for name in user: if request.POST.get("%s|admin" % name, False): - user[name]["role"] = 0 - user[name]["perms"]["admin"] = True - elif name != s["name"]: - user[name]["role"] = 1 - user[name]["perms"]["admin"] = False + user[name]['role'] = 0 + user[name]['perms']['admin'] = True + elif name != s['name']: + user[name]['role'] = 1 + user[name]['perms']['admin'] = False # set all perms to false for perm in perms: - user[name]["perms"][perm] = False + user[name]['perms'][perm] = False for perm in request.POST.getall("%s|perms" % name): - user[name]["perms"][perm] = True + user[name]['perms'][perm] = True - user[name]["permission"] = set_permission(user[name]["perms"]) + user[name]['permission'] = set_permission(user[name]['perms']) - PYLOAD.setUserPermission(name, user[name]["permission"], user[name]["role"]) + PYLOAD.setUserPermission(name, user[name]['permission'], user[name]['role']) return render_to_response("admin.html", {"users": user, "permlist": perms}, [pre_processor]) @@ -528,10 +528,10 @@ def info(): "os" : " ".join((os.name, sys.platform) + extra), "version" : PYLOAD.getServerVersion(), "folder" : abspath(PYLOAD_DIR), "config": abspath(""), - "download" : abspath(conf["general"]["download_folder"]["value"]), + "download" : abspath(conf['general']['download_folder']['value']), "freespace": formatSize(PYLOAD.freeSpace()), - "remote" : conf["remote"]["port"]["value"], - "webif" : conf["webui"]["port"]["value"], - "language" : conf["general"]["language"]["value"]} + "remote" : conf['remote']['port']['value'], + "webif" : conf['webui']['port']['value'], + "language" : conf['general']['language']['value']} return render_to_response("info.html", data, [pre_processor]) diff --git a/pyload/webui/app/utils.py b/pyload/webui/app/utils.py index ac7fa84fb..f9931f531 100644 --- a/pyload/webui/app/utils.py +++ b/pyload/webui/app/utils.py @@ -18,8 +18,8 @@ def render_to_response(file, args={}, proc=[]): def parse_permissions(session): perms = dict((x, False) for x in dir(PERMS) if not x.startswith("_")) - perms["ADMIN"] = False - perms["is_admin"] = False + perms['ADMIN'] = False + perms['is_admin'] = False if not session.get("authenticated", False): return perms @@ -66,12 +66,12 @@ def set_permission(perms): def set_session(request, info): s = request.environ.get('beaker.session') - s["authenticated"] = True - s["user_id"] = info["id"] - s["name"] = info["name"] - s["role"] = info["role"] - s["perms"] = info["permission"] - s["template"] = info["template"] + s['authenticated'] = True + s['user_id'] = info['id'] + s['name'] = info['name'] + s['role'] = info['role'] + s['perms'] = info['permission'] + s['template'] = info['template'] s.save() return s |