summaryrefslogtreecommitdiffstats
path: root/pyload/webui/app
diff options
context:
space:
mode:
authorGravatar Walter Purcaro <vuolter@gmail.com> 2014-12-01 23:53:07 +0100
committerGravatar Walter Purcaro <vuolter@gmail.com> 2014-12-01 23:53:07 +0100
commit004a80bfaad38f9400e8aebcb8f980353a232295 (patch)
tree1e786d2d14a3040767aac237982544b74a9567cb /pyload/webui/app
parentFix previous merge (diff)
downloadpyload-004a80bfaad38f9400e8aebcb8f980353a232295.tar.xz
PEP-8, Python Zen, refactor and reduce code (thx FedeG)
Diffstat (limited to 'pyload/webui/app')
-rw-r--r--pyload/webui/app/api.py4
-rw-r--r--pyload/webui/app/cnl.py10
-rw-r--r--pyload/webui/app/json.py22
-rw-r--r--pyload/webui/app/pyload.py22
-rw-r--r--pyload/webui/app/utils.py2
5 files changed, 30 insertions, 30 deletions
diff --git a/pyload/webui/app/api.py b/pyload/webui/app/api.py
index 286061c2a..9726902fb 100644
--- a/pyload/webui/app/api.py
+++ b/pyload/webui/app/api.py
@@ -60,7 +60,7 @@ def callApi(func, *args, **kwargs):
return HTTPError(404, json.dumps("Not Found"))
result = getattr(PYLOAD, func)(*[literal_eval(x) for x in args],
- **dict([(x, literal_eval(y)) for x, y in kwargs.iteritems()]))
+ **dict((x, literal_eval(y)) for x, y in kwargs.iteritems()))
# null is invalid json response
if result is None: result = True
@@ -88,7 +88,7 @@ def login():
try:
sid = s._headers["cookie_out"].split("=")[1].split(";")[0]
return json.dumps(sid)
- except:
+ except Exception:
return json.dumps(True)
diff --git a/pyload/webui/app/cnl.py b/pyload/webui/app/cnl.py
index 1444983c2..e00e47f66 100644
--- a/pyload/webui/app/cnl.py
+++ b/pyload/webui/app/cnl.py
@@ -11,7 +11,7 @@ from pyload.webui import PYLOAD, DL_ROOT, JS
try:
from Crypto.Cipher import AES
-except:
+except Exception:
pass
@@ -61,7 +61,7 @@ def addcrypted():
try:
PYLOAD.addPackage(package, [dlc_path], 0)
- except:
+ except Exception:
return HTTPError()
else:
return "success\r\n"
@@ -82,7 +82,7 @@ def addcrypted2():
else:
try:
jk = re.findall(r"return ('|\")(.+)('|\")", jk)[0][1]
- except:
+ except Exception:
## Test for some known js functions to decode
if jk.find("dec") > -1 and jk.find("org") > -1:
org = re.findall(r"var org = ('|\")([^\"']+)", jk)[0][1]
@@ -94,7 +94,7 @@ def addcrypted2():
try:
Key = unhexlify(jk)
- except:
+ except Exception:
print "Could not decrypt key, please install py-spidermonkey or ossp-js"
return "failed"
@@ -110,7 +110,7 @@ def addcrypted2():
PYLOAD.addPackage(package, result, 0)
else:
PYLOAD.generateAndAddPackages(result, 0)
- except:
+ except Exception:
return "failed can't add"
else:
return "success\r\n"
diff --git a/pyload/webui/app/json.py b/pyload/webui/app/json.py
index 8fa675865..096f72ab5 100644
--- a/pyload/webui/app/json.py
+++ b/pyload/webui/app/json.py
@@ -33,7 +33,7 @@ def status():
status = toDict(PYLOAD.statusServer())
status['captcha'] = PYLOAD.isCaptchaWaiting()
return status
- except:
+ except Exception:
return HTTPError()
@@ -78,7 +78,7 @@ def packages():
return data
- except:
+ except Exception:
return HTTPError()
@@ -112,7 +112,7 @@ def package(id):
data["links"] = tmp
return data
- except:
+ except Exception:
print_exc()
return HTTPError()
@@ -124,7 +124,7 @@ def package_order(ids):
pid, pos = ids.split("|")
PYLOAD.orderPackage(int(pid), int(pos))
return {"response": "success"}
- except:
+ except Exception:
return HTTPError()
@@ -134,7 +134,7 @@ def abort_link(id):
try:
PYLOAD.stopDownloads([id])
return {"response": "success"}
- except:
+ except Exception:
return HTTPError()
@@ -145,7 +145,7 @@ def link_order(ids):
pid, pos = ids.split("|")
PYLOAD.orderFile(int(pid), int(pos))
return {"response": "success"}
- except:
+ except Exception:
return HTTPError()
@@ -170,7 +170,7 @@ def add_package():
copyfileobj(f.file, destination)
destination.close()
links.insert(0, fpath)
- except:
+ except Exception:
pass
name = name.decode("utf8", "ignore")
@@ -191,7 +191,7 @@ def move_package(dest, id):
try:
PYLOAD.movePackage(dest, id)
return {"response": "success"}
- except:
+ except Exception:
return HTTPError()
@@ -207,7 +207,7 @@ def edit_package():
PYLOAD.setPackageData(id, data)
return {"response": "success"}
- except:
+ except Exception:
return HTTPError()
@@ -218,7 +218,7 @@ def set_captcha():
if request.environ.get('REQUEST_METHOD', "GET") == "POST":
try:
PYLOAD.setCaptchaResult(request.forms["cap_id"], request.forms["cap_result"])
- except:
+ except Exception:
pass
task = PYLOAD.getCaptchaTask()
@@ -257,7 +257,7 @@ def save_config(category):
for key, value in request.POST.iteritems():
try:
section, option = key.split("|")
- except:
+ except Exception:
continue
if category == "general": category = "core"
diff --git a/pyload/webui/app/pyload.py b/pyload/webui/app/pyload.py
index c13d5bf48..13e3802d1 100644
--- a/pyload/webui/app/pyload.py
+++ b/pyload/webui/app/pyload.py
@@ -173,7 +173,7 @@ def logout():
def home():
try:
res = [toDict(x) for x in PYLOAD.statusDownloads()]
- except:
+ except Exception:
s = request.environ.get('beaker.session')
s.delete()
return redirect("/login")
@@ -231,7 +231,7 @@ def downloads():
try:
if isfile(safe_join(root, item, file)):
folder['files'].append(file)
- except:
+ except Exception:
pass
data['folder'].append(folder)
@@ -289,7 +289,7 @@ def config():
try:
data.options["time"] = data.options["time"][0]
- except:
+ except Exception:
data.options["time"] = "0:00-0:00"
if "limitDL" in data.options:
@@ -334,7 +334,7 @@ def path(file="", path=""):
try:
cwd = cwd.encode("utf8")
- except:
+ except Exception:
pass
cwd = os.path.normpath(os.path.abspath(cwd))
@@ -351,7 +351,7 @@ def path(file="", path=""):
try:
folders = os.listdir(cwd)
- except:
+ except Exception:
folders = []
files = []
@@ -363,7 +363,7 @@ def path(file="", path=""):
data['sort'] = data['fullpath'].lower()
data['modified'] = datetime.fromtimestamp(int(os.path.getmtime(join(cwd, f))))
data['ext'] = os.path.splitext(f)[1]
- except:
+ except Exception:
continue
if os.path.isdir(join(cwd, f)):
@@ -414,7 +414,7 @@ def logs(item=-1):
if request.environ.get('REQUEST_METHOD', "GET") == "POST":
try:
fro = datetime.strptime(request.forms['from'], '%d.%m.%Y %H:%M:%S')
- except:
+ except Exception:
pass
try:
perpage = int(request.forms['perpage'])
@@ -422,14 +422,14 @@ def logs(item=-1):
reversed = bool(request.forms.get('reversed', False))
s['reversed'] = reversed
- except:
+ except Exception:
pass
s.save()
try:
item = int(item)
- except:
+ except Exception:
pass
log = PYLOAD.getLog()
@@ -452,7 +452,7 @@ def logs(item=-1):
try:
date, time, level, message = l.decode("utf8", "ignore").split(" ", 3)
dtime = datetime.strptime(date + ' ' + time, '%d.%m.%Y %H:%M:%S')
- except:
+ except Exception:
dtime = None
date = '?'
time = ' '
@@ -484,7 +484,7 @@ def logs(item=-1):
@login_required("ADMIN")
def admin():
# convert to dict
- user = dict([(name, toDict(y)) for name, y in PYLOAD.getAllUserData().iteritems()])
+ user = dict((name, toDict(y)) for name, y in PYLOAD.getAllUserData().iteritems())
perms = permlist()
for data in user.itervalues():
diff --git a/pyload/webui/app/utils.py b/pyload/webui/app/utils.py
index d5fa66a35..ff0faddd0 100644
--- a/pyload/webui/app/utils.py
+++ b/pyload/webui/app/utils.py
@@ -32,7 +32,7 @@ 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 = dict((x, False) for x in dir(PERMS) if not x.startswith("_"))
perms["ADMIN"] = False
perms["is_admin"] = False