Skip to content

Commit cda6709

Browse files
committed
Adding a warning when trying to download data (but no unbeaching information is provided)
1 parent 756b2d6 commit cda6709

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

plasticparcels/utils.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import json
88
from pathlib import Path
99
from urllib.request import urlretrieve
10+
import warnings
1011

1112

1213
def getclosest_ij(lats, lons, latpt, lonpt):
@@ -158,9 +159,11 @@ def download_plasticparcels_dataset(dataset: str, settings, data_home=None):
158159

159160
for settings_path, filename in plasticparcels_data_files[dataset]:
160161
filepath = os.path.join(dataset_folder, filename)
161-
settings[settings_path[0]][settings_path[1]] = filepath
162-
if not os.path.exists(filepath):
163-
url = f"{plasticparcels_data_url}/{dataset}/{filename}"
164-
urlretrieve(url, str(filepath))
165-
162+
try:
163+
settings[settings_path[0]][settings_path[1]] = filepath
164+
if not os.path.exists(filepath):
165+
url = f"{plasticparcels_data_url}/{dataset}/{filename}"
166+
urlretrieve(url, str(filepath))
167+
except Exception as e:
168+
warnings.warn(f"Could not set settings path {settings_path} for dataset {dataset!r}.", stacklevel=1)
166169
return settings

0 commit comments

Comments
 (0)