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))
def handle_torrentrequester(k, target): if 'view' not in k or 'attributes' not in k: return None view = k['view'] attributes = k['attributes'] try: tr = TorrentRequester(target, view) for method, args in attributes: getattr(tr, method) return tr.all() except (InvalidTorrentCommandException,): return None
def handle_torrentrequester(k, target): if 'view' not in k or 'attributes' not in k: return None view = k['view'] attributes = k['attributes'] try: tr = TorrentRequester(target, view) for method, args in attributes: getattr(tr, method) h = hash(tr) r = cache.get(h) if r is None: r = tr.all() cache.set(h, r, timeout=CACHE_TIMEOUT) return r except (InvalidTorrentCommandException, ): return None
def handle_torrentrequester(k, target): if 'view' not in k or 'attributes' not in k: return None view = k['view'] attributes = k['attributes'] try: tr = TorrentRequester(target, view) for method, args in attributes: getattr(tr, method) h = hash(tr) r = cache.get(h) if r is None: r = tr.all() cache.set(h, r, timeout=CACHE_TIMEOUT) return r except (InvalidTorrentCommandException,): return None
def main_view_page(view='default'): rtorrent_data = fetch_global_info() # if view not in rtorrent_data.get_view_list: # return error_page(env, 'Invalid view: %s' % view) torrents = {} for target in targets: if g.user == None and USE_AUTH: continue if g.user and (target['name'] not in g.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() h = hash(t) torrents[target['name']] = cache.get(h) if torrents[target['name']]: continue torrents[target['name']] = cache.get(target['name']) if torrents[target['name']] is not None: continue torrents[target['name']] = t.all() cache.set(h, torrents[target['name']], timeout=CACHE_TIMEOUT) except InvalidTorrentException, e: return error_page(env, str(e))