small improvements and dont mail mark seen
continuous-integration/drone/push Build is passing Details

By using BODY.PEEK[] messages are not implicitely marked seen which
allows to set them seen when it could be processed. Might help to
reiterate over mails until the record is ready in Lodur.
This commit is contained in:
Tobias Brunner 2021-02-27 20:33:23 +01:00
parent 5aae306119
commit 8a22747315
4 changed files with 11 additions and 8 deletions

View File

@ -60,7 +60,7 @@ class EmailHandling:
data = {}
for msg_id in msg_ids[0].split():
# download message from imap
typ, msg_data = self.imap.fetch(msg_id, "(RFC822)")
typ, msg_data = self.imap.fetch(msg_id, "(BODY.PEEK[])")
if typ != "OK":
self.logger.error("Error fetching message")

View File

@ -127,7 +127,7 @@ class Lodur:
else:
return None
def einsatzprotokoll(self, f_id, lodur_data, webdav_client):
def einsatzprotokoll(self, f_id, lodur_data, pdf_data, webdav_client):
""" Prepare Einsatzprotokoll to be sent to Lodur """
self.logger.info("[%s] Updating Lodur entry", f_id)
@ -138,9 +138,9 @@ class Lodur:
lodur_data["ztb_m"] = lodur_data[
"ztv_m"
] # 05. Zeit (copy minute from start to round up to 1h)
lodur_data["eins_ereig"] = "{} - {} - {}".format(
f_id, lodur_data["ala_stich"], lodur_data["adr"]
) # 07. Ereignis
lodur_data[
"eins_ereig"
] = f"{f_id} - {pdf_data['einsatz']} - {lodur_data['adr']}" # 07. Ereignis
lodur_data["en_kr_feuwehr"] = "1" # 21. Einsatzkräfte
lodur_data["ali_io"] = "1" # 24. Alarmierung
lodur_data["keyword_els_zutreffend"] = "1" # 25. Stichwort

View File

@ -170,6 +170,7 @@ def main():
elif f_type == "Einsatzprotokoll":
lodur_id = webdav_client.get_lodur_data(f_id)["event_id"]
pdf_data = webdav_client.get_lodur_data(f_id, "_pdf.json")
logger.info(
"[%s] Processing type %s with Lodur ID %s",
f_id,
@ -195,12 +196,14 @@ def main():
)
# Update entry in Lodur
lodur_client.einsatzprotokoll(f_id, lodur_data, webdav_client)
lodur_client.einsatzprotokoll(
f_id, lodur_data, pdf_data, webdav_client
)
# Einsatz finished - publish on pushover
logger.info("[%s] Publishing message on Pushover", f_id)
pushover.send_message(
"Einsatz {} beendet".format(f_id),
"Einsatz beendet",
title="Feuerwehr Einsatz beendet - {}".format(f_id),
)

View File

@ -1,6 +1,6 @@
[tool.poetry]
name = "pylokid"
version = "3.0.2"
version = "3.0.3"
description = ""
authors = ["Tobias Brunner <tobias@tobru.ch>"]
license = "MIT"