diff --git a/mlair/helpers/join.py b/mlair/helpers/join.py index b772a053a7131e5538cbb9da6b03f6dc1c775a4d..8a8ca0b8c964268aa6043312cd1cc88bc0d50544 100644 --- a/mlair/helpers/join.py +++ b/mlair/helpers/join.py @@ -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) - return response.json() + 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, diff --git a/mlair/run_modules/pre_processing.py b/mlair/run_modules/pre_processing.py index 8be5870a3d1945c18e0f27278dc30af0c7c61139..0238ad0e2e8f85558d4e1172bfb65759bff35ce1 100644 --- a/mlair/run_modules/pre_processing.py +++ b/mlair/run_modules/pre_processing.py @@ -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