Exemplo n.º 1
0
 def _vote_order():
     ugc = None
     try:
         ugc = self._ugc(https=False)
         key_sorter = lambda x: ugc.get_ugc_download(
             entropy_dep.dep_getkey(x[5].retrieveAtom(x[0])))
         return sorted(pkgs_data, key = key_sorter, reverse = True)
     except ServiceConnectionError:
         return []
     finally:
         if ugc is not None:
             ugc.disconnect()
             del ugc
Exemplo n.º 2
0
    def _get_api_package_basic_info(self, entropy_repository, ugc, package_id,
        repository_id, arch, branch, product):
        """
        Internal method. Return a dict containing all the basic info of a
        package.
        atom, key, name, category, branch, description, revision
        package_id, repository_id, vote, downloads, number of documents,
        arch, product.
        NOTE: can return None!
        """
        base_data = entropy_repository.getBaseData(package_id)
        if base_data is None:
            return None
        atom, name, version, tag, desc, cat, chost, cflags, cxxflags, \
            homepage, license, branch, download, digest, slot, api, \
            date, size, rev = base_data
        pkg_key = entropy_dep.dep_getkey(atom)

        has_more, docs = ugc.get_ugc_metadata_doctypes(pkg_key,
            [ugc.DOC_TYPES[x] for x in ugc.DOC_TYPES])

        pkg_data = {
            'atom': atom,
            'key': pkg_key,
            'slot': slot,
            'name': name,
            'category': cat,
            'branch': branch,
            'description': desc,
            'repository_id': repository_id,
            'arch': arch,
            'product': product,
            'package_id': package_id,
            'vote': round(ugc.get_ugc_vote(pkg_key), 2),
            'downloads': ugc.get_ugc_download(pkg_key),
            'docs_number': len(docs),
            'has_more_docs': has_more,
        }
        return pkg_data
Exemplo n.º 3
0
    def _get_api_package_detailed_info(self, entropy_repository,
                                       ugc, package_id,
        repository_id, arch, branch, product):
        """
        Internal method. Return a dict containing all the detailed info of a
        package. See below.
        NOTE: can return None!
        """
        base_data = entropy_repository.getBaseData(package_id)
        if base_data is None:
            return None
        atom, name, version, tag, desc, cat, chost, cflags, cxxflags, \
            homepage, license, branch, download, digest, slot, api, \
            date, size, rev = base_data
        if size is None:
            size = "0b"
        else:
            size = entropy_tools.bytes_into_human(size)
        on_disk_size = entropy_repository.retrieveOnDiskSize(package_id)
        pkg_key = entropy_dep.dep_getkey(atom)
        t_time = float(date)
        has_more, docs = ugc.get_ugc_metadata_doctypes(pkg_key,
                [ugc.DOC_TYPES[x] for x in ugc.DOC_TYPES])

        pkg_data = {
            'version': version,
            'revision': rev,
            'homepage': homepage,
            'size': size,
            'md5': digest,
            'api': api,
            'date': date,
            'download': download,
            'cflags': cflags,
            'chost': chost,
            'cxxflags': cxxflags,
            'license': license.split(),
            'tag': tag,
            'ondisksize': entropy_tools.bytes_into_human(on_disk_size),
            'use': sorted(entropy_repository.retrieveUseflags(package_id)),
            'date': entropy_tools.convert_unix_time_to_human_time(t_time),
            'time': t_time,
            'repository_id': repository_id,
            'arch': arch,
            'product': product,
            'package_id': package_id,
            'docs': docs,
            'has_more_docs': has_more,
        }
        for mydoc in pkg_data['docs']:
            self._expand_ugc_doc_metadata(ugc, mydoc)

        dependencies = entropy_repository.retrieveDependencies(package_id,
            extended = True)
        pkg_data['build_deps'] = sorted([x for x, y in dependencies if y == \
            etpConst['dependency_type_ids']['bdepend_id']])
        pkg_data['run_deps'] = sorted([x for x, y in dependencies if y == \
            etpConst['dependency_type_ids']['rdepend_id']])
        pkg_data['post_deps'] = sorted([x for x, y in dependencies if y == \
            etpConst['dependency_type_ids']['pdepend_id']])
        pkg_data['manual_deps'] = sorted([x for x, y in dependencies if y == \
            etpConst['dependency_type_ids']['mdepend_id']])
        pkg_data['conflicts'] = sorted(
            entropy_repository.retrieveConflicts(package_id))

        pkg_data['sha1'], pkg_data['sha256'], pkg_data['sha512'], \
            pkg_data['gpg'] = entropy_repository.retrieveSignatures(
            package_id)

        return pkg_data