mirror of
https://github.com/craigerl/aprsd.git
synced 2024-11-21 23:55:17 -05:00
Compare commits
2 Commits
b00c8db3d6
...
03a20ebb5c
Author | SHA1 | Date | |
---|---|---|---|
03a20ebb5c | |||
6257c9ea90 |
@ -1,9 +1,17 @@
|
|||||||
CHANGES
|
CHANGES
|
||||||
=======
|
=======
|
||||||
|
|
||||||
|
v2.5.9
|
||||||
|
------
|
||||||
|
|
||||||
|
* FIX: logging exceptions
|
||||||
|
* Updated build and run for rich lib
|
||||||
|
* update build for 2.5.8
|
||||||
|
|
||||||
v2.5.8
|
v2.5.8
|
||||||
------
|
------
|
||||||
|
|
||||||
|
* For 2.5.8
|
||||||
* Removed debug code
|
* Removed debug code
|
||||||
* Updated list-plugins
|
* Updated list-plugins
|
||||||
* Renamed virtualenv dir to .aprsd-venv
|
* Renamed virtualenv dir to .aprsd-venv
|
||||||
|
@ -437,7 +437,8 @@ class PluginManager:
|
|||||||
)
|
)
|
||||||
self._pluggy_pm.register(plugin_obj)
|
self._pluggy_pm.register(plugin_obj)
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
LOG.exception(f"Couldn't load plugin '{plugin_name}'", ex)
|
LOG.error(f"Couldn't load plugin '{plugin_name}'")
|
||||||
|
LOG.exception(ex)
|
||||||
|
|
||||||
def reload_plugins(self):
|
def reload_plugins(self):
|
||||||
with self.lock:
|
with self.lock:
|
||||||
|
@ -193,8 +193,8 @@ def _imap_connect(config):
|
|||||||
ssl=use_ssl,
|
ssl=use_ssl,
|
||||||
timeout=30,
|
timeout=30,
|
||||||
)
|
)
|
||||||
except Exception as e:
|
except Exception:
|
||||||
LOG.error("Failed to connect IMAP server", e)
|
LOG.exception("Failed to connect IMAP server")
|
||||||
return
|
return
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@ -348,8 +348,8 @@ def parse_email(msgid, data, server):
|
|||||||
LOG.debug(f"Got a message from '{from_addr}'")
|
LOG.debug(f"Got a message from '{from_addr}'")
|
||||||
try:
|
try:
|
||||||
m = server.fetch([msgid], ["RFC822"])
|
m = server.fetch([msgid], ["RFC822"])
|
||||||
except Exception as e:
|
except Exception:
|
||||||
LOG.exception("Couldn't fetch email from server in parse_email", e)
|
LOG.exception("Couldn't fetch email from server in parse_email")
|
||||||
return
|
return
|
||||||
|
|
||||||
msg = email.message_from_string(m[msgid][b"RFC822"].decode(errors="ignore"))
|
msg = email.message_from_string(m[msgid][b"RFC822"].decode(errors="ignore"))
|
||||||
@ -414,9 +414,9 @@ def parse_email(msgid, data, server):
|
|||||||
# it below, also with errors='ignore'
|
# it below, also with errors='ignore'
|
||||||
try:
|
try:
|
||||||
body = body.decode(errors="ignore")
|
body = body.decode(errors="ignore")
|
||||||
except Exception as e:
|
except Exception:
|
||||||
LOG.error("Unicode decode failure: " + str(e))
|
LOG.exception("Unicode decode failure")
|
||||||
LOG.error("Unidoce decode failed: " + str(body))
|
LOG.error(f"Unidoce decode failed: {str(body)}")
|
||||||
body = "Unreadable unicode msg"
|
body = "Unreadable unicode msg"
|
||||||
# strip all html tags
|
# strip all html tags
|
||||||
body = re.sub("<[^<]+?>", "", body)
|
body = re.sub("<[^<]+?>", "", body)
|
||||||
@ -437,13 +437,13 @@ def send_email(config, to_addr, content):
|
|||||||
LOG.info("Sending Email_________________")
|
LOG.info("Sending Email_________________")
|
||||||
|
|
||||||
if to_addr in shortcuts:
|
if to_addr in shortcuts:
|
||||||
LOG.info("To : " + to_addr)
|
LOG.info(f"To : {to_addr}")
|
||||||
to_addr = email_address
|
to_addr = email_address
|
||||||
LOG.info(" (" + to_addr + ")")
|
LOG.info(f" ({to_addr})")
|
||||||
subject = config["ham"]["callsign"]
|
subject = config["ham"]["callsign"]
|
||||||
# content = content + "\n\n(NOTE: reply with one line)"
|
# content = content + "\n\n(NOTE: reply with one line)"
|
||||||
LOG.info("Subject : " + subject)
|
LOG.info(f"Subject : {subject}")
|
||||||
LOG.info("Body : " + content)
|
LOG.info(f"Body : {content}")
|
||||||
|
|
||||||
# check email more often since there's activity right now
|
# check email more often since there's activity right now
|
||||||
EmailInfo().delay = 60
|
EmailInfo().delay = 60
|
||||||
@ -461,9 +461,8 @@ def send_email(config, to_addr, content):
|
|||||||
msg.as_string(),
|
msg.as_string(),
|
||||||
)
|
)
|
||||||
stats.APRSDStats().email_tx_inc()
|
stats.APRSDStats().email_tx_inc()
|
||||||
except Exception as e:
|
except Exception:
|
||||||
msg = getattr(e, "message", repr(e))
|
LOG.exception("Sendmail Error!!!!")
|
||||||
LOG.error("Sendmail Error!!!! '{}'", msg)
|
|
||||||
server.quit()
|
server.quit()
|
||||||
return -1
|
return -1
|
||||||
server.quit()
|
server.quit()
|
||||||
@ -484,14 +483,14 @@ def resend_email(config, count, fromcall):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
server = _imap_connect(config)
|
server = _imap_connect(config)
|
||||||
except Exception as e:
|
except Exception:
|
||||||
LOG.exception("Failed to Connect to IMAP. Cannot resend email ", e)
|
LOG.exception("Failed to Connect to IMAP. Cannot resend email ")
|
||||||
return
|
return
|
||||||
|
|
||||||
try:
|
try:
|
||||||
messages = server.search(["SINCE", today])
|
messages = server.search(["SINCE", today])
|
||||||
except Exception as e:
|
except Exception:
|
||||||
LOG.exception("Couldn't search for emails in resend_email ", e)
|
LOG.exception("Couldn't search for emails in resend_email ")
|
||||||
return
|
return
|
||||||
|
|
||||||
# LOG.debug("%d messages received today" % len(messages))
|
# LOG.debug("%d messages received today" % len(messages))
|
||||||
@ -503,8 +502,8 @@ def resend_email(config, count, fromcall):
|
|||||||
for message in messages:
|
for message in messages:
|
||||||
try:
|
try:
|
||||||
parts = server.fetch(message, ["ENVELOPE"]).items()
|
parts = server.fetch(message, ["ENVELOPE"]).items()
|
||||||
except Exception as e:
|
except Exception:
|
||||||
LOG.exception("Couldn't fetch email parts in resend_email", e)
|
LOG.exception("Couldn't fetch email parts in resend_email")
|
||||||
continue
|
continue
|
||||||
|
|
||||||
for msgid, data in list(parts):
|
for msgid, data in list(parts):
|
||||||
@ -513,8 +512,8 @@ def resend_email(config, count, fromcall):
|
|||||||
# unset seen flag, will stay bold in email client
|
# unset seen flag, will stay bold in email client
|
||||||
try:
|
try:
|
||||||
server.remove_flags(msgid, [imapclient.SEEN])
|
server.remove_flags(msgid, [imapclient.SEEN])
|
||||||
except Exception as e:
|
except Exception:
|
||||||
LOG.exception("Failed to remove SEEN flag in resend_email", e)
|
LOG.exception("Failed to remove SEEN flag in resend_email")
|
||||||
|
|
||||||
if from_addr in shortcuts_inverted:
|
if from_addr in shortcuts_inverted:
|
||||||
# reverse lookup of a shortcut
|
# reverse lookup of a shortcut
|
||||||
@ -592,24 +591,21 @@ class APRSDEmailThread(threads.APRSDThread):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
server = _imap_connect(self.config)
|
server = _imap_connect(self.config)
|
||||||
except Exception as e:
|
except Exception:
|
||||||
LOG.exception("IMAP failed to connect.", e)
|
LOG.exception("IMAP Failed to connect")
|
||||||
return True
|
return True
|
||||||
|
|
||||||
try:
|
try:
|
||||||
messages = server.search(["SINCE", today])
|
messages = server.search(["SINCE", today])
|
||||||
except Exception as e:
|
except Exception:
|
||||||
LOG.exception(
|
LOG.exception("IMAP failed to search for messages since today.")
|
||||||
"IMAP failed to search for messages since today.",
|
|
||||||
e,
|
|
||||||
)
|
|
||||||
return True
|
return True
|
||||||
LOG.debug(f"{len(messages)} messages received today")
|
LOG.debug(f"{len(messages)} messages received today")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
_msgs = server.fetch(messages, ["ENVELOPE"])
|
_msgs = server.fetch(messages, ["ENVELOPE"])
|
||||||
except Exception as e:
|
except Exception:
|
||||||
LOG.exception("IMAP failed to fetch/flag messages: ", e)
|
LOG.exception("IMAP failed to fetch/flag messages: ")
|
||||||
return True
|
return True
|
||||||
|
|
||||||
for msgid, data in _msgs.items():
|
for msgid, data in _msgs.items():
|
||||||
@ -637,27 +633,24 @@ class APRSDEmailThread(threads.APRSDThread):
|
|||||||
x.decode(errors="ignore")
|
x.decode(errors="ignore")
|
||||||
for x in server.get_flags(msgid)[msgid]
|
for x in server.get_flags(msgid)[msgid]
|
||||||
]
|
]
|
||||||
except Exception as e:
|
except Exception:
|
||||||
LOG.exception("Failed to get flags.", e)
|
LOG.error("Failed to get flags.")
|
||||||
break
|
break
|
||||||
|
|
||||||
if "APRS" not in taglist:
|
if "APRS" not in taglist:
|
||||||
# if msg not flagged as sent via aprs
|
# if msg not flagged as sent via aprs
|
||||||
try:
|
try:
|
||||||
server.fetch([msgid], ["RFC822"])
|
server.fetch([msgid], ["RFC822"])
|
||||||
except Exception as e:
|
except Exception:
|
||||||
LOG.exception(
|
LOG.exception("Failed single server fetch for RFC822")
|
||||||
"Failed single server fetch for RFC822",
|
|
||||||
e,
|
|
||||||
)
|
|
||||||
break
|
break
|
||||||
|
|
||||||
(body, from_addr) = parse_email(msgid, data, server)
|
(body, from_addr) = parse_email(msgid, data, server)
|
||||||
# unset seen flag, will stay bold in email client
|
# unset seen flag, will stay bold in email client
|
||||||
try:
|
try:
|
||||||
server.remove_flags(msgid, [imapclient.SEEN])
|
server.remove_flags(msgid, [imapclient.SEEN])
|
||||||
except Exception as e:
|
except Exception:
|
||||||
LOG.exception("Failed to remove flags SEEN", e)
|
LOG.exception("Failed to remove flags SEEN")
|
||||||
# Not much we can do here, so lets try and
|
# Not much we can do here, so lets try and
|
||||||
# send the aprs message anyway
|
# send the aprs message anyway
|
||||||
|
|
||||||
@ -676,13 +669,13 @@ class APRSDEmailThread(threads.APRSDThread):
|
|||||||
try:
|
try:
|
||||||
server.add_flags(msgid, ["APRS"])
|
server.add_flags(msgid, ["APRS"])
|
||||||
# unset seen flag, will stay bold in email client
|
# unset seen flag, will stay bold in email client
|
||||||
except Exception as e:
|
except Exception:
|
||||||
LOG.exception("Couldn't add APRS flag to email", e)
|
LOG.exception("Couldn't add APRS flag to email")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
server.remove_flags(msgid, [imapclient.SEEN])
|
server.remove_flags(msgid, [imapclient.SEEN])
|
||||||
except Exception as e:
|
except Exception:
|
||||||
LOG.exception("Couldn't remove seen flag from email", e)
|
LOG.exception("Couldn't remove seen flag from email")
|
||||||
|
|
||||||
# check email more often since we just received an email
|
# check email more often since we just received an email
|
||||||
EmailInfo().delay = 60
|
EmailInfo().delay = 60
|
||||||
@ -692,8 +685,8 @@ class APRSDEmailThread(threads.APRSDThread):
|
|||||||
self.past = datetime.datetime.now()
|
self.past = datetime.datetime.now()
|
||||||
try:
|
try:
|
||||||
server.logout()
|
server.logout()
|
||||||
except Exception as e:
|
except Exception:
|
||||||
LOG.exception("IMAP failed to logout: ", e)
|
LOG.exception("IMAP failed to logout: ")
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
# We haven't hit the email delay yet.
|
# We haven't hit the email delay yet.
|
||||||
|
@ -208,7 +208,7 @@ class APRSDProcessPacketThread(APRSDThread):
|
|||||||
ack_num = packet.get("msgNo")
|
ack_num = packet.get("msgNo")
|
||||||
LOG.info(f"Got ack for message {ack_num}")
|
LOG.info(f"Got ack for message {ack_num}")
|
||||||
messaging.log_message(
|
messaging.log_message(
|
||||||
"ACK",
|
"RXACK",
|
||||||
packet["raw"],
|
packet["raw"],
|
||||||
None,
|
None,
|
||||||
ack=ack_num,
|
ack=ack_num,
|
||||||
@ -311,7 +311,8 @@ class APRSDProcessPacketThread(APRSDThread):
|
|||||||
)
|
)
|
||||||
msg.send()
|
msg.send()
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
LOG.exception("Plugin failed!!!", ex)
|
LOG.error("Plugin failed!!!")
|
||||||
|
LOG.exception(ex)
|
||||||
# Do we need to send a reply?
|
# Do we need to send a reply?
|
||||||
if tocall == self.config["aprs"]["login"]:
|
if tocall == self.config["aprs"]["login"]:
|
||||||
reply = "A Plugin failed! try again?"
|
reply = "A Plugin failed! try again?"
|
||||||
|
Loading…
Reference in New Issue
Block a user