def url(url_string): url = urlparse(url_string) if url.scheme not in ALLOWED_SCHEMES: tty.die("Invalid protocol in URL: '%s'" % url_string) if not allowed_archive(url_string): tty.die("Invalid file type in URL: '%s'" % url_string)
def validate_package_url(url_string): """Determine whether spack can handle a particular URL or not.""" url = urlparse(url_string) if url.scheme not in _ALLOWED_URL_SCHEMES: tty.die("Invalid protocol in URL: '%s'" % url_string) if not allowed_archive(url_string): tty.die("Invalid file type in URL: '%s'" % url_string)
def suggest_archive_basename(resource): """Return a tentative basename for an archive. Raises: RuntimeError: if the name is not an allowed archive type. """ basename = os.path.basename(resource.fetcher.url) if not allowed_archive(basename): raise RuntimeError("%s is not an allowed archive tye" % basename) return basename
def suggest_archive_basename(resource): """ Return a tentative basename for an archive. Raise an exception if the name is among the allowed archive types. :param fetcher: :return: """ basename = os.path.basename(resource.fetcher.url) if not allowed_archive(basename): raise RuntimeError("%s is not an allowed archive tye" % basename) return basename
def __init__(self, path_or_url, level, working_dir, **kwargs): super(UrlPatch, self).__init__(path_or_url, level, working_dir) self.url = path_or_url self.archive_sha256 = None if allowed_archive(self.url): if 'archive_sha256' not in kwargs: raise PatchDirectiveError( "Compressed patches require 'archive_sha256' " "and patch 'sha256' attributes: %s" % self.url) self.archive_sha256 = kwargs.get('archive_sha256') if 'sha256' not in kwargs: raise PatchDirectiveError("URL patches require a sha256 checksum") self.sha256 = kwargs.get('sha256')
def __init__(self, pkg, url, level=1, working_dir='.', ordering_key=None, **kwargs): super(UrlPatch, self).__init__(pkg, url, level, working_dir) self.url = url self.ordering_key = ordering_key self.archive_sha256 = kwargs.get('archive_sha256') if allowed_archive(self.url) and not self.archive_sha256: raise PatchDirectiveError( "Compressed patches require 'archive_sha256' " "and patch 'sha256' attributes: %s" % self.url) self.sha256 = kwargs.get('sha256') if not self.sha256: raise PatchDirectiveError("URL patches require a sha256 checksum")
def test_allowed_archvie(path): assert scomp.allowed_archive(path)