How to use the pyp2rpm.exceptions.NoSuchPackageException function in pyp2rpm

To help you get started, we’ve selected a few pyp2rpm examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github fedora-python / pyp2rpm / tests / test_package_getters.py View on Github external
def test_init_bad_data(self, name, version):
        with pytest.raises(NoSuchPackageException):
            PypiDownloader(self.client, name, version)
github fedora-python / pyp2rpm / tests / test_convertor.py View on Github external
        ('eggs', NoSuchPackageException),
        ('/spam/beans/eggs/ham', NoSuchPackageException)
    ])
    def test_getter_bad_data(self, sf, expected):
        with pytest.raises(expected):
            c = Convertor(package=sf)
            c.getter
github fedora-python / pyp2rpm / pyp2rpm / convertor.py View on Github external
def convert(self):
        """Returns RPM SPECFILE.
        Returns:
            rendered RPM SPECFILE.
        """
        # move file into position
        try:
            local_file = self.getter.get()
        except (exceptions.NoSuchPackageException, OSError) as e:
            logger.error(
                "Failed and exiting:", exc_info=True)
            logger.info("Pyp2rpm failed. See log for more info.")

            sys.exit(e)

        # save name and version from the file (rewrite if set previously)
        self.name, self.version = self.getter.get_name_version()

        self.local_file = local_file
        data = self.metadata_extractor.extract_data(self.client)
        logger.debug("Extracted metadata:")
        logger.debug(pprint.pformat(data.data))
        self.merge_versions(data)

        jinja_env = jinja2.Environment(loader=jinja2.ChoiceLoader([
github fedora-python / pyp2rpm / pyp2rpm / package_getters.py View on Github external
self.client = client
        self.name = name
        try:
            self.versions = self.client.package_releases(self.name, True)
        except xmlrpclib.ProtocolError as e:
            sys.stderr.write("Failed to connect to server: {0} \n".format(e))
            raise SystemExit(3)

        # Use only stable versions, unless --pre was specified
        if not prerelease:
            self.versions = [candidate for candidate in self.versions
                             if not parse_version(candidate).is_prerelease]

        # If versions is empty list then there is no such package on PyPI
        if not self.versions:
            raise exceptions.NoSuchPackageException(
                'Package "{0}" could not be found on PyPI.'.format(name))

        self.version = version or self.versions[0]

        # if version is specified, will check if such version exists
        if version and self.client.release_urls(name, version) == []:
            raise exceptions.NoSuchPackageException(
                'Package with name "{0}" and version "{1}" could not be '
                'found on PyPI.'.format(name, version))
        self.save_dir_init(save_dir)
github fedora-python / pyp2rpm / pyp2rpm / package_getters.py View on Github external
# Use only stable versions, unless --pre was specified
        if not prerelease:
            self.versions = [candidate for candidate in self.versions
                             if not parse_version(candidate).is_prerelease]

        # If versions is empty list then there is no such package on PyPI
        if not self.versions:
            raise exceptions.NoSuchPackageException(
                'Package "{0}" could not be found on PyPI.'.format(name))

        self.version = version or self.versions[0]

        # if version is specified, will check if such version exists
        if version and self.client.release_urls(name, version) == []:
            raise exceptions.NoSuchPackageException(
                'Package with name "{0}" and version "{1}" could not be '
                'found on PyPI.'.format(name, version))
        self.save_dir_init(save_dir)