def get_all_links(self, q): """ Return information about all links in queue q q0 queue q1 collector format: { id: {'name': name, ... 'package': id }, ... } """ self.c.execute( "SELECT l.id, l.url, l.name, l.size, l.status, l.error, l.plugin, l.package, l.linkorder FROM links as l INNER JOIN packages as p ON l.package=p.id WHERE p.queue=? ORDER BY l.linkorder", (q,), ) data = {} for r in self.c: data[r[0]] = { "id": r[0], "url": r[1], "name": r[2], "size": r[3], "format_size": format_size(r[3]), "status": r[4], "statusmsg": self.manager.statusMsg[r[4]], "error": r[5], "plugin": tuple(r[6].split(".")), "package": r[7], "order": r[8], } return data
def config(): conf = API.get_config() plugin = API.get_plugin_config() conf_menu = [] plugin_menu = [] for entry in sorted(conf.keys()): conf_menu.append((entry, conf[entry].description)) last_name = None for entry in sorted(plugin.keys()): desc = plugin[entry].description name, none, type = desc.partition("_") if type in API.pyload.pluginManager.TYPES: if name == last_name or len([a for a, b in plugin.iteritems() if b.description.startswith(name + "_")]) > 1: desc = name + " (" + type.title() + ")" else: desc = name last_name = name plugin_menu.append((entry, desc)) accs = API.get_accounts(False) for data in accs: if data.trafficleft == -1: data.trafficleft = _("unlimited") elif not data.trafficleft: data.trafficleft = _("not available") else: data.trafficleft = format_size(data.trafficleft) if data.validuntil == -1: data.validuntil = _("unlimited") elif not data.validuntil: data.validuntil = _("not available") else: t = time.localtime(data.validuntil) data.validuntil = time.strftime("%d.%m.%Y - %H:%M:%S", t) try: data.options['time'] = data.options['time'][0] except Exception: data.options['time'] = "0:00-0:00" if "limitDL" in data.options: data.options['limitdl'] = data.options['limitDL'][0] else: data.options['limitdl'] = "0" return render_to_response('settings.html', {'conf': {'plugin': plugin_menu, 'general': conf_menu, 'accs': accs}, 'types': API.get_account_types()}, [pre_processor])
def info(): conf = API.get_config_dict() extra = os.uname() if hasattr(os, "uname") else tuple() data = {"python" : sys.version, "os" : " ".join((os.name, sys.platform) + extra), "version" : API.get_server_version(), "folder" : os.path.abspath(PYLOAD_DIR), "config": os.path.abspath(""), "download" : os.path.abspath(conf['general']['download_folder']['value']), "freespace": format_size(API.free_space()), "remote" : conf['remote']['port']['value'], "webif" : conf['webui']['port']['value'], "language" : conf['general']['language']['value']} return render_to_response("info.html", data, [pre_processor])
def get_package_data(self, id): """Get data about links for a package""" self.c.execute( "SELECT id, url, name, size, status, error, plugin, package, linkorder FROM links WHERE package=? ORDER BY linkorder", (str(id),), ) data = {} for r in self.c: data[r[0]] = { "id": r[0], "url": r[1], "name": r[2], "size": r[3], "format_size": format_size(r[3]), "status": r[4], "statusmsg": self.manager.statusMsg[r[4]], "error": r[5], "plugin": tuple(r[6].split(".")), "package": r[7], "order": r[8], } return data
def get_link_data(self, id): """Get link information as dict""" self.c.execute( "SELECT id, url, name, size, status, error, plugin, package, linkorder FROM links WHERE id=?", (str(id),) ) data = {} r = self.c.fetchone() if not r: return None data[r[0]] = { "id": r[0], "url": r[1], "name": r[2], "size": r[3], "format_size": format_size(r[3]), "status": r[4], "statusmsg": self.manager.statusMsg[r[4]], "error": r[5], "plugin": tuple(r[6].split(".")), "package": r[7], "order": r[8], } return data
def format_size(self): """Formats size to readable format""" return format_size(self.get_size())