From 9fb6d35f487310e2f46b94af2b14f59f0d0f3a2c Mon Sep 17 00:00:00 2001 From: Alexandre Strube Date: Tue, 23 Oct 2018 23:10:32 +0200 Subject: [PATCH] Crude fix --- Calendar/stable.py | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) mode change 100644 => 100755 Calendar/stable.py diff --git a/Calendar/stable.py b/Calendar/stable.py old mode 100644 new mode 100755 index fceca41..f75e95a --- a/Calendar/stable.py +++ b/Calendar/stable.py @@ -132,15 +132,24 @@ def main(): pass # openweathermap api - owm = pyowm.OWM(api_key) - observation = owm.weather_at_place(location) - weather = observation.get_weather() - weathericon = weather.get_weather_icon_name() + try: + print("Before fetching owm data") + owm = pyowm.OWM(api_key) + observation = owm.weather_at_place(location) + print("Fetching weather data...") + weather = observation.get_weather() + weathericon = weather.get_weather_icon_name() + except Exception as e: + template = "An exception of type {0} occurred. Arguments:\n{1!r}" + message = template.format(type(ex).__name__, ex.args) + print(message) + print("************ OWM DID NOT RESPOND *************") + pass Temperature = str(int(weather.get_temperature(unit='celsius')['temp'])) Humidity = str(weather.get_humidity()) - #print('temp: '+Temperature +' °C') #->debug - #print('humidity: '+Humidity+'%') #->debug - #print(weathericon) #->debug + print('temp: '+Temperature +' °C') #->debug + print('humidity: '+Humidity+'%') #->debug + print(weathericon) #->debug #weather icon handler draw(wiconplace, open(wpath+weathericons[weathericon]+'.bmp'))