当前位置: 首页>>代码示例>>Python>>正文


Python PYLOAD.setPackageData方法代码示例

本文整理汇总了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)
开发者ID:reissdorf,项目名称:pyload,代码行数:32,代码来源:json.py

示例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()
开发者ID:reissdorf,项目名称:pyload,代码行数:14,代码来源:json.py


注:本文中的pyload.webui.PYLOAD.setPackageData方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。