mirror of
https://github.com/craigerl/aprsd.git
synced 2024-11-26 18:08:36 -05:00
Compare commits
3 Commits
7863103f12
...
c0e17c1f1e
Author | SHA1 | Date | |
---|---|---|---|
|
c0e17c1f1e | ||
f265e8f354 | |||
|
1334eded62 |
@ -14,7 +14,10 @@ from aprsd.main import cli
|
||||
|
||||
|
||||
os.environ["APRSD_ADMIN_COMMAND"] = "1"
|
||||
from aprsd import wsgi as aprsd_wsgi
|
||||
# this import has to happen AFTER we set the
|
||||
# above environment variable, so that the code
|
||||
# inside the wsgi.py has the value
|
||||
from aprsd import wsgi as aprsd_wsgi # noqa
|
||||
|
||||
|
||||
CONF = cfg.CONF
|
||||
|
@ -136,6 +136,11 @@ aprsd_opts = [
|
||||
default=True,
|
||||
help="Set this to False, to disable logging of packets to the log file.",
|
||||
),
|
||||
cfg.BoolOpt(
|
||||
"load_help_plugin",
|
||||
default=True,
|
||||
help="Set this to False to disable the help plugin.",
|
||||
),
|
||||
]
|
||||
|
||||
watch_list_opts = [
|
||||
|
@ -472,9 +472,13 @@ class PluginManager:
|
||||
del self._pluggy_pm
|
||||
self.setup_plugins()
|
||||
|
||||
def setup_plugins(self, load_help_plugin=True):
|
||||
def setup_plugins(self, load_help_plugin=None):
|
||||
"""Create the plugin manager and register plugins."""
|
||||
|
||||
# If load_help_plugin is not specified, load it from the config
|
||||
if load_help_plugin is None:
|
||||
load_help_plugin = CONF.load_help_plugin
|
||||
|
||||
LOG.info("Loading APRSD Plugins")
|
||||
# Help plugin is always enabled.
|
||||
if load_help_plugin:
|
||||
|
@ -328,8 +328,22 @@ class APRSDPluginProcessPacketThread(APRSDProcessPacketThread):
|
||||
# If the message was for us and we didn't have a
|
||||
# response, then we send a usage statement.
|
||||
if to_call == CONF.callsign and not replied:
|
||||
|
||||
# Is the help plugin installed?
|
||||
help_available = False
|
||||
for p in pm.get_message_plugins():
|
||||
if isinstance(p, plugin.HelpPlugin):
|
||||
help_available = True
|
||||
break
|
||||
|
||||
# Tailor the messages accordingly
|
||||
if help_available:
|
||||
LOG.warning("Sending help!")
|
||||
message_text = "Unknown command! Send 'help' message for help"
|
||||
else:
|
||||
LOG.warning("Unknown command!")
|
||||
message_text = "Unknown command!"
|
||||
|
||||
tx.send(
|
||||
packets.MessagePacket(
|
||||
from_call=CONF.callsign,
|
||||
|
@ -89,6 +89,9 @@ def _send_direct(packet, aprs_client=None):
|
||||
except Exception as e:
|
||||
LOG.error(f"Failed to send packet: {packet}")
|
||||
LOG.error(e)
|
||||
return False
|
||||
else:
|
||||
return True
|
||||
|
||||
|
||||
class SendPacketThread(aprsd_threads.APRSDThread):
|
||||
@ -150,7 +153,16 @@ class SendPacketThread(aprsd_threads.APRSDThread):
|
||||
# no attempt time, so lets send it, and start
|
||||
# tracking the time.
|
||||
packet.last_send_time = int(round(time.time()))
|
||||
_send_direct(packet)
|
||||
sent = False
|
||||
try:
|
||||
sent = _send_direct(packet)
|
||||
except Exception:
|
||||
LOG.error(f"Failed to send packet: {packet}")
|
||||
else:
|
||||
# If an exception happens while sending
|
||||
# we don't want this attempt to count
|
||||
# against the packet
|
||||
if sent:
|
||||
packet.send_count += 1
|
||||
|
||||
time.sleep(1)
|
||||
@ -199,8 +211,18 @@ class SendAckThread(aprsd_threads.APRSDThread):
|
||||
send_now = True
|
||||
|
||||
if send_now:
|
||||
_send_direct(self.packet)
|
||||
sent = False
|
||||
try:
|
||||
sent = _send_direct(self.packet)
|
||||
except Exception:
|
||||
LOG.error(f"Failed to send packet: {self.packet}")
|
||||
else:
|
||||
# If an exception happens while sending
|
||||
# we don't want this attempt to count
|
||||
# against the packet
|
||||
if sent:
|
||||
self.packet.send_count += 1
|
||||
|
||||
self.packet.last_send_time = int(round(time.time()))
|
||||
|
||||
time.sleep(1)
|
||||
|
@ -269,7 +269,6 @@ def init_app(config_file=None, log_level=None):
|
||||
|
||||
return log_level
|
||||
|
||||
print(f"__name__ = {__name__}")
|
||||
|
||||
if __name__ == "__main__":
|
||||
async_mode = "threading"
|
||||
|
Loading…
Reference in New Issue
Block a user