mirror of
https://github.com/craigerl/aprsd.git
synced 2026-01-26 07:25:36 -05:00
Updates for plugins to make them more consistent.
Got rid of some comment blocks and inconsistent logging messsages
This commit is contained in:
parent
7151cb5d07
commit
ee61bf5fd5
@ -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',
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -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(
|
||||
|
||||
@ -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)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user