From 00b95528a701789d4996b2f8d533f4b7fb8a1e2d Mon Sep 17 00:00:00 2001 From: reedts Date: Tue, 29 May 2018 15:28:50 +0200 Subject: [PATCH] Do not discard fetched data in case of error --- pywatts/fetchdata.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/pywatts/fetchdata.py b/pywatts/fetchdata.py index 95ac34f..0cdfb8c 100644 --- a/pywatts/fetchdata.py +++ b/pywatts/fetchdata.py @@ -17,11 +17,15 @@ def fetch_data(from_lon, to_lon, from_lat, to_lat, step_size=1): for longitude in range(from_lon, to_lon, step_size): for latitude in range(from_lat, to_lat, step_size): - results.append(p.request( - format='JSON', system_capacity=4, module_type=1, array_type=1, - azimuth=190, tilt=40, dataset='intl', timeframe='hourly', - losses=10, lon=longitude, lat=latitude - )) + try: + results.append(p.request( + format='JSON', system_capacity=4, module_type=1, array_type=1, + azimuth=190, tilt=40, dataset='intl', timeframe='hourly', + losses=10, lon=longitude, lat=latitude + )) + except: + print("Could not fetch all data") + return results return results