mirror of
https://github.com/SheffieldML/GPy.git
synced 2026-06-05 14:55:15 +02:00
Added some more error checking for downloading datasets.
This commit is contained in:
parent
e349c12cf0
commit
4a751fd2da
1 changed files with 5 additions and 2 deletions
|
|
@ -87,8 +87,11 @@ def download_url(url, store_directory, save_name = None, messages = True, suffix
|
||||||
if not hasattr(e, "code"):
|
if not hasattr(e, "code"):
|
||||||
raise
|
raise
|
||||||
response = e
|
response = e
|
||||||
if response.code == 404:
|
if response.code > 399 and response.code<500:
|
||||||
raise ValueError('Url ' + url + suffix + ' 404 not found.')
|
raise ValueError('Tried url ' + url + suffix + ' and received client error ' + str(response.code))
|
||||||
|
elif response.code > 499:
|
||||||
|
raise ValueError('Tried url ' + url + suffix + ' and received server error ' + str(response.code))
|
||||||
|
# if we wanted to get more sophisticated maybe we should check the response code here again even for successes.
|
||||||
with open(save_name, 'wb') as f:
|
with open(save_name, 'wb') as f:
|
||||||
f.write(response.read())
|
f.write(response.read())
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue