Beispiel #1
0
def _verify_file_hash(path, sha256):
    actual = util.file_sha256(path, use_cache=True)
    if actual != sha256:
        raise ResolutionError(
            "'%s' has an unexpected sha256 (expected %s but got %s)"
            % (path, sha256, actual)
        )
Beispiel #2
0
 def _verify_file_hash(self, path, sha256):
     actual = util.file_sha256(path)
     if actual != sha256:
         raise DependencyError(
             "'%s' required by operation '%s' has an unexpected sha256 "
             "(expected %s but got %s)"
             % (path, self.ctx.opdef.fullname, sha256, actual))
Beispiel #3
0
def main(args):
    resdef = resourcedef.ResourceDef("download", {})
    source = resourcedef.ResourceSource(resdef, args.url)
    download_dir = resolver.url_source_download_dir(source)
    util.ensure_dir(download_dir)
    try:
        source_path = pip_util.download_url(source.uri, download_dir)
    except Exception as e:
        _handle_download_error(e, source)
    else:
        sha256 = util.file_sha256(source_path, use_cache=False)
        print("{}  {}".format(sha256, source_path))
Beispiel #4
0
def _verify_and_cache_hash(path, expected_hash):
    calculated_hash = util.file_sha256(path)
    if calculated_hash != expected_hash:
        raise HashMismatch(path, expected_hash, calculated_hash)
    _cache_sha256(calculated_hash, path)