mirror of
https://github.com/Schrolli91/BOSWatch.git
synced 2026-04-04 14:07:25 +00:00
change string converting for NMA and firE plugins #73
This commit is contained in:
parent
30320b3c71
commit
28936d68ec
6 changed files with 189 additions and 88 deletions
|
|
@ -18,6 +18,8 @@ import socket
|
|||
from includes import globals # Global variables
|
||||
|
||||
from includes.helper import configHandler
|
||||
from includes.helper import stringConverter
|
||||
|
||||
|
||||
###
|
||||
#
|
||||
|
|
@ -85,7 +87,8 @@ def run(typ,freq,data):
|
|||
elif typ == "ZVEI":
|
||||
logging.debug("ZVEI to firEmergency")
|
||||
try:
|
||||
firXML = "<event>\n<address>"+data["zvei"]+"</address>\n<description>"+data["description"]+"</description>\n<message>"+data["zvei"]+" alarmiert.</message>\n</event>\n"
|
||||
description = stringConverter.convertToUTF8(data["description"])
|
||||
firXML = "<event>\n<address>"+data["zvei"]+"</address>\n<description>"+description+"</description>\n<message>"+data["zvei"]+"</message>\n</event>\n"
|
||||
firSocket.send(firXML)
|
||||
except:
|
||||
logging.error("%s to firEmergency failed", typ)
|
||||
|
|
@ -97,7 +100,9 @@ def run(typ,freq,data):
|
|||
logging.debug("POC to firEmergency")
|
||||
try:
|
||||
# !!! Subric+"XX" because of an Issuse in firEmergency !!!
|
||||
firXML = "<event>\n<address>"+data["ric"]+"</address>\n<status>"+data["function"]+"XX</status>\n<description>"+data["description"]+"</description>\n<message>"+data["msg"]+"</message>\n</event>\n"
|
||||
description = stringConverter.convertToUTF8(data["description"])
|
||||
msg = stringConverter.convertToUTF8(data["msg"])
|
||||
firXML = "<event>\n<address>"+data["ric"]+"</address>\n<status>"+data["function"]+"XX</status>\n<description>"+description+"</description>\n<message>"+msg+"</message>\n</event>\n"
|
||||
firSocket.send(firXML)
|
||||
except:
|
||||
logging.error("%s to firEmergency failed", typ)
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: UTF-8 -*-
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
notifyMyAndroid-Plugin to dispatch FMS-, ZVEI- and POCSAG-messages via UDP/TCP
|
||||
|
|
@ -20,7 +20,7 @@ from includes import globals # Global variables
|
|||
|
||||
from includes.helper import configHandler
|
||||
from includes.helper import timeHandler
|
||||
from includes.helper import uft8Converter # UTF-8 converter
|
||||
from includes.helper import stringConverter
|
||||
from includes.pynma import pynma
|
||||
|
||||
|
||||
|
|
@ -93,7 +93,7 @@ def onLoad():
|
|||
|
||||
# load config:
|
||||
configHandler.checkConfig("notifyMyAndroid")
|
||||
application = globals.config.get("notifyMyAndroid","appName")
|
||||
application = stringConverter.convertToUnicode(globals.config.get("notifyMyAndroid","appName"))
|
||||
usecsv = globals.config.getboolean("notifyMyAndroid","usecsv")
|
||||
|
||||
# if no csv should use, we take the APIKey directly
|
||||
|
|
@ -207,11 +207,12 @@ def run(typ,freq,data):
|
|||
logging.debug("Start %s to NMA", typ)
|
||||
try:
|
||||
# build event and msg
|
||||
event = uft8Converter.convertToUTF8(data['description'])
|
||||
msg = timeHandler.curtime()
|
||||
if len(data['msg']) > 0:
|
||||
# pyNMA expect strings are not in UTF-8
|
||||
event = stringConverter.convertToUnicode(data['description'])
|
||||
msg = timeHandler.curtime()
|
||||
if ("POC" in typ) and (len(data['msg']) > 0):
|
||||
msg += "\n" + data['msg']
|
||||
msg = uft8Converter.convertToUTF8(msg)
|
||||
msg = stringConverter.convertToUnicode(msg)
|
||||
|
||||
# if not using csv-import, all is simple...
|
||||
if usecsv == False:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue