Skip to content

Commit

Permalink
Raise for status in more places
Browse files Browse the repository at this point in the history
  • Loading branch information
J535D165 committed Jun 24, 2024
1 parent 9abbe92 commit 58baba1
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions datahugger/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ def download_file(
if not self.print_only:
logging.info(f"Downloading file {file_link}")
res = requests.get(file_link, stream=True)
res.raise_for_status()

output_fp = Path(output_folder, file_name)
Path(output_fp).parent.mkdir(parents=True, exist_ok=True)
Expand Down Expand Up @@ -199,6 +200,8 @@ def _parse_url(self, url):

def _unpack_single_folder(self, zip_url, output_folder):
r = requests.get(zip_url)
r.raise_for_status()

z = zipfile.ZipFile(io.BytesIO(r.content))

for zip_info in z.infolist():
Expand Down Expand Up @@ -287,6 +290,7 @@ def _get_files_recursive(self, url, folder_name=None, base_url=None):

# get the data from URL
res = requests.get(url)
res.raise_for_status()
response = res.json()

# find path to raw files
Expand Down

0 comments on commit 58baba1

Please sign in to comment.