Skip to content

Commit c0abca0

Browse files
authored
Raise status when downloading fails (#80)
1 parent 7ce04e8 commit c0abca0

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

datahugger/base.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ def download_file(
161161
if not self.print_only:
162162
logging.info(f"Downloading file {file_link}")
163163
res = requests.get(file_link, stream=True)
164+
res.raise_for_status()
164165

165166
output_fp = Path(output_folder, file_name)
166167
Path(output_fp).parent.mkdir(parents=True, exist_ok=True)
@@ -198,6 +199,8 @@ def _parse_url(self, url):
198199

199200
def _unpack_single_folder(self, zip_url, output_folder):
200201
r = requests.get(zip_url)
202+
r.raise_for_status()
203+
201204
z = zipfile.ZipFile(io.BytesIO(r.content))
202205

203206
for zip_info in z.infolist():
@@ -284,6 +287,7 @@ def _get_files_recursive(self, url, folder_name=None, base_url=None):
284287

285288
# get the data from URL
286289
res = requests.get(url)
290+
res.raise_for_status()
287291
response = res.json()
288292

289293
# find path to raw files

tests/test_repositories.toml

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ location = "https://doi.org/10.7910/DVN/KBHLOD"
3535
files = "tutorial1.py"
3636

3737
[[dataverse]]
38-
location = "https://hdl.handle.net/10622/NHJZUD"
39-
files = "ERRHS_7_01_data_1795.tab"
38+
location = "https://hdl.handle.net/10622/6IWVTB"
39+
files = "Micro_Ethiopia_1941-2018.xlsx"
4040

4141
[[figshare]]
4242
location = "https://doi.org/10.6084/m9.figshare.8851784.v1"
@@ -86,9 +86,17 @@ files = "READMI Stranding Sea Turtle records.pdf"
8686
location = "https://doi.org/10.18739/A2KH0DZ42"
8787
files = "2012F_Temperature_Data.csv"
8888

89-
[[dspace]]
90-
location = "https://uhra.herts.ac.uk/handle/2299/26087"
91-
files = "pdf.pdf"
89+
# [[dspace]]
90+
# location = "https://doi.org/10.17863/CAM.111909"
91+
# files = "README.md"
92+
93+
# [[dspace]]
94+
# location = "https://uhra.herts.ac.uk/handle/2299/26087"
95+
# files = "pdf.pdf"
96+
97+
# [[dspace]]
98+
# location = "http://dx.doi.org/10.21994/loar8554"
99+
# files = "terms_and_conditions_for_the_use_of_open_geographic_data.pdf"
92100

93101
[[dspace]]
94102
location = "https://repositorioinstitucional.ceu.es/handle/10637/2741"

0 commit comments

Comments
 (0)