From: gregor herrmann Date: Fri, 8 Jun 2018 21:58:28 +0000 (+0200) Subject: owm.py: handle missing wind degrees/direction X-Git-Url: https://git.toastfreeware.priv.at/chrisu/seepark.git/commitdiff_plain/9914342507741bf4a6ba2d8f8a03916ca37e07de owm.py: handle missing wind degrees/direction --- diff --git a/owm.py b/owm.py index 04d38b5..2fefc6a 100755 --- a/owm.py +++ b/owm.py @@ -36,6 +36,8 @@ def fromtimestamp(timestamp, format): # https://stackoverflow.com/questions/7490660/converting-wind-direction-in-angles-to-text-words def degToCompass(num): + if num is None: + return 'N/A' val=int((num/22.5)+.5) arr=["N","NNO","NO","ONO","O","OSO", "SO", "SSO","S","SSW","SW","WSW","W","WNW","NW","NNW"] return arr[(val % 16)]