Commit 726f470f authored by Cédric Bonhomme's avatar Cédric Bonhomme
Browse files

Log exceptions when getting information from OpenWeatherMap.

parent c360b395
......@@ -36,12 +36,17 @@ def rain():
"""
try:
result = requests.get("http://api.openweathermap.org/data/2.5/weather?q=Luxembourg,Lux")
except:
except Exception as e:
print str(e)
return True
if result.status_code != 200:
print result.status_code
return True
json_result = json.loads(result.text)
try:
return json_result['weather'][0]['main'] != 'Rain'
except:
return True
\ No newline at end of file
except Exception as e:
print str(e)
return False
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment