owm.py: handle missing wind degrees/direction
authorgregor herrmann <gregor@toastfreeware.priv.at>
Fri, 8 Jun 2018 21:58:28 +0000 (23:58 +0200)
committergregor herrmann <gregor@toastfreeware.priv.at>
Fri, 8 Jun 2018 21:58:28 +0000 (23:58 +0200)
owm.py

diff --git a/owm.py b/owm.py
index 04d38b50ca421b71697e0aa750204d3054820d58..2fefc6a20b3780ab3b03963b7526a2ced0e7ac0e 100755 (executable)
--- 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)]