From: Philipp Spitzer Date: Wed, 25 Jul 2018 20:03:18 +0000 (+0200) Subject: Make script ready for missing visibility information in JSON. X-Git-Url: https://git.toastfreeware.priv.at/chrisu/seepark.git/commitdiff_plain/b5d269a55c7a833b398a74f47f4a788485aa1db4 Make script ready for missing visibility information in JSON. --- diff --git a/owm.py b/owm.py index c57b242..6f7ba24 100755 --- a/owm.py +++ b/owm.py @@ -37,7 +37,6 @@ def extractweatherdata(w): temp = w['main']['temp'], pressure = w['main']['pressure'], humidity = w['main']['humidity'], - visibility = w['visibility'], weather = w['weather'][0]['description'], sky = w['weather'][0]['main'], windspeed = w['wind']['speed'], @@ -51,6 +50,7 @@ def extractweatherdata(w): data['winddegrees'] = w['wind']['deg'] if 'deg' in w['wind'] else math.nan data['winddirection'] = degToCompass(data['winddegrees']) data['precipitation'] = w['rain']['3h'] if 'rain' in w else math.nan + data['visibility'] = w.get('visibility', math.nan) return data