Beispiel #1
0
    def getAllPackages(self, root=None, owner=None, tags=None):
        """ Return dict with package information

        :param root: optional root to filter
        :param owner: optional user id
        :param tags: optional tag list
        """
        qry = ('SELECT pid, name, folder, root, owner, site, comment, password, added, tags, status, packageorder '
               'FROM packages%s ORDER BY root, packageorder')

        if root is None:
            stats = self.getPackageStats(owner=owner)
            if owner is None:
                self.c.execute(qry % "")
            else:
                self.c.execute(qry % " WHERE owner=?", (owner,))
        else:
            stats = self.getPackageStats(root=root, owner=owner)
            if owner is None:
                self.c.execute(qry % ' WHERE root=? OR pid=?', (root, root))
            else:
                self.c.execute(qry % ' WHERE (root=? OR pid=?) AND owner=?', (root, root, owner))

        data = OrderedDict()
        for r in self.c:
            data[r[0]] = PackageInfo(
                r[0], r[1], r[2], r[3], r[4], r[5], r[6], r[7], r[8], r[9].split(","), r[10], r[11], stats.get(r[0], zero_stats)
            )

        return data
Beispiel #2
0
    def __init__(self, core):
        self.lock = Lock()
        self.core = core
        self.tasks = OrderedDict()  #task store, for all outgoing tasks

        self.last_clients = {}
        self.ids = 0  #uniue interaction ids
Beispiel #3
0
    def addConfigSection(self, section, name, desc, long_desc, config, base=False):
        """Adds a section to the config. `config` is a list of config tuples as used in plugin api defined as:
        Either (name, type, verbose_name, default_value) or
                (name, type, verbose_name, short_description, default_value)
        The order of the config elements is preserved with OrderedDict
        """
        d = OrderedDict()

        for entry in config:
            if len(entry) == 5:
                conf_name, type, conf_desc, conf_verbose, default = entry
            else: # config options without tooltip / description
                conf_name, type, conf_desc, default = entry
                conf_verbose = ""

            d[conf_name] = ConfigData(gettext(conf_desc), type, gettext(conf_verbose), from_string(default, type))

        if base:
            if section not in self.baseSections: self.baseSections.append(section)
        elif section in self.baseSections:
            return # would overwrite base section

        data = SectionTuple(gettext(name), gettext(desc), gettext(long_desc), d)
        self.config[section] = data

        if section not in self.values:
            self.values[section] = {}
Beispiel #4
0
    def addConfigSection(self, section, label, desc, expl, config):
        """Adds a section to the config. `config` is a list of config tuple as used in plugin api defined as:
        The order of the config elements is preserved with OrderedDict
        """
        d = OrderedDict()

        for entry in config:
            name, data = to_configdata(entry)
            d[name] = data

        data = SectionTuple(gettext(label), gettext(desc), gettext(expl), d)
        self.config[section] = data
Beispiel #5
0
    def __init__(self, config=None):

        if config: self.CONFIG = config

        # Meta data information
        self.config = OrderedDict()
        # The actual config values
        self.values = {}

        self.checkVersion()

        self.loadDefault()
        self.parseValues(self.CONFIG)
Beispiel #6
0
    def __init__(self, core):
        self.lock = Lock()
        self.core = core
        self.tasks = OrderedDict()  #task store, for outgoing tasks only
        self.notifications = []  #list of notifications

        self.last_clients = {
            Output.Notification: 0,
            Output.Captcha: 0,
            Output.Query: 0,
        }

        self.ids = 0  #only for internal purpose
Beispiel #7
0
    def __init__(self, core, parser):
        # No __init__ call to super class is needed!

        self.core = core
        self.db = core.db
        # The config parser, holding the core config
        self.parser = parser

        # similar to parser, separated meta data and values
        self.config = OrderedDict()

        # Value cache for multiple user configs
        # Values are populated from db on first access
        # Entries are saved as (user, section) keys
        self.values = {}
Beispiel #8
0
def get_system_info():
    """ Returns system information as dict """
    global info

    if info is None:
        import platform

        info = OrderedDict([
            (_("Platform"), platform.platform()),
            (_("Version"), sys.version),
            (_("Path"), os.path.abspath("")),
            (_("Encoding"), sys.getdefaultencoding()),
            (_("FS-Encoding"), sys.getfilesystemencoding())
        ])

    return info
Beispiel #9
0
    def __init__(self):
        """Constructor"""

        # core config sections from pyload
        self.baseSections = []

        # Meta data information
        self.config = OrderedDict()
        # The actual config values
        self.values = {}

        self.changeCB = None # callback when config value was changed

        self.checkVersion()

        self.loadDefault()
        self.parseValues(self.CONFIG)
Beispiel #10
0
    def getAllFiles(self, package=None, search=None, state=None, owner=None):
        """ Return dict with file information

        :param package: optional package to filter out
        :param search: or search string for file name
        :param unfinished: filter by dlstatus not finished
        :param owner: only specific owner
        """
        qry = (
            'SELECT fid, name, owner, size, status, media, added, fileorder, '
            'url, plugin, hash, dlstatus, error, package FROM files WHERE ')

        arg = []

        if state is not None and state != DS.All:
            qry += 'dlstatus IN (%s) AND ' % state_string(state)
        if owner is not None:
            qry += 'owner=? AND '
            arg.append(owner)

        if package is not None:
            arg.append(package)
            qry += 'package=? AND '
        if search is not None:
            search = "%%%s%%" % search.strip("%")
            arg.append(search)
            qry += "name LIKE ? "

        # make qry valid
        if qry.endswith("WHERE "): qry = qry[:-6]
        if qry.endswith("AND "): qry = qry[:-4]

        self.c.execute(qry + "ORDER BY package, fileorder", arg)

        data = OrderedDict()
        for r in self.c:
            f = FileInfo(r[0], r[1], r[13], r[2], r[3], r[4], r[5], r[6], r[7])
            if r[11] > 0:  # dl status != NA
                f.download = DownloadInfo(r[8], r[9], r[10], r[11],
                                          self.manager.statusMsg[r[11]], r[12])

            data[r[0]] = f

        return data
Beispiel #11
0
    def addConfigSection(self, section, name, desc, long_desc, config):
        """Adds a section to the config. `config` is a list of config tuples as used in plugin api defined as:
        The order of the config elements is preserved with OrderedDict
        """
        d = OrderedDict()

        for entry in config:
            if len(entry) == 5:
                conf_name, type, conf_desc, conf_verbose, default = entry
            else:  # config options without description
                conf_name, type, conf_desc, default = entry
                conf_verbose = ""

            d[conf_name] = ConfigData(gettext(conf_desc), type,
                                      gettext(conf_verbose),
                                      from_string(default, type))

        data = SectionTuple(gettext(name), gettext(desc), gettext(long_desc),
                            d)
        self.config[section] = data