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


Python PYLOAD.getConfigValue方法代码示例

本文整理汇总了Python中webinterface.PYLOAD.getConfigValue方法的典型用法代码示例。如果您正苦于以下问题:Python PYLOAD.getConfigValue方法的具体用法?Python PYLOAD.getConfigValue怎么用?Python PYLOAD.getConfigValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在webinterface.PYLOAD的用法示例。


在下文中一共展示了PYLOAD.getConfigValue方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: index

# 需要导入模块: from webinterface import PYLOAD [as 别名]
# 或者: from webinterface.PYLOAD import getConfigValue [as 别名]
def index():
    # the browser should not set this, but remove in case to to avoid cached requests
    if 'HTTP_IF_MODIFIED_SINCE' in request.environ:
        del request.environ['HTTP_IF_MODIFIED_SINCE']

    if UNAVAILALBE:
        return serve_static("unavailable.html")

    resp = serve_static('index.html')
    # set variable depending on setup mode
    setup = 'false' if SETUP is None else 'true'
    ws = PYLOAD.getWSAddress() if PYLOAD else False
    external = PYLOAD.getConfigValue('webUI', 'external') if PYLOAD else None
    web = None
    if PYLOAD:
        web = PYLOAD.getConfigValue('webUI', 'port')
    elif SETUP:
        web = SETUP.config['webUI']['port']

    # Render variables into the html page
    if resp.status_code == 200:
        content = resp.body.read()
        resp.body = template(content, ws=ws, web=web, setup=setup, external=external, prefix=PREFIX)
        resp.content_length = len(resp.body) + 1

    # these page should not be cached at all
    resp.headers.append("Cache-Control", "no-cache")
    # they are rendered and last modified would be wrong
    if "Last-Modified" in resp.headers:
        del resp.headers["Last-Modified"]

    return resp
开发者ID:ASCIIteapot,项目名称:pyload,代码行数:34,代码来源:pyload_app.py

示例2: add_package

# 需要导入模块: from webinterface import PYLOAD [as 别名]
# 或者: from webinterface.PYLOAD import getConfigValue [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)
        destination = open(fpath, 'wb')
        copyfileobj(f.file, destination)
        destination.close()
        links.insert(0, fpath)
    except:
        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:EikeKre,项目名称:pyload,代码行数:33,代码来源:json_app.py

示例3: downloads

# 需要导入模块: from webinterface import PYLOAD [as 别名]
# 或者: from webinterface.PYLOAD import getConfigValue [as 别名]
def downloads():
    root = PYLOAD.getConfigValue("general", "download_folder")

    if not isdir(root):
        return base([_('Download directory not found.')])
    data = {
        'folder': [],
        'files': []
    }

    items = listdir(fs_encode(root))

    for item in sorted([fs_decode(x) for x in items]):
        if isdir(save_join(root, item)):
            folder = {
                'name': item,
                'path': item,
                'files': []
            }
            files = listdir(save_join(root, item))
            for file in sorted([fs_decode(x) for x in files]):
                try:
                    if isfile(save_join(root, item, file)):
                        folder['files'].append(file)
                except:
                    pass

            data['folder'].append(folder)
        elif isfile(join(root, item)):
            data['files'].append(item)

    return render_to_response('downloads.html', {'files': data}, [pre_processor])
开发者ID:EikeKre,项目名称:pyload,代码行数:34,代码来源:pyload_app.py

示例4: get_download

# 需要导入模块: from webinterface import PYLOAD [as 别名]
# 或者: from webinterface.PYLOAD import getConfigValue [as 别名]
def get_download(path):
    path = unquote(path).decode("utf8")
    #@TODO some files can not be downloaded

    root = PYLOAD.getConfigValue("general", "download_folder")

    path = path.replace("..", "")
    try:
        return static_file(fs_encode(path), fs_encode(root))

    except Exception, e:
        print e
        return HTTPError(404, "File not Found.")
开发者ID:EikeKre,项目名称:pyload,代码行数:15,代码来源:pyload_app.py

示例5: index

# 需要导入模块: from webinterface import PYLOAD [as 别名]
# 或者: from webinterface.PYLOAD import getConfigValue [as 别名]
def index():
    if UNAVAILALBE:
        return server_static("unavailable.html")

    if SETUP:
        # TODO show different page
        pass

    f = server_static('index.html')
    content = f.body.read()
    f.body = template(content, ws=PYLOAD.getWSAddress(), web=PYLOAD.getConfigValue('webinterface', 'port'))

    return f
开发者ID:Kagenoshin,项目名称:pyload,代码行数:15,代码来源:pyload_app.py

示例6: index

# 需要导入模块: from webinterface import PYLOAD [as 别名]
# 或者: from webinterface.PYLOAD import getConfigValue [as 别名]
def index():
    if UNAVAILALBE:
        return server_static("unavailable.html")

    if SETUP:
        # TODO show different page
        pass

    resp = server_static('index.html')

    # Render variables into the html page
    if resp.status_code == 200:
        content = resp.body.read()
        resp.body = template(content, ws=PYLOAD.getWSAddress(), web=PYLOAD.getConfigValue('webinterface', 'port'))

    return resp
开发者ID:DasLampe,项目名称:pyload,代码行数:18,代码来源:pyload_app.py

示例7: index

# 需要导入模块: from webinterface import PYLOAD [as 别名]
# 或者: from webinterface.PYLOAD import getConfigValue [as 别名]
def index():
    if UNAVAILALBE:
        return serve_static("unavailable.html")

    resp = serve_static('index.html')
    # set variable depending on setup mode
    setup = 'false' if SETUP is None else 'true'
    ws = PYLOAD.getWSAddress() if PYLOAD else False
    web = PYLOAD.getConfigValue('webinterface', 'port') if PYLOAD else False

    # Render variables into the html page
    if resp.status_code == 200:
        content = resp.body.read()
        resp.body = template(content, ws=ws, web=web, setup=setup)
        resp.content_length = len(resp.body)

    return resp
开发者ID:chkorn,项目名称:pyload,代码行数:19,代码来源:pyload_app.py

示例8: logs

# 需要导入模块: from webinterface import PYLOAD [as 别名]
# 或者: from webinterface.PYLOAD import getConfigValue [as 别名]
def logs(item=-1):
    s = request.environ.get('beaker.session')

    perpage = s.get('perpage', 34)
    reversed = s.get('reversed', False)

    warning = ""
    conf = PYLOAD.getConfigValue("log","file_log")
    if not conf:
        warning = "Warning: File log is disabled, see settings page."

    perpage_p = ((20, 20), (34, 34), (40, 40), (100, 100), (0, 'all'))
    fro = None

    if request.environ.get('REQUEST_METHOD', "GET") == "POST":
        try:
            fro = datetime.strptime(request.forms['from'], '%d.%m.%Y %H:%M:%S')
        except:
            pass
        try:
            perpage = int(request.forms['perpage'])
            s['perpage'] = perpage

            reversed = bool(request.forms.get('reversed', False))
            s['reversed'] = reversed
        except:
            pass

        s.save()

    try:
        item = int(item)
    except:
        pass

    log = PYLOAD.getLog()
    if not perpage:
        item = 0

    if item < 1 or type(item) is not int:
        item = 1 if len(log) - perpage + 1 < 1 else len(log) - perpage + 1

    if type(fro) is datetime: # we will search for datetime
        item = -1

    data = []
    counter = 0
    perpagecheck = 0
    for l in log:
        counter += 1

        if counter >= item:
            try:
                date, time, level, message = l.decode("utf8", "ignore").split(" ", 3)
                dtime = datetime.strptime(date + ' ' + time, '%d.%m.%Y %H:%M:%S')
            except:
                dtime = None
                date = '?'
                time = ' '
                level = '?'
                message = l
            if item == -1 and dtime is not None and fro <= dtime:
                item = counter #found our datetime
            if item >= 0:
                data.append({'line': counter, 'date': date + " " + time, 'level': level, 'message': message})
                perpagecheck += 1
                if fro is None and dtime is not None: #if fro not set set it to first showed line
                    fro = dtime
            if perpagecheck >= perpage > 0:
                break

    if fro is None: #still not set, empty log?
        fro = datetime.now()
    if reversed:
        data.reverse()
    return render_to_response('logs.html', {'warning': warning, 'log': data, 'from': fro.strftime('%d.%m.%Y %H:%M:%S'),
                                            'reversed': reversed, 'perpage': perpage, 'perpage_p': sorted(perpage_p),
                                            'iprev': 1 if item - perpage < 1 else item - perpage,
                                            'inext': (item + perpage) if item + perpage < len(log) else item},
        [pre_processor])
开发者ID:EikeKre,项目名称:pyload,代码行数:82,代码来源:pyload_app.py


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