Fix Probealarm, use loops "Wachalarm" and "WRD"
This commit is contained in:
parent
af43e7e4fa
commit
42e38c4752
18
helpers.py
18
helpers.py
@ -1,4 +1,4 @@
|
||||
REGEX = r"SDS_ILS_BEGINN\s*(#D#Leitstelle:\s*)(?P<number>\d*)(?P<sonderrechte>m|o|i)?(?P<fzg>RTW|NAW|KTW)? (?P<keyword>Trauma Gesicht\/|Atemnot Akut|Trauma Extremit|Abdomen Akut|Person droht zu spr|Hilflose Person|\S*|)(?P<address>\D*)(.*) \$GPS\s*N(.*)E(.*)\s*SDS_ILS_ENDE"
|
||||
REGEX = r"SDS_ILS_BEGINN\s*(#D#Leitstelle:\s*)(?P<number>\d*)(?P<sonderrechte>m|o|i)?(?P<fzg>RTW|NAW|KTW)? (?P<keyword>Trauma Gesicht\/|Atemnot Akut|Trauma Extremit|Abdomen Akut|Person droht zu spr|Hilflose Person|\S*|)(?P<address>\D*)(.*)\s*\$GPS\s*N(.*)E(.*)\s*SDS_ILS_ENDE"
|
||||
|
||||
import os
|
||||
import PyPDF2
|
||||
@ -27,16 +27,24 @@ def read_pdf(file_path):
|
||||
return text
|
||||
|
||||
def get_draeger_json(text):
|
||||
data = {}
|
||||
|
||||
# Probelarm has another sds format (it is too long so the E coordinate is missing)
|
||||
if ("Probealarm" in text.replace("\n", "")):
|
||||
data["apiKey"] = DRAEGER_API_KEY
|
||||
|
||||
data["alertingKeyword"] = "WRD"
|
||||
data["alertingKeywordText"] = "Probealarm"
|
||||
else:
|
||||
match = re.findall(REGEX, text.replace("\n", ""))
|
||||
|
||||
if (len(match) != 0):
|
||||
data = {}
|
||||
data["apiKey"] = DRAEGER_API_KEY
|
||||
|
||||
if(match[0][1].startswith("9")): # 9 => RD (First Rsponder)
|
||||
data["alertingKeyword"] = "Wachalarm"
|
||||
else:
|
||||
data["alertingKeyword"] = match[0][4]
|
||||
data["alertingKeyword"] = "WRD"
|
||||
data["alertingKeywordText"] = match[0][1] + match[0][2] + match[0][3] + " " + match[0][4]
|
||||
data["street"] = match[0][5]
|
||||
data["houseNumber"] = match[0][6]
|
||||
@ -50,8 +58,8 @@ def get_draeger_json(text):
|
||||
|
||||
data["lat"] = match[0][7][:2] + '.' + match[0][7][2:]
|
||||
data["lon"] = match[0][8][:2] + '.' + match[0][8][2:]
|
||||
else:
|
||||
return None
|
||||
|
||||
logging.debug(data)
|
||||
return data
|
||||
else:
|
||||
return None
|
14
main.py
14
main.py
@ -61,18 +61,18 @@ def check_email():
|
||||
|
||||
if filename.endswith('.pdf'):
|
||||
pdf_text = read_pdf(filepath)
|
||||
|
||||
r = requests.post('https://einsatzmeldesystem.de/ems/inbound/deployment/universal/', json=get_draeger_json(pdf_text))
|
||||
|
||||
logging.debug(r.status_code)
|
||||
logging.debug(r.json())
|
||||
except Exception as e:
|
||||
data = {}
|
||||
data["apiKey"] = DRAEGER_API_KEY
|
||||
r = requests.post('https://einsatzmeldesystem.de/ems/inbound/deployment/universal/', json=data)
|
||||
|
||||
r = requests.get(HEALTHCHECK_URL + "?status=down&msg=Can not parse data. Alarming with empty data&ping=")
|
||||
logging.debug(r.status_code)
|
||||
pass
|
||||
#data = {}
|
||||
#data["apiKey"] = DRAEGER_API_KEY
|
||||
#r = requests.post('https://einsatzmeldesystem.de/ems/inbound/deployment/universal/', json=data)
|
||||
#
|
||||
#r = requests.get(HEALTHCHECK_URL + "?status=down&msg=Can not parse data. Alarming with empty data&ping=")
|
||||
#logging.debug(r.status_code)
|
||||
|
||||
mail.logout()
|
||||
except Exception as e:
|
||||
|
Loading…
Reference in New Issue
Block a user