Skip to content

Commit

Permalink
Remove wget
Browse files Browse the repository at this point in the history
  • Loading branch information
pmitros committed Jul 14, 2024
1 parent 236ff7c commit ea049d1
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions learning_observer/learning_observer/prestartup.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import hashlib
import os
import os.path
import requests
import shutil
import sys
import uuid
Expand Down Expand Up @@ -147,10 +148,16 @@ def format_hash(hash_string):
# For subdirectories, make them
os.makedirs(os.path.dirname(filename), exist_ok=True)
if not os.path.exists(filename):
os.system("wget {url} -O {filename} 2> /dev/null".format(
url=url,
filename=filename
))
# TODO: For larger downloads, we might want to set
# stream=True and use iter_content instead
response = requests.get(url)
if response.status_code == 200:
with open(filename, 'wb') as file:
file.write(response.content)
print("Downloaded {name}".format(name=name))
else:
print("Failed to download file")

print("Downloaded {name}".format(name=name))
shahash = hashlib.sha3_512(open(filename, "rb").read()).hexdigest()
if shahash not in hashes:
Expand Down

0 comments on commit ea049d1

Please sign in to comment.