From e5e99725940efb3889e6aad4ff5661503d2f4af4 Mon Sep 17 00:00:00 2001 From: Alexander Vasarab Date: Sun, 29 Nov 2020 17:31:46 -0800 Subject: [PATCH 01/16] Add some comments and exceptions --- examples/custom-wx.example.py | 4 ++++ infoex-autowx.py | 8 ++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/examples/custom-wx.example.py b/examples/custom-wx.example.py index 565e71f..0b2cc42 100644 --- a/examples/custom-wx.example.py +++ b/examples/custom-wx.example.py @@ -27,5 +27,9 @@ def get_custom_data(): # Whatever your program needs to do to get its data can be done # either here in this function directly, or elsewhere with # modification to the global variable `wx_data`. + # + # NOTE: The LOG class from infoex-autowx is available, so you may + # issue e.g. LOG.info('some helpful information') in your + # program. return wx_data diff --git a/infoex-autowx.py b/infoex-autowx.py index f285c42..c191e5c 100755 --- a/infoex-autowx.py +++ b/infoex-autowx.py @@ -228,9 +228,9 @@ def main(): if infoex['wx_data'] is None: infoex['wx_data'] = [] - except Exception: + except Exception as exc: LOG.error("Python program for custom Wx data failed in " - "execution") + "execution: " + str(exc)) sys.exit(1) LOG.info("Successfully executed external Python program") @@ -241,6 +241,10 @@ def main(): LOG.error("Specified Python program for custom Wx data " "was not found") sys.exit(1) + except Exception as exc: + LOG.error("A problem was encountered when attempting to " + "load your custom Wx program: " + str(exc)) + sys.exit(1) LOG.info("Time taken to get all data : %.3f sec", time.time() - time_all_elements) -- 2.30.2 From 1a88cb87e43c538e58bf00dd9d4f363e5b8c9e04 Mon Sep 17 00:00:00 2001 From: Alexander Vasarab Date: Sun, 29 Nov 2020 17:37:46 -0800 Subject: [PATCH 02/16] Bump version to 3.0.0 --- README.md | 12 +++++++++++- infoex-autowx.py | 2 +- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 681feac..8d9da91 100644 --- a/README.md +++ b/README.md @@ -257,12 +257,22 @@ windGustSpeedNum Future plans ------------ -- Improve the documentation - Implement unit conversion for NRCS stations Version history --------------- +- 3.0.0 (Nov 2020) + + Implement Custom Wx data providers. + + This release enables the user to write their own Python programs and + specify them to infoex-autowx as a data provider. + + This in turn enables the user to pull data from e.g. a local database + or an HTML page and push it into their InfoEx auto station data, + limited only by the imagination. + - 2.2.0 (Nov 2020) Add support for Tmin/Tmax values (directly from MesoWest/NRCS). diff --git a/infoex-autowx.py b/infoex-autowx.py index c191e5c..3fe07fc 100755 --- a/infoex-autowx.py +++ b/infoex-autowx.py @@ -39,7 +39,7 @@ import zeep import zeep.cache import zeep.transports -__version__ = '2.2.0' +__version__ = '3.0.0' LOG = logging.getLogger(__name__) LOG.setLevel(logging.NOTSET) -- 2.30.2 From 9cf140090cffed0f3e63c4695df48d20b0483467 Mon Sep 17 00:00:00 2001 From: Alexander Vasarab Date: Wed, 6 Jan 2021 16:54:08 -0800 Subject: [PATCH 03/16] Convert MesoWest wind speed data to correct unit --- infoex-autowx.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/infoex-autowx.py b/infoex-autowx.py index 3fe07fc..be66aa4 100755 --- a/infoex-autowx.py +++ b/infoex-autowx.py @@ -474,9 +474,14 @@ def get_mesowest_data(begin, end, station): # we may not have the data at all key_name = element_cd + '_set_1' + if key_name in observations: if observations[key_name][pos]: remote_data[element_cd] = observations[key_name][pos] + + # mesowest provides wind_speed in m/s, we want mph + if 'wind_speed' == element_cd: + remote_data[element_cd] = ms_to_mph(remote_data[element_cd]) else: remote_data[element_cd] = None else: @@ -535,5 +540,9 @@ def setup_time_values(): begin_date = end_date - datetime.timedelta(hours=3) return (begin_date, end_date) +def ms_to_mph(ms): + """convert meters per second to miles per hour""" + return ms * 2.236936 + if __name__ == "__main__": sys.exit(main()) -- 2.30.2 From 64e0ea112b8b8a5f19cf869c334283b6991f2ad5 Mon Sep 17 00:00:00 2001 From: Alexander Vasarab Date: Wed, 6 Jan 2021 16:58:29 -0800 Subject: [PATCH 04/16] Add wind_gust to m/s -> mph conversion --- infoex-autowx.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/infoex-autowx.py b/infoex-autowx.py index be66aa4..4b58427 100755 --- a/infoex-autowx.py +++ b/infoex-autowx.py @@ -480,7 +480,7 @@ def get_mesowest_data(begin, end, station): remote_data[element_cd] = observations[key_name][pos] # mesowest provides wind_speed in m/s, we want mph - if 'wind_speed' == element_cd: + if element_cd in ('wind_speed', 'wind_gust'): remote_data[element_cd] = ms_to_mph(remote_data[element_cd]) else: remote_data[element_cd] = None -- 2.30.2 From 76933d07912ab0d624a7bd4c16a54e40ae520f19 Mon Sep 17 00:00:00 2001 From: Alexander Vasarab Date: Wed, 6 Jan 2021 17:00:35 -0800 Subject: [PATCH 05/16] Fix some pylint issues --- infoex-autowx.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/infoex-autowx.py b/infoex-autowx.py index 4b58427..aeac27c 100755 --- a/infoex-autowx.py +++ b/infoex-autowx.py @@ -230,7 +230,7 @@ def main(): infoex['wx_data'] = [] except Exception as exc: LOG.error("Python program for custom Wx data failed in " - "execution: " + str(exc)) + "execution: %s", str(exc)) sys.exit(1) LOG.info("Successfully executed external Python program") @@ -243,7 +243,7 @@ def main(): sys.exit(1) except Exception as exc: LOG.error("A problem was encountered when attempting to " - "load your custom Wx program: " + str(exc)) + "load your custom Wx program: %s", str(exc)) sys.exit(1) LOG.info("Time taken to get all data : %.3f sec", time.time() - @@ -289,7 +289,7 @@ def main(): LOG.debug("final_data: %s", str(final_data)) - if len(infoex['wx_data']) > 0: + if infoex['wx_data']: if not write_local_csv(infoex['csv_filename'], final_data): LOG.warning('Could not write local CSV file: %s', infoex['csv_filename']) -- 2.30.2 From 25e1790265541d4fc5be280db49716a5f12415de Mon Sep 17 00:00:00 2001 From: Alexander Vasarab Date: Wed, 6 Jan 2021 17:04:38 -0800 Subject: [PATCH 06/16] Round relative humidity to one decimal place --- infoex-autowx.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/infoex-autowx.py b/infoex-autowx.py index aeac27c..cac8c3e 100755 --- a/infoex-autowx.py +++ b/infoex-autowx.py @@ -266,14 +266,15 @@ def main(): # expectations # # 0 decimal places: wind speed, wind direction, wind gust, snow depth - # 1 decimal place: air temp, baro + # 1 decimal place: air temp, relative humidity, 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']: infoex['wx_data'][element_cd] = round(infoex['wx_data'][element_cd]) - elif element_cd in ['TOBS', 'air_temp', 'PRES', 'pressure']: + elif element_cd in ['TOBS', 'air_temp', 'RHUM', + 'relative_humidity', 'PRES', 'pressure']: infoex['wx_data'][element_cd] = round(infoex['wx_data'][element_cd], 1) # CONSIDER: Casting every value to Float() -- need to investigate if -- 2.30.2 From 6a516ce12e2e30356f0935485d5f565c398d5ef0 Mon Sep 17 00:00:00 2001 From: Alexander Vasarab Date: Wed, 6 Jan 2021 17:08:50 -0800 Subject: [PATCH 07/16] Version bump --- README.md | 11 +++++++++++ infoex-autowx.py | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 8d9da91..944606c 100644 --- a/README.md +++ b/README.md @@ -262,6 +262,17 @@ Future plans Version history --------------- +- 3.0.1 (Jan 2021) + + General fixes. + + - MesoWest wind data (speed and gust speed) units are now transformed + from their origin unit (meters per second) to the unit expected by + InfoEx (miles per hour). + + - Relative humidity is now rounded to one decimal place, preventing + InfoEx from reddening the auto-filled value. + - 3.0.0 (Nov 2020) Implement Custom Wx data providers. diff --git a/infoex-autowx.py b/infoex-autowx.py index cac8c3e..d58baac 100755 --- a/infoex-autowx.py +++ b/infoex-autowx.py @@ -39,7 +39,7 @@ import zeep import zeep.cache import zeep.transports -__version__ = '3.0.0' +__version__ = '3.0.1' LOG = logging.getLogger(__name__) LOG.setLevel(logging.NOTSET) -- 2.30.2 From 045b69f96c4a18fb1dbb81f754e51d5fdf1629cc Mon Sep 17 00:00:00 2001 From: Alexander Vasarab Date: Wed, 6 Jan 2021 18:27:18 -0800 Subject: [PATCH 08/16] Fix another issue with MesoWest wind units --- infoex-autowx.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/infoex-autowx.py b/infoex-autowx.py index d58baac..1d84ab8 100755 --- a/infoex-autowx.py +++ b/infoex-autowx.py @@ -480,9 +480,11 @@ def get_mesowest_data(begin, end, station): if observations[key_name][pos]: remote_data[element_cd] = observations[key_name][pos] - # mesowest provides wind_speed in m/s, we want mph + # mesowest by default provides wind_speed in m/s, but + # we specify 'english' units in the request; either way, + # we want mph if element_cd in ('wind_speed', 'wind_gust'): - remote_data[element_cd] = ms_to_mph(remote_data[element_cd]) + remote_data[element_cd] = kn_to_mph(remote_data[element_cd]) else: remote_data[element_cd] = None else: @@ -545,5 +547,9 @@ def ms_to_mph(ms): """convert meters per second to miles per hour""" return ms * 2.236936 +def kn_to_mph(kn): + """convert knots to miles per hour""" + return kn * 1.150779 + if __name__ == "__main__": sys.exit(main()) -- 2.30.2 From 3ac2d05ca878f346f89043ddcc0c430d70d2ae4b Mon Sep 17 00:00:00 2001 From: Alexander Vasarab Date: Wed, 6 Jan 2021 19:22:59 -0800 Subject: [PATCH 09/16] Use UTC time when asking MesoWest for data --- infoex-autowx.py | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/infoex-autowx.py b/infoex-autowx.py index 1d84ab8..439ff19 100755 --- a/infoex-autowx.py +++ b/infoex-autowx.py @@ -196,7 +196,7 @@ def main(): "file") sys.exit(1) - (begin_date, end_date) = setup_time_values() + (begin_date, end_date) = setup_time_values(station['provider']) if station['provider'] == 'python': LOG.debug("Getting custom data from external Python program") @@ -404,6 +404,10 @@ def get_nrcs_data(begin, end, station): client = zeep.Client(wsdl=station['source'], transport=transport) remote_data = {} + # massage begin/end date format + begin_date_str = begin.strftime('%Y-%m-%d %H:%M:00') + end_date_str = end.strftime('%Y-%m-%d %H:%M:00') + for element_cd in station['desired_data']: time_element = time.time() @@ -412,8 +416,8 @@ def get_nrcs_data(begin, end, station): stationTriplets=[station['station_id']], elementCd=element_cd, ordinal=1, - beginDate=begin, - endDate=end) + beginDate=begin_date_str, + endDate=end_date_str) LOG.info("Time to get NRCS elementCd '%s': %.3f sec", element_cd, time.time() - time_element) @@ -533,10 +537,17 @@ def upload_csv(path_to_file, infoex_data): os.remove(path_to_file) # other miscellaneous routines -def setup_time_values(): +def setup_time_values(provider): """establish time bounds of data request(s)""" + + # default timezone to UTC (for MesoWest) + tz = datetime.timezone.utc + + if provider == 'nrcs': + tz = None + # floor time to nearest hour - date_time = datetime.datetime.now() + date_time = datetime.datetime.now(tz=tz) end_date = date_time - datetime.timedelta(minutes=date_time.minute % 60, seconds=date_time.second, microseconds=date_time.microsecond) -- 2.30.2 From d0aebe468057e65aefaa233512832e8cfe73b0b3 Mon Sep 17 00:00:00 2001 From: Alexander Vasarab Date: Wed, 6 Jan 2021 19:25:38 -0800 Subject: [PATCH 10/16] Version bump --- README.md | 4 ++++ infoex-autowx.py | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 944606c..bebbdcb 100644 --- a/README.md +++ b/README.md @@ -262,6 +262,10 @@ Future plans Version history --------------- +- 3.0.2 (Jan 2021) + + Use UTCC time when asking MesoWest for data. + - 3.0.1 (Jan 2021) General fixes. diff --git a/infoex-autowx.py b/infoex-autowx.py index 439ff19..dfb22a7 100755 --- a/infoex-autowx.py +++ b/infoex-autowx.py @@ -39,7 +39,7 @@ import zeep import zeep.cache import zeep.transports -__version__ = '3.0.1' +__version__ = '3.0.2' LOG = logging.getLogger(__name__) LOG.setLevel(logging.NOTSET) -- 2.30.2 From 4d4c7019aa2063a0b8742949021a028a3a96b795 Mon Sep 17 00:00:00 2001 From: Alexander Vasarab Date: Thu, 7 Jan 2021 21:09:25 -0800 Subject: [PATCH 11/16] Implement time zone support --- README.md | 27 +++++++++++++++++++++++++++ examples/config.example.ini | 1 + infoex-autowx.py | 35 ++++++++++++++++++++++++++--------- requirements.txt | 1 + 4 files changed, 55 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index bebbdcb..62d15bc 100644 --- a/README.md +++ b/README.md @@ -83,6 +83,7 @@ options. `station_id = # the NRCS/MesoWest identifier for a particular station #` `desired_data = # a comma-delimited list of fields you're interested in #` `units = # either english or metric -- only applies when type is mesowest #` +`tz = # any entry from the Olson tz database e.g. America/Denver #` `path = # the filesystem path to the Python program -- only applies when type is python #` `[infoex]` @@ -206,6 +207,32 @@ or a remote web page which requires some custom parsing. Please see the program located at examples/custom-wx.example.py for a complete description of what's required. +A note on time zones +-------------------- + +This program is aware of time zones via the pytz library. The way in +which NRCS and MesoWest deal with time zones differs as follows: + +NRCS expects the request to come in the appropriate time zone, and the +data retrieved will be in the same time zone (no transformation +required before sending to InfoEx). + +MesoWest expects the request to come in UTC, and the data retrieved will +be in the same time zone (transformation from UTC to the desired time +zone is required before sending to InfoEx). + +As long as you specify the correct timezone in your configuration file, +all will be handled correctly. The list of time zones comes from the +Olson tz database. See that for more information. + +If you specify an invalid time zone, the program will exit and inform +you of such. + +Lastly, InfoEx itself is timezone aware. If you notice that the data +which makes it into your operation is inaccurate, start your +investigation with time zone-related issues and move on only once you've +ruled this out as a cause of the inaccuracy. + A note on supported measurements -------------------------------- diff --git a/examples/config.example.ini b/examples/config.example.ini index 17544ae..0408788 100644 --- a/examples/config.example.ini +++ b/examples/config.example.ini @@ -4,6 +4,7 @@ token = # MesoWest API token (ignored for NRCS) # station_id = # NRCS/MesoWest Station ID # desired_data = # Comma-separated list of values # units = # (english|metric) (ignored for NRCS) # +tz = # any Olson tz database entries e.g. America/Denver # [infoex] host = # InfoEx FTP host address # diff --git a/infoex-autowx.py b/infoex-autowx.py index dfb22a7..15adf08 100755 --- a/infoex-autowx.py +++ b/infoex-autowx.py @@ -33,6 +33,8 @@ import time from ftplib import FTP from argparse import ArgumentParser +import pytz + import requests import zeep @@ -115,6 +117,17 @@ def setup_config(config): if station['provider'] == 'python': station['path'] = config['station']['path'] + tz = 'America/Los_Angeles' + + if 'tz' in config['station']: + tz = config['station']['tz'] + + try: + station['tz'] = pytz.timezone(tz) + except pytz.exceptions.UnknownTimeZoneError: + LOG.critical("%s is not a valid timezone", tz) + sys.exit(1) + except KeyError as err: LOG.critical("%s not defined in configuration file", err) sys.exit(1) @@ -196,14 +209,14 @@ def main(): "file") sys.exit(1) - (begin_date, end_date) = setup_time_values(station['provider']) + (begin_date, end_date) = setup_time_values(station) if station['provider'] == 'python': LOG.debug("Getting custom data from external Python program") else: - LOG.debug("Getting %s data from %s to %s", + LOG.debug("Getting %s data from %s to %s (%s)", str(station['desired_data']), - str(begin_date), str(end_date)) + str(begin_date), str(end_date), end_date.tzinfo.zone) time_all_elements = time.time() @@ -251,11 +264,14 @@ def main(): LOG.debug("infoex[wx_data]: %s", str(infoex['wx_data'])) + # timezone massaging + final_end_date = end_date.astimezone(station['tz']) + # Now we only need to add in what we want to change thanks to that # abomination of a variable declaration earlier final_data[fmap['Location UUID']] = infoex['location_uuid'] - final_data[fmap['obDate']] = end_date.strftime('%m/%d/%Y') - final_data[fmap['obTime']] = end_date.strftime('%H:%M') + final_data[fmap['obDate']] = final_end_date.strftime('%m/%d/%Y') + final_data[fmap['obTime']] = final_end_date.strftime('%H:%M') for element_cd in infoex['wx_data']: if element_cd not in iemap: @@ -537,14 +553,15 @@ def upload_csv(path_to_file, infoex_data): os.remove(path_to_file) # other miscellaneous routines -def setup_time_values(provider): +def setup_time_values(station): """establish time bounds of data request(s)""" # default timezone to UTC (for MesoWest) - tz = datetime.timezone.utc + tz = pytz.utc - if provider == 'nrcs': - tz = None + # but for NRCS, use the config-specified timezone + if station['provider'] == 'nrcs': + tz = station['tz'] # floor time to nearest hour date_time = datetime.datetime.now(tz=tz) diff --git a/requirements.txt b/requirements.txt index 2aec4ac..cb9dc30 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,3 @@ +pytz>=2020.1 requests>=2.0.0 zeep>=3.4.0 -- 2.30.2 From 06814f5e532c29e05562ebab327a454c8b8b8d12 Mon Sep 17 00:00:00 2001 From: Alexander Vasarab Date: Thu, 7 Jan 2021 21:11:22 -0800 Subject: [PATCH 12/16] Version bump --- README.md | 6 +++++- infoex-autowx.py | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 62d15bc..1a5cbef 100644 --- a/README.md +++ b/README.md @@ -289,9 +289,13 @@ Future plans Version history --------------- +- 3.1.0 (Jan 2021) + + Implement time zone support. + - 3.0.2 (Jan 2021) - Use UTCC time when asking MesoWest for data. + Use UTC time when asking MesoWest for data. - 3.0.1 (Jan 2021) diff --git a/infoex-autowx.py b/infoex-autowx.py index 15adf08..f2be003 100755 --- a/infoex-autowx.py +++ b/infoex-autowx.py @@ -41,7 +41,7 @@ import zeep import zeep.cache import zeep.transports -__version__ = '3.0.2' +__version__ = '3.1.0' LOG = logging.getLogger(__name__) LOG.setLevel(logging.NOTSET) -- 2.30.2 From c3d3cc62e986acac7b4b044eb7958b20e48ab2a1 Mon Sep 17 00:00:00 2001 From: Alexander Vasarab Date: Mon, 1 Feb 2021 22:00:38 -0800 Subject: [PATCH 13/16] Catch KeyError exception when interpreting json --- infoex-autowx.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/infoex-autowx.py b/infoex-autowx.py index f2be003..9bd77c1 100755 --- a/infoex-autowx.py +++ b/infoex-autowx.py @@ -473,6 +473,9 @@ def get_mesowest_data(begin, end, station): try: observations = json['STATION'][0]['OBSERVATIONS'] + except KeyError: + LOG.error("Unexpected JSON in MesoWest response") + sys.exit(1) except ValueError: LOG.error("Bad JSON in MesoWest response") sys.exit(1) -- 2.30.2 From 5583d801acf7ce96b5a846807a9cb9b3b5039738 Mon Sep 17 00:00:00 2001 From: Alexander Vasarab Date: Mon, 1 Feb 2021 22:03:32 -0800 Subject: [PATCH 14/16] Round RH to zero decimal places --- infoex-autowx.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/infoex-autowx.py b/infoex-autowx.py index 9bd77c1..b979287 100755 --- a/infoex-autowx.py +++ b/infoex-autowx.py @@ -281,16 +281,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 -- 2.30.2 From f6ec08d2525c2418d14fecaaab1c78e15e1c1b21 Mon Sep 17 00:00:00 2001 From: Alexander Vasarab Date: Mon, 1 Feb 2021 22:11:38 -0800 Subject: [PATCH 15/16] Catch a few more exceptions, and Pylint fixes --- infoex-autowx.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/infoex-autowx.py b/infoex-autowx.py index b979287..a68d778 100755 --- a/infoex-autowx.py +++ b/infoex-autowx.py @@ -474,11 +474,19 @@ def get_mesowest_data(begin, end, station): try: observations = json['STATION'][0]['OBSERVATIONS'] - except KeyError: - LOG.error("Unexpected JSON in MesoWest response") + except KeyError as exc: + LOG.error("Unexpected JSON in MesoWest response: '%s'", exc) sys.exit(1) - except ValueError: - LOG.error("Bad JSON in MesoWest response") + 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 -- 2.30.2 From 678212bea2f94379cc34fa67549d30d8b4c24511 Mon Sep 17 00:00:00 2001 From: Alexander Vasarab Date: Mon, 1 Feb 2021 22:13:52 -0800 Subject: [PATCH 16/16] Fix a Pylint import-outside-toplevel warning --- infoex-autowx.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/infoex-autowx.py b/infoex-autowx.py index a68d778..c2d20f7 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 @@ -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) -- 2.30.2