Skip to content

Commit

Permalink
Merge branch 'master' into object-v0-bis
Browse files Browse the repository at this point in the history
  • Loading branch information
n1k0 committed Sep 26, 2024
2 parents fc91c61 + 1f68b23 commit ea461bd
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions bin/download_github_releases.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,12 @@ def download_file(url, destination_directory=None):
logger.debug(f"-> Downloading {url} to {local_filename}")

with requests.get(url, stream=True) as r:
with open(local_filename, "wb") as f:
shutil.copyfileobj(r.raw, f)
if r.status_code == 200:
with open(local_filename, "wb") as f:
shutil.copyfileobj(r.raw, f)
else:
logger.error(f"Status: {r.status_code}, body: {r.text}")
return None

return local_filename

Expand Down Expand Up @@ -68,13 +72,24 @@ def download_file(url, destination_directory=None):
nb_releases_extracted = 0
for release in releases:
if release.tag_name is None:
logger.info("Skipping release without a tag.")
continue

if release.draft:
logger.info("Skipping draft release.")
continue

for asset in release.assets:
if "-dist.tar.gz" in asset.browser_download_url:
file_path = download_file(
asset.browser_download_url, args.destination_directory
)
if not file_path:
logger.error(
f"Error downloading {asset.browser_download_url}, skipping."
)
continue

# 'dist' is the name of the directory contained in the archive
unpacked_destination_directory = os.path.join(
args.destination_directory, "dist"
Expand Down

0 comments on commit ea461bd

Please sign in to comment.