Skip to content

Commit

Permalink
dont hardcode the hash
Browse files Browse the repository at this point in the history
  • Loading branch information
paulacamargo25 committed Oct 18, 2023
1 parent b436f0b commit 9070859
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,15 @@ def install_bundled_libs(session):
download_url(debugpy_info["any"])


def download_url(value, hash_algorithm="sha256"):
def download_url(value):
with url_lib.urlopen(value["url"]) as response:
data = response.read()
if (
hashlib.new(hash_algorithm, data).hexdigest()
!= value["hash"][hash_algorithm]
):
hash_algorithm, hash_value = [
(key, value) for key, value in value["hash"].items()
][0]
if hashlib.new(hash_algorithm, data).hexdigest() != hash_value:
raise ValueError("Failed hash verification for {}.".format(value["url"]))

print("Download: ", value["url"])
with zipfile.ZipFile(io.BytesIO(data), "r") as wheel:
libs_dir = pathlib.Path.cwd() / "bundled" / "libs"
Expand Down

0 comments on commit 9070859

Please sign in to comment.