1
0
mirror of https://github.com/craigerl/aprsd.git synced 2025-05-23 18:12:25 -04:00

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.
This commit is contained in:
Hemna 2021-10-07 10:11:48 -04:00
parent 725bb2fe35
commit 5b17228811
2 changed files with 14 additions and 21 deletions

View File

@ -5,7 +5,7 @@ import time
from opencage.geocoder import OpenCageGeocode from opencage.geocoder import OpenCageGeocode
import pytz import pytz
from aprsd import config, fuzzyclock, plugin, plugin_utils, trace from aprsd import fuzzyclock, plugin, plugin_utils, trace
LOG = logging.getLogger("APRSD") LOG = logging.getLogger("APRSD")
@ -64,7 +64,7 @@ class TimeOpenCageDataPlugin(TimePlugin):
# get last location of a callsign, get descriptive name from weather service # get last location of a callsign, get descriptive name from weather service
try: try:
config.check_config_option(self.config, ["services", "aprs.fi", "apiKey"]) self.config.exists(["services", "aprs.fi", "apiKey"])
except Exception as ex: except Exception as ex:
LOG.error(f"Failed to find config aprs.fi:apikey {ex}") LOG.error(f"Failed to find config aprs.fi:apikey {ex}")
return "No aprs.fi apikey found" return "No aprs.fi apikey found"
@ -95,7 +95,7 @@ class TimeOpenCageDataPlugin(TimePlugin):
lon = aprs_data["entries"][0]["lng"] lon = aprs_data["entries"][0]["lng"]
try: try:
config.check_config_option(self.config, "opencagedata", "apiKey") self.config.exists("opencagedata.apiKey")
except Exception as ex: except Exception as ex:
LOG.error(f"Failed to find config opencage:apiKey {ex}") LOG.error(f"Failed to find config opencage:apiKey {ex}")
return "No opencage apiKey found" return "No opencage apiKey found"
@ -130,7 +130,7 @@ class TimeOWMPlugin(TimePlugin):
# get last location of a callsign, get descriptive name from weather service # get last location of a callsign, get descriptive name from weather service
try: try:
config.check_config_option(self.config, ["services", "aprs.fi", "apiKey"]) self.config.exists(["services", "aprs.fi", "apiKey"])
except Exception as ex: except Exception as ex:
LOG.error(f"Failed to find config aprs.fi:apikey {ex}") LOG.error(f"Failed to find config aprs.fi:apikey {ex}")
return "No aprs.fi apikey found" return "No aprs.fi apikey found"
@ -160,8 +160,7 @@ class TimeOWMPlugin(TimePlugin):
lon = aprs_data["entries"][0]["lng"] lon = aprs_data["entries"][0]["lng"]
try: try:
config.check_config_option( self.config.exists(
self.config,
["services", "openweathermap", "apiKey"], ["services", "openweathermap", "apiKey"],
) )
except Exception as ex: except Exception as ex:

View File

@ -4,7 +4,7 @@ import re
import requests import requests
from aprsd import config, plugin, plugin_utils, trace from aprsd import plugin, plugin_utils, trace
LOG = logging.getLogger("APRSD") LOG = logging.getLogger("APRSD")
@ -34,7 +34,7 @@ class USWeatherPlugin(plugin.APRSDRegexCommandPluginBase):
# message = packet.get("message_text", None) # message = packet.get("message_text", None)
# ack = packet.get("msgNo", "0") # ack = packet.get("msgNo", "0")
try: try:
config.check_config_option(self.config, ["services", "aprs.fi", "apiKey"]) self.config.exists(["services", "aprs.fi", "apiKey"])
except Exception as ex: except Exception as ex:
LOG.error(f"Failed to find config aprs.fi:apikey {ex}") LOG.error(f"Failed to find config aprs.fi:apikey {ex}")
return "No aprs.fi apikey found" return "No aprs.fi apikey found"
@ -115,10 +115,7 @@ class USMetarPlugin(plugin.APRSDRegexCommandPluginBase):
fromcall = fromcall fromcall = fromcall
try: try:
config.check_config_option( self.config.exists(["services", "aprs.fi", "apiKey"])
self.config,
["services", "aprs.fi", "apiKey"],
)
except Exception as ex: except Exception as ex:
LOG.error(f"Failed to find config aprs.fi:apikey {ex}") LOG.error(f"Failed to find config aprs.fi:apikey {ex}")
return "No aprs.fi apikey found" return "No aprs.fi apikey found"
@ -199,7 +196,7 @@ class OWMWeatherPlugin(plugin.APRSDRegexCommandPluginBase):
searchcall = fromcall searchcall = fromcall
try: try:
config.check_config_option(self.config, ["services", "aprs.fi", "apiKey"]) self.config.exists(["services", "aprs.fi", "apiKey"])
except Exception as ex: except Exception as ex:
LOG.error(f"Failed to find config aprs.fi:apikey {ex}") LOG.error(f"Failed to find config aprs.fi:apikey {ex}")
return "No aprs.fi apikey found" return "No aprs.fi apikey found"
@ -220,16 +217,13 @@ class OWMWeatherPlugin(plugin.APRSDRegexCommandPluginBase):
lon = aprs_data["entries"][0]["lng"] lon = aprs_data["entries"][0]["lng"]
try: try:
config.check_config_option( self.config.exists(["services", "openweathermap", "apiKey"])
self.config,
["services", "openweathermap", "apiKey"],
)
except Exception as ex: except Exception as ex:
LOG.error(f"Failed to find config openweathermap:apiKey {ex}") LOG.error(f"Failed to find config openweathermap:apiKey {ex}")
return "No openweathermap apiKey found" return "No openweathermap apiKey found"
try: try:
config.check_config_option(self.config, ["aprsd", "units"]) self.config.exists(["aprsd", "units"])
except Exception: except Exception:
LOG.debug("Couldn't find untis in aprsd:services:units") LOG.debug("Couldn't find untis in aprsd:services:units")
units = "metric" units = "metric"
@ -323,7 +317,7 @@ class AVWXWeatherPlugin(plugin.APRSDRegexCommandPluginBase):
searchcall = fromcall searchcall = fromcall
try: try:
config.check_config_option(self.config, ["services", "aprs.fi", "apiKey"]) self.config.exists(["services", "aprs.fi", "apiKey"])
except Exception as ex: except Exception as ex:
LOG.error(f"Failed to find config aprs.fi:apikey {ex}") LOG.error(f"Failed to find config aprs.fi:apikey {ex}")
return "No aprs.fi apikey found" return "No aprs.fi apikey found"
@ -344,13 +338,13 @@ class AVWXWeatherPlugin(plugin.APRSDRegexCommandPluginBase):
lon = aprs_data["entries"][0]["lng"] lon = aprs_data["entries"][0]["lng"]
try: try:
config.check_config_option(self.config, ["services", "avwx", "apiKey"]) self.config.exists(["services", "avwx", "apiKey"])
except Exception as ex: except Exception as ex:
LOG.error(f"Failed to find config avwx:apiKey {ex}") LOG.error(f"Failed to find config avwx:apiKey {ex}")
return "No avwx apiKey found" return "No avwx apiKey found"
try: try:
config.check_config_option(self.config, ["services", "avwx", "base_url"]) self.config.exists(self.config, ["services", "avwx", "base_url"])
except Exception as ex: except Exception as ex:
LOG.debug(f"Didn't find avwx:base_url {ex}") LOG.debug(f"Didn't find avwx:base_url {ex}")
base_url = "https://avwx.rest" base_url = "https://avwx.rest"