From: Alexander Vasarab Date: Tue, 2 Feb 2021 06:17:18 +0000 (-0800) Subject: Merge branch 'release-3.1.1' X-Git-Tag: v3.1.1^0 X-Git-Url: https://wylark.com/src/infoex-autowx.git/commitdiff_plain/8210e35384e3f5bad451c7eeeed8d70c3bcf8e60?hp=5bb081b14946754f13e282055b90adee89ff29c0 Merge branch 'release-3.1.1' --- diff --git a/README.md b/README.md index 1a5cbef..16c76b2 100644 --- a/README.md +++ b/README.md @@ -289,6 +289,10 @@ Future plans Version history --------------- +- 3.1.1 (Feb 2021) + + Fix relative humidity rounding. + - 3.1.0 (Jan 2021) Implement time zone support. diff --git a/infoex-autowx.py b/infoex-autowx.py index f2be003..abdf14a 100755 --- a/infoex-autowx.py +++ b/infoex-autowx.py @@ -29,6 +29,7 @@ import logging import os import sys import time +import importlib.util from ftplib import FTP from argparse import ArgumentParser @@ -41,7 +42,7 @@ import zeep import zeep.cache import zeep.transports -__version__ = '3.1.0' +__version__ = '3.1.1' LOG = logging.getLogger(__name__) LOG.setLevel(logging.NOTSET) @@ -228,8 +229,6 @@ def main(): station) elif station['provider'] == 'python': try: - import importlib.util - spec = importlib.util.spec_from_file_location('custom_wx', station['path']) mod = importlib.util.module_from_spec(spec) @@ -281,16 +280,17 @@ def main(): # Massage precision of certain values to fit InfoEx's # expectations # - # 0 decimal places: wind speed, wind direction, wind gust, snow depth - # 1 decimal place: air temp, relative humidity, baro + # 0 decimal places: relative humidity, wind speed, wind + # direction, wind gust, snow depth + # 1 decimal place: air temp, baro # Avoid transforming None values if infoex['wx_data'][element_cd] is None: continue elif element_cd in ['wind_speed', 'WSPD', 'wind_direction', - 'WDIR', 'wind_gust', 'SNWD', 'snow_depth']: + 'RHUM', 'relative_humidity', 'WDIR', + 'wind_gust', 'SNWD', 'snow_depth']: infoex['wx_data'][element_cd] = round(infoex['wx_data'][element_cd]) - elif element_cd in ['TOBS', 'air_temp', 'RHUM', - 'relative_humidity', 'PRES', 'pressure']: + elif element_cd in ['TOBS', 'air_temp', 'PRES', 'pressure']: infoex['wx_data'][element_cd] = round(infoex['wx_data'][element_cd], 1) # CONSIDER: Casting every value to Float() -- need to investigate if @@ -473,8 +473,19 @@ def get_mesowest_data(begin, end, station): try: observations = json['STATION'][0]['OBSERVATIONS'] - except ValueError: - LOG.error("Bad JSON in MesoWest response") + except KeyError as exc: + LOG.error("Unexpected JSON in MesoWest response: '%s'", exc) + sys.exit(1) + except IndexError as exc: + LOG.error("Unexpected JSON in MesoWest response: '%s'", exc) + try: + LOG.error("Detailed MesoWest response: '%s'", + json['SUMMARY']['RESPONSE_MESSAGE']) + except KeyError: + pass + sys.exit(1) + except ValueError as exc: + LOG.error("Bad JSON in MesoWest response: '%s'", exc) sys.exit(1) pos = len(observations['date_time']) - 1