Exemplo n.º 1
0
async def get_torrent(request):
    tid = request.match_info.get('tid', None)

    if tid is None:
        return web.json_response(get_torrent_list())
    else:
        handle = get_valid_handle(tid)

        # We don't want to return all of the keys as they are just an enum
        ignored = ['states'] + list(lt.torrent_status.states.names.keys())

        status = common.struct_to_dict(
            handle.status(),
            ignore_keys=ignored,
        )

        return web.json_response(status)
Exemplo n.º 2
0
def test_struct_to_dict():
    class struct(object):
        a = 1
        b = 2
        __mytest__ = 3
        sha1_hash = lt.sha1_hash(binascii.unhexlify('a0'*20))

    s = struct()

    d = common.struct_to_dict(s)

    assert isinstance(d, dict)
    assert d['a'] == 1
    assert d['b'] == 2
    assert '__mytest__' not in d
    assert len(d) == 3
    assert d['sha1_hash'] == 'a0'*20
Exemplo n.º 3
0
def test_struct_to_dict():
    class struct(object):
        a = 1
        b = 2
        __mytest__ = 3
        sha1_hash = lt.sha1_hash(binascii.unhexlify('a0' * 20))

    s = struct()

    d = common.struct_to_dict(s)

    assert isinstance(d, dict)
    assert d['a'] == 1
    assert d['b'] == 2
    assert '__mytest__' not in d
    assert len(d) == 3
    assert d['sha1_hash'] == 'a0' * 20
Exemplo n.º 4
0
async def get_torrent(request):
    core = request.app['spritzle.core']
    tid = request.match_info.get('tid', None)

    if tid is None:
        return web.json_response(get_torrent_list(core))
    else:
        handle = get_valid_handle(core, tid)

        # We don't want to return all of the keys as they are just an enum
        ignored = (['states', 'handle', 'torrent_file'] +
                   list(lt.torrent_status.states.names.keys()))

        status = common.struct_to_dict(
            handle.status(),
            ignore_keys=ignored,
        )

        if tid in core.torrent_data:
            status.update(core.torrent_data[tid])

        return web.json_response(status)
Exemplo n.º 5
0
async def get_torrent(request):
    core = request.app['spritzle.core']
    tid = request.match_info.get('tid', None)

    if tid is None:
        return web.json_response(get_torrent_list(core))
    else:
        handle = get_valid_handle(core, tid)

        # We don't want to return all of the keys as they are just an enum
        ignored = (['states', 'handle', 'torrent_file'] +
                   list(lt.torrent_status.states.names.keys()))

        status = common.struct_to_dict(
            handle.status(),
            ignore_keys=ignored,
        )

        if tid in core.torrent_data:
            status.update(core.torrent_data[tid])

        return web.json_response(status)
Exemplo n.º 6
0
def get_session_cache_status():
    return common.struct_to_dict(core.session.get_cache_status())
Exemplo n.º 7
0
def get_settings_pe():
    return common.struct_to_dict(core.session.get_pe_settings())
Exemplo n.º 8
0
def get_settings_proxy():
    return common.struct_to_dict(core.session.proxy())
Exemplo n.º 9
0
def get_settings_session_mmu():
    return common.struct_to_dict(libtorrent.min_memory_usage())
Exemplo n.º 10
0
def get_settings_session_hps():
    return common.struct_to_dict(libtorrent.high_performance_seed())