def __init__(self, client, name, version=None, save_dir=None): self.client = client self.name = name self.versions = self.client.package_releases(self.name) if not self.versions: # If versions is empty list then there is no such package on PyPI raise exceptions.NoSuchPackageException( 'Package "{0}" could not be found on PyPI.'.format(name)) logger.error('Package "{0}" could not be found on PyPI.'.format(name)) self.version = version or self.versions[0] if version and self.client.release_urls(name, version) == []: # if version is specified, will check if such version exists raise exceptions.NoSuchPackageException( 'Package with name "{0}" and version "{1}" could not be found on PyPI.'.format(name, version)) logger.error('Package with name "{0}" and version "{1}" could not be found on PyPI.'.format(name, version)) self.save_dir = save_dir or settings.DEFAULT_PKG_SAVE_PATH if self.save_dir == settings.DEFAULT_PKG_SAVE_PATH: self.save_dir += '/SOURCES' if not os.path.exists(self.save_dir): if self.save_dir != (settings.DEFAULT_PKG_SAVE_PATH + '/SOURCES'): os.makedirs(self.save_dir) else: try: subprocess.Popen( 'rpmdev-setuptree', stdout=subprocess.PIPE) logger.info('Using rpmdevtools package to make rpmbuild folders tree.') except OSError: self.save_dir = '/tmp' # pyp2rpm can work without rpmdevtools logger.warn('Package rpmdevtools is missing , using default folder: {0} to store {1}.'.format( self.save_dir, self.name)) logger.warn('Specify folder to store a file (SAVE_DIR) or install rpmdevtools.') logger.info('Using {0} as directory to save source.'.format(self.save_dir))
def __init__(self, client, name, version=None, prerelease=False, save_dir=None): 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)
def __init__(self, client, name, version=None, save_dir=None): self.client = client self.name = name try: self.versions = self.client.package_releases(self.name) except xmlrpclib.ProtocolError as e: sys.stderr.write("Failed to connect to server: {0} \n".format(e)) raise SystemExit(3) if not self.versions: # If versions is empty list then there is no such package on PyPI raise exceptions.NoSuchPackageException( 'Package "{0}" could not be found on PyPI.'.format(name)) logger.error( '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)) logger.error( 'Package with name "{0}" and version "{1}" could not be found on PyPI.' .format(name, version)) self.save_dir_init(save_dir)
def __init__(self, client, name, version=None, save_dir=None): self.client = client self.name = name try: self.version = version or self.client.package_releases( self.name)[0] except IndexError: # no such package raise exceptions.NoSuchPackageException( 'Package "{0}" could not be found on PyPI.'.format(name)) if version and self.client.release_urls( name, version ) == []: # if version is specified, will check if such version exists raise exceptions.NoSuchPackageException( 'Package with name "{0}" and version "{1}" could not be found on PyPI' .format(name, version)) self.save_dir = save_dir or settings.DEFAULT_PKG_SAVE_PATH