From 5b17228811d303c62fe82d85a4ddf14e15d87934 Mon Sep 17 00:00:00 2001 From: Hemna Date: Thu, 7 Oct 2021 10:11:48 -0400 Subject: [PATCH] removed usage of config.check_config_option check_config_option has been superceeded by the config UserDict object's ability to see if a config option exists. --- aprsd/plugins/time.py | 11 +++++------ aprsd/plugins/weather.py | 24 +++++++++--------------- 2 files changed, 14 insertions(+), 21 deletions(-) diff --git a/aprsd/plugins/time.py b/aprsd/plugins/time.py index 516643a..ad660ac 100644 --- a/aprsd/plugins/time.py +++ b/aprsd/plugins/time.py @@ -5,7 +5,7 @@ import time from opencage.geocoder import OpenCageGeocode import pytz -from aprsd import config, fuzzyclock, plugin, plugin_utils, trace +from aprsd import fuzzyclock, plugin, plugin_utils, trace LOG = logging.getLogger("APRSD") @@ -64,7 +64,7 @@ class TimeOpenCageDataPlugin(TimePlugin): # get last location of a callsign, get descriptive name from weather service try: - config.check_config_option(self.config, ["services", "aprs.fi", "apiKey"]) + self.config.exists(["services", "aprs.fi", "apiKey"]) except Exception as ex: LOG.error(f"Failed to find config aprs.fi:apikey {ex}") return "No aprs.fi apikey found" @@ -95,7 +95,7 @@ class TimeOpenCageDataPlugin(TimePlugin): lon = aprs_data["entries"][0]["lng"] try: - config.check_config_option(self.config, "opencagedata", "apiKey") + self.config.exists("opencagedata.apiKey") except Exception as ex: LOG.error(f"Failed to find config opencage:apiKey {ex}") return "No opencage apiKey found" @@ -130,7 +130,7 @@ class TimeOWMPlugin(TimePlugin): # get last location of a callsign, get descriptive name from weather service try: - config.check_config_option(self.config, ["services", "aprs.fi", "apiKey"]) + self.config.exists(["services", "aprs.fi", "apiKey"]) except Exception as ex: LOG.error(f"Failed to find config aprs.fi:apikey {ex}") return "No aprs.fi apikey found" @@ -160,8 +160,7 @@ class TimeOWMPlugin(TimePlugin): lon = aprs_data["entries"][0]["lng"] try: - config.check_config_option( - self.config, + self.config.exists( ["services", "openweathermap", "apiKey"], ) except Exception as ex: diff --git a/aprsd/plugins/weather.py b/aprsd/plugins/weather.py index a1dc2cf..21364ab 100644 --- a/aprsd/plugins/weather.py +++ b/aprsd/plugins/weather.py @@ -4,7 +4,7 @@ import re import requests -from aprsd import config, plugin, plugin_utils, trace +from aprsd import plugin, plugin_utils, trace LOG = logging.getLogger("APRSD") @@ -34,7 +34,7 @@ class USWeatherPlugin(plugin.APRSDRegexCommandPluginBase): # message = packet.get("message_text", None) # ack = packet.get("msgNo", "0") try: - config.check_config_option(self.config, ["services", "aprs.fi", "apiKey"]) + self.config.exists(["services", "aprs.fi", "apiKey"]) except Exception as ex: LOG.error(f"Failed to find config aprs.fi:apikey {ex}") return "No aprs.fi apikey found" @@ -115,10 +115,7 @@ class USMetarPlugin(plugin.APRSDRegexCommandPluginBase): fromcall = fromcall try: - config.check_config_option( - self.config, - ["services", "aprs.fi", "apiKey"], - ) + self.config.exists(["services", "aprs.fi", "apiKey"]) except Exception as ex: LOG.error(f"Failed to find config aprs.fi:apikey {ex}") return "No aprs.fi apikey found" @@ -199,7 +196,7 @@ class OWMWeatherPlugin(plugin.APRSDRegexCommandPluginBase): searchcall = fromcall try: - config.check_config_option(self.config, ["services", "aprs.fi", "apiKey"]) + self.config.exists(["services", "aprs.fi", "apiKey"]) except Exception as ex: LOG.error(f"Failed to find config aprs.fi:apikey {ex}") return "No aprs.fi apikey found" @@ -220,16 +217,13 @@ class OWMWeatherPlugin(plugin.APRSDRegexCommandPluginBase): lon = aprs_data["entries"][0]["lng"] try: - config.check_config_option( - self.config, - ["services", "openweathermap", "apiKey"], - ) + self.config.exists(["services", "openweathermap", "apiKey"]) except Exception as ex: LOG.error(f"Failed to find config openweathermap:apiKey {ex}") return "No openweathermap apiKey found" try: - config.check_config_option(self.config, ["aprsd", "units"]) + self.config.exists(["aprsd", "units"]) except Exception: LOG.debug("Couldn't find untis in aprsd:services:units") units = "metric" @@ -323,7 +317,7 @@ class AVWXWeatherPlugin(plugin.APRSDRegexCommandPluginBase): searchcall = fromcall try: - config.check_config_option(self.config, ["services", "aprs.fi", "apiKey"]) + self.config.exists(["services", "aprs.fi", "apiKey"]) except Exception as ex: LOG.error(f"Failed to find config aprs.fi:apikey {ex}") return "No aprs.fi apikey found" @@ -344,13 +338,13 @@ class AVWXWeatherPlugin(plugin.APRSDRegexCommandPluginBase): lon = aprs_data["entries"][0]["lng"] try: - config.check_config_option(self.config, ["services", "avwx", "apiKey"]) + self.config.exists(["services", "avwx", "apiKey"]) except Exception as ex: LOG.error(f"Failed to find config avwx:apiKey {ex}") return "No avwx apiKey found" try: - config.check_config_option(self.config, ["services", "avwx", "base_url"]) + self.config.exists(self.config, ["services", "avwx", "base_url"]) except Exception as ex: LOG.debug(f"Didn't find avwx:base_url {ex}") base_url = "https://avwx.rest"