diff --git a/aprsd/plugin.py b/aprsd/plugin.py index 6c9defe..499bbe5 100644 --- a/aprsd/plugin.py +++ b/aprsd/plugin.py @@ -22,9 +22,7 @@ CONF = cfg.CONF LOG = logging.getLogger('APRSD') CORE_MESSAGE_PLUGINS = [ - 'aprsd.plugins.email.EmailPlugin', 'aprsd.plugins.fortune.FortunePlugin', - 'aprsd.plugins.location.LocationPlugin', 'aprsd.plugins.ping.PingPlugin', 'aprsd.plugins.time.TimePlugin', 'aprsd.plugins.weather.USWeatherPlugin', diff --git a/aprsd/plugins/fortune.py b/aprsd/plugins/fortune.py index 9482022..94666ff 100644 --- a/aprsd/plugins/fortune.py +++ b/aprsd/plugins/fortune.py @@ -3,7 +3,6 @@ import shutil import subprocess from aprsd import packets, plugin -from aprsd.utils import trace LOG = logging.getLogger('APRSD') @@ -34,16 +33,9 @@ class FortunePlugin(plugin.APRSDRegexCommandPluginBase): else: self.enabled = True - @trace.trace - def process(self, packet: packets.MessagePacket): + def process(self, packet: packets.MessagePacket) -> str: LOG.info('FortunePlugin') - - # fromcall = packet.get("from") - # message = packet.get("message_text", None) - # ack = packet.get("msgNo", "0") - - reply = None - + reply = packets.NULL_MESSAGE try: cmnd = [self.fortune_path, '-s', '-n 60'] command = ' '.join(cmnd) diff --git a/aprsd/plugins/notify.py b/aprsd/plugins/notify.py index 30fb9cd..639cf80 100644 --- a/aprsd/plugins/notify.py +++ b/aprsd/plugins/notify.py @@ -19,7 +19,7 @@ class NotifySeenPlugin(plugin.APRSDWatchListPluginBase): short_description = 'Notify me when a CALLSIGN is recently seen on APRS-IS' - def process(self, packet: packets.MessagePacket): + def process(self, packet: packets.MessagePacket) -> packets.MessagePacket: LOG.info('NotifySeenPlugin') notify_callsign = CONF.watch_list.alert_callsign diff --git a/aprsd/plugins/ping.py b/aprsd/plugins/ping.py index 1f85073..6540fd1 100644 --- a/aprsd/plugins/ping.py +++ b/aprsd/plugins/ping.py @@ -1,8 +1,7 @@ import logging import time -from aprsd import plugin -from aprsd.utils import trace +from aprsd import packets, plugin LOG = logging.getLogger('APRSD') @@ -14,12 +13,8 @@ class PingPlugin(plugin.APRSDRegexCommandPluginBase): command_name = 'ping' short_description = 'reply with a Pong!' - @trace.trace - def process(self, packet): + def process(self, packet: packets.MessagePacket) -> str: LOG.info('PingPlugin') - # fromcall = packet.get("from") - # message = packet.get("message_text", None) - # ack = packet.get("msgNo", "0") stm = time.localtime() h = stm.tm_hour m = stm.tm_min diff --git a/aprsd/plugins/time.py b/aprsd/plugins/time.py index 5f4d75b..b47893f 100644 --- a/aprsd/plugins/time.py +++ b/aprsd/plugins/time.py @@ -5,7 +5,7 @@ from oslo_config import cfg from tzlocal import get_localzone from aprsd import packets, plugin -from aprsd.utils import fuzzy, trace +from aprsd.utils import fuzzy CONF = cfg.CONF LOG = logging.getLogger('APRSD') @@ -43,9 +43,8 @@ class TimePlugin(plugin.APRSDRegexCommandPluginBase): return reply - @trace.trace - def process(self, packet: packets.Packet): - LOG.info('TIME COMMAND') + def process(self, packet: packets.MessagePacket) -> str: + LOG.info('TimePlugin') # So we can mock this in unit tests localzone = self._get_local_tz() return self.build_date_str(localzone) diff --git a/aprsd/plugins/version.py b/aprsd/plugins/version.py index 24f4b72..8c4b1cb 100644 --- a/aprsd/plugins/version.py +++ b/aprsd/plugins/version.py @@ -1,7 +1,7 @@ import logging import aprsd -from aprsd import conf, plugin +from aprsd import conf, packets, plugin from aprsd.stats import collector LOG = logging.getLogger('APRSD') @@ -18,11 +18,8 @@ class VersionPlugin(plugin.APRSDRegexCommandPluginBase): # five mins {int:int} email_sent_dict = {} - def process(self, packet): - LOG.info('Version COMMAND') - # fromcall = packet.get("from") - # message = packet.get("message_text", None) - # ack = packet.get("msgNo", "0") + def process(self, packet: packets.MessagePacket) -> str: + LOG.info('VersionPlugin') s = collector.Collector().collect() owner = conf.CONF.owner_callsign or '-' return 'APRSD ver:{} uptime:{} owner:{}'.format( diff --git a/aprsd/plugins/weather.py b/aprsd/plugins/weather.py index 879c3b5..6da4a9c 100644 --- a/aprsd/plugins/weather.py +++ b/aprsd/plugins/weather.py @@ -4,8 +4,7 @@ import re from oslo_config import cfg -from aprsd import plugin, plugin_utils -from aprsd.utils import trace +from aprsd import packets, plugin, plugin_utils CONF = cfg.CONF LOG = logging.getLogger('APRSD') @@ -24,7 +23,6 @@ class USWeatherPlugin(plugin.APRSDRegexCommandPluginBase, plugin.APRSFIKEYMixin) "weather" - returns weather near the calling callsign """ - # command_regex = r"^([w][x]|[w][x]\s|weather)" command_regex = r'^[wW]' command_name = 'USWeather' @@ -33,13 +31,10 @@ class USWeatherPlugin(plugin.APRSDRegexCommandPluginBase, plugin.APRSFIKEYMixin) def setup(self): self.ensure_aprs_fi_key() - @trace.trace - def process(self, packet): - LOG.info('Weather Plugin') + def process(self, packet: packets.MessagePacket) -> str: + LOG.info('USWeatherPlugin') fromcall = packet.from_call - message = packet.get('message_text', None) - # message = packet.get("message_text", None) - # ack = packet.get("msgNo", "0") + message = packet.message_text a = re.search(r'^.*\s+(.*)', message) if a is not None: searchcall = a.group(1) @@ -67,7 +62,7 @@ class USWeatherPlugin(plugin.APRSDRegexCommandPluginBase, plugin.APRSFIKEYMixin) LOG.error(f"Couldn't fetch forecast.weather.gov '{ex}'") return 'Unable to get weather' - LOG.info(f'WX data {wx_data}') + LOG.debug(f'WX data {wx_data}') reply = ( '%sF(%sF/%sF) %s. %s, %s.' @@ -106,12 +101,10 @@ class USMetarPlugin(plugin.APRSDRegexCommandPluginBase, plugin.APRSFIKEYMixin): def setup(self): self.ensure_aprs_fi_key() - @trace.trace - def process(self, packet): - fromcall = packet.get('from') - message = packet.get('message_text', None) - # ack = packet.get("msgNo", "0") - LOG.info(f"WX Plugin '{message}'") + def process(self, packet: packets.MessagePacket) -> str: + LOG.info('USMetarPlugin') + fromcall = packet.from_call + message = packet.message_text a = re.search(r'^.*\s+(.*)', message) if a is not None: searchcall = a.group(1)