Exemple #1
0
    def get_remote(self, repo_id=None, cache=False):
        if not repo_id:
            repo_id = self._def_repo_id()
        if cache and repo_id in self.__cache:
            log.debug("Using cached results for %s", repo_id)
            return self.__cache.get(repo_id)

        log.debug("Retrieving available plugins from repo %s", repo_id)

        p = pbi.PBI()
        p.pbid(flags=pbi.PBID_FLAGS_REFRESH, sync=True)

        results = p.browser(repo_id=repo_id, flags=pbi.PBI_BROWSER_FLAGS_VIEWALL)
        if not results:
            log.debug(
                "No results returned for repo %s", repo_id
            )
            return results

        plugins = []
	results.sort(key=lambda x: x['Application'].lower())

        for p in results:
            try:
                index_entry = self.get_index_entry(
                    repo_id,
                    application=p['Application'],
                    arch=p['Arch'],
                    version=p['Version']
                )
                if not index_entry:
                    log.debug("not index entry found for %s", p['Application'])
                    continue

                urls = self.get_mirror_urls(repo_id)

                item = self._get_remote_item(repo_id, p, index_entry, urls)
                if item is False:
                    log.debug("unable to create plugin for %s", p['Application'])
                    continue

                plugins.append(item)
            except Exception as e:
                log.debug("Failed to get remote item: %s", e)

        self.__cache[repo_id] = plugins
        return plugins
Exemple #2
0
    def get_remote(self, repo_id=None, cache=False):
        if not repo_id:
            repo_id = self._def_repo_id()
        if cache and repo_id in self.__cache:
            log.debug("Using cached results for %s", repo_id)
            return self.__cache.get(repo_id)

        log.debug("Retrieving available plugins from repo %s", repo_id)

        p = pbi.PBI()
        p.pbid(flags=pbi.PBID_FLAGS_REFRESH, sync=True)

        results = p.browser(repo_id=repo_id,
                            flags=pbi.PBI_BROWSER_FLAGS_VIEWALL)
        if not results:
            log.debug("No results returned for repo %s", repo_id)
            return results

        plugins = []
        results.sort(key=lambda x: x['Application'].lower())

        for p in results:
            try:
                index_entry = self.get_index_entry(
                    repo_id,
                    application=p['Application'],
                    arch=p['Arch'],
                    version=p['Version'])
                if not index_entry:
                    log.debug("not index entry found for %s", p['Application'])
                    continue

                urls = self.get_mirror_urls(repo_id)

                item = self._get_remote_item(repo_id, p, index_entry, urls)
                if item is False:
                    log.debug("unable to create plugin for %s",
                              p['Application'])
                    continue

                plugins.append(item)
            except Exception as e:
                log.debug("Failed to get remote item: %s", e)

        self.__cache[repo_id] = plugins
        return plugins