Fix Probealarm, use loops "Wachalarm" and "WRD"
This commit is contained in:
parent
af43e7e4fa
commit
42e38c4752
60
helpers.py
60
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 os
|
||||||
import PyPDF2
|
import PyPDF2
|
||||||
@ -27,31 +27,39 @@ def read_pdf(file_path):
|
|||||||
return text
|
return text
|
||||||
|
|
||||||
def get_draeger_json(text):
|
def get_draeger_json(text):
|
||||||
match = re.findall(REGEX, text.replace("\n", ""))
|
data = {}
|
||||||
|
|
||||||
if (len(match) != 0):
|
# Probelarm has another sds format (it is too long so the E coordinate is missing)
|
||||||
data = {}
|
if ("Probealarm" in text.replace("\n", "")):
|
||||||
data["apiKey"] = DRAEGER_API_KEY
|
data["apiKey"] = DRAEGER_API_KEY
|
||||||
|
|
||||||
if(match[0][1].startswith("9")): # 9 => RD (First Rsponder)
|
data["alertingKeyword"] = "WRD"
|
||||||
data["alertingKeyword"] = "Wachalarm"
|
data["alertingKeywordText"] = "Probealarm"
|
||||||
else:
|
|
||||||
data["alertingKeyword"] = match[0][4]
|
|
||||||
data["alertingKeywordText"] = match[0][1] + match[0][2] + match[0][3] + " " + match[0][4]
|
|
||||||
data["street"] = match[0][5]
|
|
||||||
data["houseNumber"] = match[0][6]
|
|
||||||
|
|
||||||
try:
|
|
||||||
city = get_city(match[0][7], match[0][8])
|
|
||||||
data["city"] = city[0] + " " + city[1]
|
|
||||||
data["cityDistrict"] = city[2]
|
|
||||||
except Exception as e:
|
|
||||||
logging.error(f'Fehler: {e}')
|
|
||||||
|
|
||||||
data["lat"] = match[0][7][:2] + '.' + match[0][7][2:]
|
|
||||||
data["lon"] = match[0][8][:2] + '.' + match[0][8][2:]
|
|
||||||
|
|
||||||
logging.debug(data)
|
|
||||||
return data
|
|
||||||
else:
|
else:
|
||||||
return None
|
match = re.findall(REGEX, text.replace("\n", ""))
|
||||||
|
|
||||||
|
if (len(match) != 0):
|
||||||
|
data["apiKey"] = DRAEGER_API_KEY
|
||||||
|
|
||||||
|
if(match[0][1].startswith("9")): # 9 => RD (First Rsponder)
|
||||||
|
data["alertingKeyword"] = "Wachalarm"
|
||||||
|
else:
|
||||||
|
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]
|
||||||
|
|
||||||
|
try:
|
||||||
|
city = get_city(match[0][7], match[0][8])
|
||||||
|
data["city"] = city[0] + " " + city[1]
|
||||||
|
data["cityDistrict"] = city[2]
|
||||||
|
except Exception as e:
|
||||||
|
logging.error(f'Fehler: {e}')
|
||||||
|
|
||||||
|
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
|
16
main.py
16
main.py
@ -60,19 +60,19 @@ def check_email():
|
|||||||
f.write(part.get_payload(decode=True))
|
f.write(part.get_payload(decode=True))
|
||||||
|
|
||||||
if filename.endswith('.pdf'):
|
if filename.endswith('.pdf'):
|
||||||
pdf_text = read_pdf(filepath)
|
pdf_text = read_pdf(filepath)
|
||||||
|
|
||||||
r = requests.post('https://einsatzmeldesystem.de/ems/inbound/deployment/universal/', json=get_draeger_json(pdf_text))
|
r = requests.post('https://einsatzmeldesystem.de/ems/inbound/deployment/universal/', json=get_draeger_json(pdf_text))
|
||||||
|
|
||||||
logging.debug(r.status_code)
|
logging.debug(r.status_code)
|
||||||
logging.debug(r.json())
|
logging.debug(r.json())
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
data = {}
|
pass
|
||||||
data["apiKey"] = DRAEGER_API_KEY
|
#data = {}
|
||||||
r = requests.post('https://einsatzmeldesystem.de/ems/inbound/deployment/universal/', json=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)
|
#r = requests.get(HEALTHCHECK_URL + "?status=down&msg=Can not parse data. Alarming with empty data&ping=")
|
||||||
|
#logging.debug(r.status_code)
|
||||||
|
|
||||||
mail.logout()
|
mail.logout()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
Loading…
Reference in New Issue
Block a user