예제 #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)
        )
예제 #2
0
파일: deps.py 프로젝트: pombredanne/guild
 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))
예제 #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))
예제 #4
0
파일: pip_util.py 프로젝트: yuanbw/guildai
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)