本文整理汇总了Python中pyload.webui.PYLOAD类的典型用法代码示例。如果您正苦于以下问题:Python PYLOAD类的具体用法?Python PYLOAD怎么用?Python PYLOAD使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了PYLOAD类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: pre_processor
def pre_processor():
s = request.environ.get('beaker.session')
user = parse_userdata(s)
perms = parse_permissions(s)
status = {}
captcha = False
update = False
plugins = False
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":
plugins = True
return {"user": user,
'status': status,
'captcha': captcha,
'perms': perms,
'url': request.url,
'update': update,
'plugins': plugins}
示例2: add_package
def add_package():
name = request.forms.get("add_name", "New Package").strip()
queue = int(request.forms['add_dest'])
links = decode(request.forms['add_links'])
links = links.split("\n")
pw = request.forms.get("add_password", "").strip("\n\r")
try:
f = request.files['add_file']
if not name or name == "New Package":
name = f.name
fpath = join(PYLOAD.getConfigValue("general", "download_folder"), "tmp_" + f.filename)
with open(fpath, 'wb') as destination:
shutil.copyfileobj(f.file, destination)
links.insert(0, fpath)
except Exception:
pass
name = name.decode("utf8", "ignore")
links = map(lambda x: x.strip(), links)
links = filter(lambda x: x != "", links)
pack = PYLOAD.addPackage(name, links, queue)
if pw:
pw = pw.decode("utf8", "ignore")
data = {"password": pw}
PYLOAD.setPackageData(pack, data)
示例3: admin
def admin():
# convert to dict
user = dict((name, toDict(y)) for name, y in PYLOAD.getAllUserData().iteritems())
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
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
# set all perms to false
for perm in perms:
user[name]["perms"][perm] = False
for perm in request.POST.getall("%s|perms" % name):
user[name]["perms"][perm] = True
user[name]["permission"] = set_permission(user[name]["perms"])
PYLOAD.setUserPermission(name, user[name]["permission"], user[name]["role"])
return render_to_response("admin.html", {"users": user, "permlist": perms}, [pre_processor])
示例4: status
def status():
try:
status = toDict(PYLOAD.statusServer())
status['captcha'] = PYLOAD.isCaptchaWaiting()
return status
except Exception:
return HTTPError()
示例5: package_order
def package_order(ids):
try:
pid, pos = ids.split("|")
PYLOAD.orderPackage(int(pid), int(pos))
return {"response": "success"}
except Exception:
return bottle.HTTPError()
示例6: link_order
def link_order(ids):
try:
pid, pos = ids.split("|")
PYLOAD.orderFile(int(pid), int(pos))
return {"response": "success"}
except Exception:
return HTTPError()
示例7: save_config
def save_config(category):
for key, value in request.POST.iteritems():
try:
section, option = key.split("|")
except Exception:
continue
if category == "general": category = "core"
PYLOAD.setConfigValue(section, option, decode(value), category)
示例8: add
def add(request):
package = request.POST.get('referer', None)
urls = filter(lambda x: x != "", request.POST['urls'].split("\n"))
if package:
PYLOAD.addPackage(package, urls, 0)
else:
PYLOAD.generateAndAddPackages(urls, 0)
return ""
示例9: config
def config():
conf = PYLOAD.getConfig()
plugin = PYLOAD.getPluginConfig()
conf_menu = []
plugin_menu = []
for entry in sorted(conf.keys()):
conf_menu.append((entry, conf[entry].description))
last_name = None
for entry in sorted(plugin.keys()):
desc = plugin[entry].description
name, none, type = desc.partition("_")
if type in PYLOAD.core.pluginManager.TYPES:
if name == last_name or len([a for a, b in plugin.iteritems() if b.description.startswith(name + "_")]) > 1:
desc = name + " (" + type.title() + ")"
else:
desc = name
last_name = name
plugin_menu.append((entry, desc))
accs = PYLOAD.getAccounts(False)
for data in accs:
if data.trafficleft == -1:
data.trafficleft = _("unlimited")
elif not data.trafficleft:
data.trafficleft = _("not available")
else:
data.trafficleft = formatSize(data.trafficleft)
if data.validuntil == -1:
data.validuntil = _("unlimited")
elif not data.validuntil:
data.validuntil = _("not available")
else:
t = time.localtime(data.validuntil)
data.validuntil = time.strftime("%d.%m.%Y - %H:%M:%S", t)
try:
data.options['time'] = data.options['time'][0]
except Exception:
data.options['time'] = "0:00-0:00"
if "limitDL" in data.options:
data.options['limitdl'] = data.options['limitDL'][0]
else:
data.options['limitdl'] = "0"
return render_to_response('settings.html',
{'conf': {'plugin': plugin_menu, 'general': conf_menu, 'accs': accs},
'types': PYLOAD.getAccountTypes()},
[pre_processor])
示例10: edit_package
def edit_package():
try:
id = int(request.forms.get("pack_id"))
data = {"name": request.forms.get("pack_name").decode("utf8", "ignore"),
"folder": request.forms.get("pack_folder").decode("utf8", "ignore"),
"password": request.forms.get("pack_pws").decode("utf8", "ignore")}
PYLOAD.setPackageData(id, data)
return {"response": "success"}
except Exception:
return HTTPError()
示例11: addcrypted
def addcrypted():
package = request.forms.get('referer', 'ClickNLoad Package')
dlc = request.forms['crypted'].replace(" ", "+")
dlc_path = join(DL_ROOT, package.replace("/", "").replace("\\", "").replace(":", "") + ".dlc")
with open(dlc_path, "wb") as dlc_file:
dlc_file.write(dlc)
try:
PYLOAD.addPackage(package, [dlc_path], 0)
except Exception:
return HTTPError()
else:
return "success\r\n"
示例12: packages
def packages():
print "/json/packages"
try:
data = PYLOAD.getQueue()
for package in data:
package['links'] = []
for file in PYLOAD.get_package_files(package['id']):
package['links'].append(PYLOAD.get_file_info(file))
return data
except Exception:
return HTTPError()
示例13: info
def info():
conf = PYLOAD.getConfigDict()
extra = os.uname() if hasattr(os, "uname") else tuple()
data = {"python" : sys.version,
"os" : " ".join((os.name, sys.platform) + extra),
"version" : PYLOAD.getServerVersion(),
"folder" : os.path.abspath(PYLOAD_DIR), "config": os.path.abspath(""),
"download" : os.path.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']}
return render_to_response("info.html", data, [pre_processor])
示例14: flashgot
def flashgot():
if request.environ['HTTP_REFERER'] not in ("http://localhost:9666/flashgot", "http://127.0.0.1:9666/flashgot"):
return HTTPError()
autostart = int(request.forms.get('autostart', 0))
package = request.forms.get('package', None)
urls = filter(lambda x: x != "", request.forms['urls'].split("\n"))
folder = request.forms.get('dir', None)
if package:
PYLOAD.addPackage(package, urls, autostart)
else:
PYLOAD.generateAndAddPackages(urls, autostart)
return ""
示例15: set_captcha
def set_captcha():
if request.environ.get('REQUEST_METHOD', "GET") == "POST":
try:
PYLOAD.setCaptchaResult(request.forms['cap_id'], request.forms['cap_result'])
except Exception:
pass
task = PYLOAD.getCaptchaTask()
if task.tid >= 0:
src = "data:image/%s;base64,%s" % (task.type, task.data)
return {'captcha': True, 'id': task.tid, 'src': src, 'result_type': task.resultType}
else:
return {'captcha': False}