1
0
mirror of https://github.com/craigerl/aprsd.git synced 2026-08-01 16:38:36 -04:00

Fixed fortune plugin failures

On alpine containers the fortune options aren't all available
and we were silently failing.  Updated the fortune plugin to capture
shell failures.
This commit is contained in:
2021-01-11 14:13:20 -05:00
parent 76bbdfc728
commit 7ab26135c2
+11 -8
View File
@@ -24,14 +24,17 @@ class FortunePlugin(plugin.APRSDPluginBase):
return reply
try:
process = subprocess.Popen(
[fortune_path, "-s", "-n 60"],
stdout=subprocess.PIPE,
cmnd = [fortune_path, "-s", "-n 60"]
command = " ".join(cmnd)
output = subprocess.check_output(
command,
shell=True,
timeout=3,
universal_newlines=True,
)
reply = process.communicate()[0]
reply = reply.decode(errors="ignore").rstrip()
except Exception as ex:
reply = "Fortune command failed '{}'".format(ex)
LOG.error(reply)
except subprocess.CalledProcessError as ex:
reply = "Fortune command failed '{}'".format(ex.output)
else:
reply = output
return reply