diff --git a/main.py b/main.py index 898b44b3..005e1166 100644 --- a/main.py +++ b/main.py @@ -80,7 +80,9 @@ def check(lons_lats_vect): if __name__ == "__main__": - if weather.api.clouds() < int(os.getenv('WEATHER_CLOUD_PERCENTAGE')): - status.run() + status.run() + clouds = weather.api.clouds() + print(f'Currently, clouds are {clouds}%') + if clouds < int(os.getenv('WEATHER_CLOUD_PERCENTAGE')): buffer = geodesic_point_buffer(os.getenv("LAT"), os.getenv("LON"), int(os.getenv("KM_RADIUS"))) check(buffer) diff --git a/weather/api.py b/weather/api.py index 13021d68..cc52c2a4 100644 --- a/weather/api.py +++ b/weather/api.py @@ -7,6 +7,7 @@ def clouds(): + global response url = f"https://api.openweathermap.org/data/2.5/onecall?lat={os.getenv('LAT')}&lon={os.getenv('LON')}&exclude=minutely,hourly,daily,alerts&appid={os.getenv('WEATHER_APP_ID')}" try: request = requests.get(url) @@ -14,5 +15,5 @@ def clouds(): return response['current']['clouds'] - except requests.exceptions.RequestException as e: - raise SystemExit(e) + except: + return response['current']['clouds']