예제 #1
0
def main_view_page(env, view):
    """
    Main page. Shows all torrents, per target.
    Does two XMLRPC calls per target.
    """
    if not loggedin_and_require(env):
        return handle_login(env)

    rtorrent_data = fetch_global_info()

    user = fetch_user(env)

#    if view not in rtorrent_data.get_view_list:
#        return error_page(env, 'Invalid view: %s' % view)

    torrents = {}
    for target in targets:
        if user == None and USE_AUTH:
            continue
        if user and (target['name'] not in user.targets):
            continue

        try:
            t = TorrentRequester(target, view)

            t.get_name().get_download_rate().get_upload_rate() \
                    .is_complete().get_size_bytes().get_download_total().get_hash()

            torrents[target['name']] = t.all()

        except InvalidTorrentException, e:
            return error_page(env, str(e))
예제 #2
0
def handle_api_method(env, method, keys):
    if method not in known_methods:
        raise Exception('Unknown method')

    if 'target' in keys:
        target = k['target']
        target = lookup_target(target)
        if target is None:
            print 'Returning null, target is invalid'
            return None

    u = fetch_user(env)
    # User can't be none, since we've already passed login.
    if USE_AUTH and target not in user.targets:
        print 'User is not allowed to use target: %s!' % target


    if method == 'torrentrequester':
        return known_methods[method](keys, target)
    else:
        return known_methods[method](keys, method, target)