From 81cc0ca7acfa6e2997ba23a87bdafed5b2c035a7 Mon Sep 17 00:00:00 2001 From: MitchBred Date: Sat, 25 Nov 2023 15:57:31 +0100 Subject: [PATCH] chore(weather-standby-mode): print cloud percentage --- main.py | 6 ++++-- weather/api.py | 5 +++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/main.py b/main.py index 898b44b..005e116 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 13021d6..cc52c2a 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']