本文整理匯總了Python中pyload.webui.PYLOAD.setPackageData方法的典型用法代碼示例。如果您正苦於以下問題:Python PYLOAD.setPackageData方法的具體用法?Python PYLOAD.setPackageData怎麽用?Python PYLOAD.setPackageData使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類pyload.webui.PYLOAD
的用法示例。
在下文中一共展示了PYLOAD.setPackageData方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: add_package
# 需要導入模塊: from pyload.webui import PYLOAD [as 別名]
# 或者: from pyload.webui.PYLOAD import setPackageData [as 別名]
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)
示例2: edit_package
# 需要導入模塊: from pyload.webui import PYLOAD [as 別名]
# 或者: from pyload.webui.PYLOAD import setPackageData [as 別名]
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()