From: Alexander Vasarab Date: Thu, 3 Mar 2022 23:13:38 +0000 (-0800) Subject: Small bugfix with hn24, and add units config check X-Git-Tag: v3.4.1~3^2~1 X-Git-Url: https://wylark.com/src/infoex-autowx.git/commitdiff_plain/04704c628cc5b6d9bee8fa847457cbbbc5131e1f?hp=--cc Small bugfix with hn24, and add units config check --- 04704c628cc5b6d9bee8fa847457cbbbc5131e1f diff --git a/infoex-autowx.py b/infoex-autowx.py index 05e1d46..9b72eee 100755 --- a/infoex-autowx.py +++ b/infoex-autowx.py @@ -128,6 +128,10 @@ def setup_config(config): LOG.critical("%s is not a valid timezone", tz) sys.exit(1) + if station['units'] not in ['metric', 'english', 'american']: + print("Please specify either metric, english, or american for the units.") + sys.exit(1) + # By default, fetch three hours of data # # If user wants hn24 or wind averaging, then @@ -538,7 +542,8 @@ def get_nrcs_data(begin, end, station): hn24 = 0.0 if hn24 is not None: - remote_data['hn24'] = hn24 + if station['hn24']: + remote_data['hn24'] = hn24 return remote_data @@ -697,7 +702,8 @@ def get_mesowest_data(begin, end, station): wind_direction_avg = sum(wind_direction_values) / len(wind_direction_values) if hn24 is not None: - remote_data['hn24'] = hn24 + if station['hn24']: + remote_data['hn24'] = hn24 # overwrite the following with the respective averages, if # applicable