Skip to content
Snippets Groups Projects
Commit a86928c0 authored by leufen1's avatar leufen1
Browse files

join handles now bad request reponses, /close #224

parent 83fd35e2
No related branches found
No related tags found
3 merge requests!226Develop,!225Resolve "release v1.2.0",!200Resolve "BUG: add ValueError to f_proc"
Pipeline #54104 passed
This commit is part of merge request !225. Comments created here will be created in the context of that merge request.
......@@ -70,7 +70,7 @@ def download_join(station_name: Union[str, List[str]], stat_var: dict, station_t
# create data link
opts = {'base': join_url_base, 'service': 'stats', 'id': vars_dict[var], 'statistics': stat_var[var],
'sampling': sampling, 'capture': 0, 'min_data_length': 1460, 'format': 'json'}
'sampling': sampling, 'capture': 0, 'format': 'json'}
# load data
data = get_data(opts, headers)
......@@ -130,7 +130,10 @@ def get_data(opts: Dict, headers: Dict) -> Union[Dict, List]:
"""
url = create_url(**opts)
response = requests.get(url, headers=headers)
if response.status_code == 200:
return response.json()
else:
raise EmptyQueryResult(f"There was an error (STATUS {response.status_code}) for request {url}")
def load_series_information(station_name: List[str], station_type: str_or_none, network_name: str_or_none,
......
......@@ -333,7 +333,7 @@ def f_proc(data_handler, station, name_affix, store, **kwargs):
try:
res = data_handler.build(station, name_affix=name_affix, store_processed_data=store,
**kwargs)
except (AttributeError, EmptyQueryResult, KeyError, requests.ConnectionError) as e:
except (AttributeError, EmptyQueryResult, KeyError, requests.ConnectionError, ValueError) as e:
logging.info(f"remove station {station} because it raised an error: {e}")
res = None
return res, station
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment