diff --git a/plugins/BosMon/BosMon.py b/plugins/BosMon/BosMon.py
index 971fcb3..0fc49ec 100644
--- a/plugins/BosMon/BosMon.py
+++ b/plugins/BosMon/BosMon.py
@@ -114,99 +114,98 @@ def run(typ,freq,data):
except:
logging.error("cannot read config file")
logging.debug("cannot read config file", exc_info=True)
- # Without config, plugin couldn't work
- return
+ else: # Without config, plugin couldn't work
- try:
- #
- # Initialize header an connect to BosMon-Server
- #
- headers = {}
- headers['Content-type'] = "application/x-www-form-urlencoded"
- headers['Accept'] = "text/plain"
- # if an user is set in the config.ini we will use HTTP-Authorization
- if globals.config.get("BosMon", "bosmon_user"):
- # generate b64encoded autorization-token for HTTP-request
- headers['Authorization'] = "Basic {0}".format(base64.b64encode("{0}:{1}".format(globals.config.get("BosMon", "bosmon_user"), globals.config.get("BosMon", "bosmon_password"))))
- logging.debug("connect to BosMon")
- # open connection to BosMon-Server
- httprequest = httplib.HTTPConnection(globals.config.get("BosMon", "bosmon_server"), globals.config.get("BosMon", "bosmon_port"), timeout=5)
- # debug-level to shell (0=no debug|1)
- httprequest.set_debuglevel(0)
- except:
- logging.error("cannot connect to BosMon")
- logging.debug("cannot connect to BosMon", exc_info=True)
- # Without connection, plugin couldn't work
- return
-
- else:
- #
- # Format given data-structure to compatible BosMon string
- #
- if typ == "FMS":
- logging.debug("Start FMS to BosMon")
- try:
- # BosMon-Telegramin expected assembly group, direction and tsi in one field
- # structure (binary as hex in base10):
- # Byte 1: assembly group; Byte 2: Direction; Byte 3+4: tactic short info
- info = 0
- # assembly group:
- info = info + 1 # + b0001 (Assumption: is in every time 1 (no output from multimon-ng))
- # direction:
- if data["direction"] == "1":
- info = info + 2 # + b0010
- # tsi:
- if "IV" in data["tsi"]:
- info = info + 12 # + b1100
- elif "III" in data["tsi"]:
- info = info + 8 # + b1000
- elif "II" in data["tsi"]:
- info = info + 4 # + b0100
- # "I" is nothing to do + b0000
-
- params = urllib.urlencode({'type':'fms', 'address':data["fms"], 'status':data["status"], 'info':info, 'flags':'0'})
- logging.debug(" - Params: %s", params)
- # dispatch the BosMon-request
- bosMonRequest(httprequest, params, headers)
- except:
- logging.error("FMS to BosMon failed")
- logging.debug("FMS to BosMon failed", exc_info=True)
- return
-
- elif typ == "ZVEI":
- logging.debug("Start ZVEI to BosMon")
- try:
- params = urllib.urlencode({'type':'zvei', 'address':data["zvei"], 'flags':'0'})
- logging.debug(" - Params: %s", params)
- # dispatch the BosMon-request
- bosMonRequest(httprequest, params, headers)
- except:
- logging.error("ZVEI to BosMon failed")
- logging.debug("ZVEI to BosMon failed", exc_info=True)
- return
-
- elif typ == "POC":
- logging.debug("Start POC to BosMon")
- try:
- # BosMon-Telegramin expected "a-d" as RIC-sub/function
- params = urllib.urlencode({'type':'pocsag', 'address':data["ric"], 'flags':'0', 'function':data["functionChar"], 'message':data["msg"]})
- logging.debug(" - Params: %s", params)
- # dispatch the BosMon-request
- bosMonRequest(httprequest, params, headers)
- except:
- logging.error("POC to BosMon failed")
- logging.debug("POC to BosMon failed", exc_info=True)
- return
-
- else:
- logging.warning("Invalid Typ: %s", typ)
-
- finally:
- logging.debug("close BosMon-Connection")
- try:
- httprequest.close()
+ try:
+ #
+ # Initialize header an connect to BosMon-Server
+ #
+ headers = {}
+ headers['Content-type'] = "application/x-www-form-urlencoded"
+ headers['Accept'] = "text/plain"
+ # if an user is set in the config.ini we will use HTTP-Authorization
+ if globals.config.get("BosMon", "bosmon_user"):
+ # generate b64encoded autorization-token for HTTP-request
+ headers['Authorization'] = "Basic {0}".format(base64.b64encode("{0}:{1}".format(globals.config.get("BosMon", "bosmon_user"), globals.config.get("BosMon", "bosmon_password"))))
+ logging.debug("connect to BosMon")
+ # open connection to BosMon-Server
+ httprequest = httplib.HTTPConnection(globals.config.get("BosMon", "bosmon_server"), globals.config.get("BosMon", "bosmon_port"), timeout=5)
+ # debug-level to shell (0=no debug|1)
+ httprequest.set_debuglevel(0)
except:
- pass
+ logging.error("cannot connect to BosMon")
+ logging.debug("cannot connect to BosMon", exc_info=True)
+ # Without connection, plugin couldn't work
+ return
+
+ else:
+ #
+ # Format given data-structure to compatible BosMon string
+ #
+ if typ == "FMS":
+ logging.debug("Start FMS to BosMon")
+ try:
+ # BosMon-Telegramin expected assembly group, direction and tsi in one field
+ # structure (binary as hex in base10):
+ # Byte 1: assembly group; Byte 2: Direction; Byte 3+4: tactic short info
+ info = 0
+ # assembly group:
+ info = info + 1 # + b0001 (Assumption: is in every time 1 (no output from multimon-ng))
+ # direction:
+ if data["direction"] == "1":
+ info = info + 2 # + b0010
+ # tsi:
+ if "IV" in data["tsi"]:
+ info = info + 12 # + b1100
+ elif "III" in data["tsi"]:
+ info = info + 8 # + b1000
+ elif "II" in data["tsi"]:
+ info = info + 4 # + b0100
+ # "I" is nothing to do + b0000
+
+ params = urllib.urlencode({'type':'fms', 'address':data["fms"], 'status':data["status"], 'info':info, 'flags':'0'})
+ logging.debug(" - Params: %s", params)
+ # dispatch the BosMon-request
+ bosMonRequest(httprequest, params, headers)
+ except:
+ logging.error("FMS to BosMon failed")
+ logging.debug("FMS to BosMon failed", exc_info=True)
+ return
+
+ elif typ == "ZVEI":
+ logging.debug("Start ZVEI to BosMon")
+ try:
+ params = urllib.urlencode({'type':'zvei', 'address':data["zvei"], 'flags':'0'})
+ logging.debug(" - Params: %s", params)
+ # dispatch the BosMon-request
+ bosMonRequest(httprequest, params, headers)
+ except:
+ logging.error("ZVEI to BosMon failed")
+ logging.debug("ZVEI to BosMon failed", exc_info=True)
+ return
+
+ elif typ == "POC":
+ logging.debug("Start POC to BosMon")
+ try:
+ # BosMon-Telegramin expected "a-d" as RIC-sub/function
+ params = urllib.urlencode({'type':'pocsag', 'address':data["ric"], 'flags':'0', 'function':data["functionChar"], 'message':data["msg"]})
+ logging.debug(" - Params: %s", params)
+ # dispatch the BosMon-request
+ bosMonRequest(httprequest, params, headers)
+ except:
+ logging.error("POC to BosMon failed")
+ logging.debug("POC to BosMon failed", exc_info=True)
+ return
+
+ else:
+ logging.warning("Invalid Typ: %s", typ)
+
+ finally:
+ logging.debug("close BosMon-Connection")
+ try:
+ httprequest.close()
+ except:
+ pass
except:
# something very mysterious
diff --git a/plugins/MySQL/MySQL.py b/plugins/MySQL/MySQL.py
index 34b95e5..226c071 100644
--- a/plugins/MySQL/MySQL.py
+++ b/plugins/MySQL/MySQL.py
@@ -77,56 +77,52 @@ def run(typ,freq,data):
except:
logging.error("cannot read config file")
logging.debug("cannot read config file", exc_info=True)
- # Without config, plugin couldn't work
- return
+ else: # Without config, plugin couldn't work
- try:
- #
- # Connect to MySQL
- #
- logging.debug("connect to MySQL")
- connection = mysql.connector.connect(host = globals.config.get("MySQL","dbserver"), user = globals.config.get("MySQL","dbuser"), passwd = globals.config.get("MySQL","dbpassword"), db = globals.config.get("MySQL","database"))
- cursor = connection.cursor()
- except:
- logging.error("cannot connect to MySQL")
- logging.debug("cannot connect to MySQL", exc_info=True)
- # Without connection, plugin couldn't work
- return
-
- else:
try:
+ #
+ # Connect to MySQL
#
- # Create and execute SQL-statement
- #
- logging.debug("Insert %s", typ)
-
- if typ == "FMS":
- #data = {"fms":fms_id[0:8], "status":fms_status, "direction":fms_direction, "tsi":fms_tsi}
- cursor.execute("INSERT INTO "+globals.config.get("MySQL","tableFMS")+" (time,fms,status,direction,tsi) VALUES (NOW(),%s,%s,%s,%s)",(data["fms"],data["status"],data["direction"],data["tsi"]))
-
- elif typ == "ZVEI":
- #data = {"zvei":zvei_id}
- #Don't use %s here (bug in mysql-lib with one parameter)
- cursor.execute("INSERT INTO "+globals.config.get("MySQL","tableZVEI")+" (time,zvei) VALUES (NOW(),"+(data["zvei"])+")")
-
- elif typ == "POC":
- #data = {"ric":poc_id, "function":poc_sub, "msg":poc_text}
- cursor.execute("INSERT INTO "+globals.config.get("MySQL","tablePOC")+" (time,ric,funktion,text) VALUES (NOW(),%s,%s,%s)",(data["ric"],data["function"],data["msg"]))
-
- else:
- logging.warning("Invalid Typ: %s", typ)
+ logging.debug("connect to MySQL")
+ connection = mysql.connector.connect(host = globals.config.get("MySQL","dbserver"), user = globals.config.get("MySQL","dbuser"), passwd = globals.config.get("MySQL","dbpassword"), db = globals.config.get("MySQL","database"))
+ cursor = connection.cursor()
except:
- logging.error("cannot Insert %s", typ)
- logging.debug("cannot Insert %s", typ, exc_info=True)
- return
-
- finally:
- logging.debug("close MySQL")
- try:
- cursor.close()
- connection.close() #Close connection in every case
- except:
- pass
+ logging.error("cannot connect to MySQL")
+ logging.debug("cannot connect to MySQL", exc_info=True)
+ else: # Without connection, plugin couldn't work
+ try:
+ #
+ # Create and execute SQL-statement
+ #
+ logging.debug("Insert %s", typ)
+
+ if typ == "FMS":
+ #data = {"fms":fms_id[0:8], "status":fms_status, "direction":fms_direction, "tsi":fms_tsi}
+ cursor.execute("INSERT INTO "+globals.config.get("MySQL","tableFMS")+" (time,fms,status,direction,tsi) VALUES (NOW(),%s,%s,%s,%s)",(data["fms"],data["status"],data["direction"],data["tsi"]))
+
+ elif typ == "ZVEI":
+ #data = {"zvei":zvei_id}
+ #Don't use %s here (bug in mysql-lib with one parameter)
+ cursor.execute("INSERT INTO "+globals.config.get("MySQL","tableZVEI")+" (time,zvei) VALUES (NOW(),"+(data["zvei"])+")")
+
+ elif typ == "POC":
+ #data = {"ric":poc_id, "function":poc_sub, "msg":poc_text}
+ cursor.execute("INSERT INTO "+globals.config.get("MySQL","tablePOC")+" (time,ric,funktion,text) VALUES (NOW(),%s,%s,%s)",(data["ric"],data["function"],data["msg"]))
+
+ else:
+ logging.warning("Invalid Typ: %s", typ)
+ except:
+ logging.error("cannot Insert %s", typ)
+ logging.debug("cannot Insert %s", typ, exc_info=True)
+ return
+
+ finally:
+ logging.debug("close MySQL")
+ try:
+ cursor.close()
+ connection.close() #Close connection in every case
+ except:
+ pass
except:
logging.error("unknown error")
diff --git a/plugins/eMail/eMail.py b/plugins/eMail/eMail.py
index 11a38dc..2540dda 100644
--- a/plugins/eMail/eMail.py
+++ b/plugins/eMail/eMail.py
@@ -118,110 +118,109 @@ def run(typ,freq,data):
except:
logging.error("cannot read config file")
logging.debug("cannot read config file", exc_info=True)
- # Without config, plugin couldn't work
- return
+ else: # Without config, plugin couldn't work
- try:
- #
- # connect to SMTP-Server
- #
- server = smtplib.SMTP(globals.config.get("eMail", "smtp_server"), globals.config.get("eMail", "smtp_port"))
- # debug-level to shell (0=no debug|1)
- server.set_debuglevel(0)
-
- # if tls is enabled, starttls
- if globals.config.get("eMail", "tls"):
- server.starttls()
-
- # if user is given, login
- if globals.config.get("eMail", "user"):
- server.login(globals.config.get("eMail", "user"), globals.config.get("eMail", "password"))
-
- except:
- logging.error("cannot connect to eMail")
- logging.debug("cannot connect to eMail", exc_info=True)
- # Without connection, plugin couldn't work
- return
-
- else:
-
- if typ == "FMS":
- logging.debug("Start FMS to eMail")
- try:
- # read subject-structure from config.ini
- subject = globals.config.get("eMail", "fms_subject")
- subject = subject.replace("%FMS%", data["fms"]).replace("%STATUS%", data["status"]) #replace Wildcards
- subject = subject.replace("%DIR%", data["direction"]).replace("%DIRT%", data["directionText"]) #replace Wildcards
- subject = subject.replace("%TSI%", data["tsi"]) #replace Wildcards
- subject = subject.replace("%DESCR%", data["description"]) # replace Wildcards
- subject = subject.replace("%TIME%", curtime()) # replace Wildcards
- # read mailtext-structure from config.ini
- mailtext = globals.config.get("eMail", "fms_message")
- mailtext = mailtext.replace("%FMS%", data["fms"]).replace("%STATUS%", data["status"]) #replace Wildcards
- mailtext = mailtext.replace("%DIR%", data["direction"]).replace("%DIRT%", data["directionText"]) #replace Wildcards
- mailtext = mailtext.replace("%TSI%", data["tsi"]) #replace Wildcards
- mailtext = mailtext.replace("%DESCR%", data["description"]) # replace Wildcards
- mailtext = mailtext.replace("%TIME%", curtime()) # replace Wildcards
- # send eMail
- doSendmail(server, subject, mailtext)
- except:
- logging.error("%s to eMail failed", typ)
- logging.debug("%s to eMail failed", typ, exc_info=True)
- return
-
- elif typ == "ZVEI":
- logging.debug("Start ZVEI to eMail")
- try:
- # read subject-structure from config.ini
- subject = globals.config.get("eMail", "zvei_subject")
- subject = subject.replace("%ZVEI%", data["zvei"]) #replace Wildcards
- subject = subject.replace("%DESCR%", data["description"]) # replace Wildcards
- subject = subject.replace("%TIME%", curtime()) # replace Wildcards
- # read mailtext-structure from config.ini
- mailtext = globals.config.get("eMail", "zvei_message")
- mailtext = mailtext.replace("%ZVEI%", data["zvei"]) #replace Wildcards
- mailtext = mailtext.replace("%DESCR%", data["description"]) # replace Wildcards
- mailtext = mailtext.replace("%TIME%", curtime()) # replace Wildcards
- # send eMail
- doSendmail(server, subject, mailtext)
- except:
- logging.error("%s to eMail failed", typ)
- logging.debug("%s to eMail failed", typ, exc_info=True)
- return
-
- elif typ == "POC":
- logging.debug("Start POC to eMail")
- try:
- # read subject-structure from config.ini
- subject = globals.config.get("eMail", "poc_subject")
- subject = subject.replace("%RIC%", data["ric"]) #replace Wildcards
- subject = subject.replace("%FUNC%", data["function"]).replace("%FUNCCHAR%", data["functionChar"]) #replace Wildcards
- subject = subject.replace("%MSG%", data["msg"]).replace("%BITRATE%", str(data["bitrate"])) #replace Wildcards
- subject = subject.replace("%DESCR%", data["description"]) # replace Wildcards
- subject = subject.replace("%TIME%", curtime()) # replace Wildcards
- # read mailtext-structure from config.ini
- mailtext = globals.config.get("eMail", "poc_message")
- mailtext = mailtext.replace("%RIC%", data["ric"]) #replace Wildcards
- mailtext = mailtext.replace("%FUNC%", data["function"]).replace("%FUNCCHAR%", data["functionChar"]) #replace Wildcards
- mailtext = mailtext.replace("%MSG%", data["msg"]).replace("%BITRATE%", str(data["bitrate"])) #replace Wildcards
- mailtext = mailtext.replace("%DESCR%", data["description"]) # replace Wildcards
- mailtext = mailtext.replace("%TIME%", curtime()) # replace Wildcards
- # send eMail
- doSendmail(server, subject, mailtext)
- except:
- logging.error("%s to eMail failed", typ)
- logging.debug("%s to eMail failed", typ, exc_info=True)
- return
-
- else:
- logging.warning("Invalid Typ: %s", typ)
-
- finally:
- logging.debug("close eMail-Connection")
- try:
- server.quit()
+ try:
+ #
+ # connect to SMTP-Server
+ #
+ server = smtplib.SMTP(globals.config.get("eMail", "smtp_server"), globals.config.get("eMail", "smtp_port"))
+ # debug-level to shell (0=no debug|1)
+ server.set_debuglevel(0)
+
+ # if tls is enabled, starttls
+ if globals.config.get("eMail", "tls"):
+ server.starttls()
+
+ # if user is given, login
+ if globals.config.get("eMail", "user"):
+ server.login(globals.config.get("eMail", "user"), globals.config.get("eMail", "password"))
+
except:
- pass
+ logging.error("cannot connect to eMail")
+ logging.debug("cannot connect to eMail", exc_info=True)
+ # Without connection, plugin couldn't work
+ return
+
+ else:
+
+ if typ == "FMS":
+ logging.debug("Start FMS to eMail")
+ try:
+ # read subject-structure from config.ini
+ subject = globals.config.get("eMail", "fms_subject")
+ subject = subject.replace("%FMS%", data["fms"]).replace("%STATUS%", data["status"]) #replace Wildcards
+ subject = subject.replace("%DIR%", data["direction"]).replace("%DIRT%", data["directionText"]) #replace Wildcards
+ subject = subject.replace("%TSI%", data["tsi"]) #replace Wildcards
+ subject = subject.replace("%DESCR%", data["description"]) # replace Wildcards
+ subject = subject.replace("%TIME%", curtime()) # replace Wildcards
+ # read mailtext-structure from config.ini
+ mailtext = globals.config.get("eMail", "fms_message")
+ mailtext = mailtext.replace("%FMS%", data["fms"]).replace("%STATUS%", data["status"]) #replace Wildcards
+ mailtext = mailtext.replace("%DIR%", data["direction"]).replace("%DIRT%", data["directionText"]) #replace Wildcards
+ mailtext = mailtext.replace("%TSI%", data["tsi"]) #replace Wildcards
+ mailtext = mailtext.replace("%DESCR%", data["description"]) # replace Wildcards
+ mailtext = mailtext.replace("%TIME%", curtime()) # replace Wildcards
+ # send eMail
+ doSendmail(server, subject, mailtext)
+ except:
+ logging.error("%s to eMail failed", typ)
+ logging.debug("%s to eMail failed", typ, exc_info=True)
+ return
+
+ elif typ == "ZVEI":
+ logging.debug("Start ZVEI to eMail")
+ try:
+ # read subject-structure from config.ini
+ subject = globals.config.get("eMail", "zvei_subject")
+ subject = subject.replace("%ZVEI%", data["zvei"]) #replace Wildcards
+ subject = subject.replace("%DESCR%", data["description"]) # replace Wildcards
+ subject = subject.replace("%TIME%", curtime()) # replace Wildcards
+ # read mailtext-structure from config.ini
+ mailtext = globals.config.get("eMail", "zvei_message")
+ mailtext = mailtext.replace("%ZVEI%", data["zvei"]) #replace Wildcards
+ mailtext = mailtext.replace("%DESCR%", data["description"]) # replace Wildcards
+ mailtext = mailtext.replace("%TIME%", curtime()) # replace Wildcards
+ # send eMail
+ doSendmail(server, subject, mailtext)
+ except:
+ logging.error("%s to eMail failed", typ)
+ logging.debug("%s to eMail failed", typ, exc_info=True)
+ return
+
+ elif typ == "POC":
+ logging.debug("Start POC to eMail")
+ try:
+ # read subject-structure from config.ini
+ subject = globals.config.get("eMail", "poc_subject")
+ subject = subject.replace("%RIC%", data["ric"]) #replace Wildcards
+ subject = subject.replace("%FUNC%", data["function"]).replace("%FUNCCHAR%", data["functionChar"]) #replace Wildcards
+ subject = subject.replace("%MSG%", data["msg"]).replace("%BITRATE%", str(data["bitrate"])) #replace Wildcards
+ subject = subject.replace("%DESCR%", data["description"]) # replace Wildcards
+ subject = subject.replace("%TIME%", curtime()) # replace Wildcards
+ # read mailtext-structure from config.ini
+ mailtext = globals.config.get("eMail", "poc_message")
+ mailtext = mailtext.replace("%RIC%", data["ric"]) #replace Wildcards
+ mailtext = mailtext.replace("%FUNC%", data["function"]).replace("%FUNCCHAR%", data["functionChar"]) #replace Wildcards
+ mailtext = mailtext.replace("%MSG%", data["msg"]).replace("%BITRATE%", str(data["bitrate"])) #replace Wildcards
+ mailtext = mailtext.replace("%DESCR%", data["description"]) # replace Wildcards
+ mailtext = mailtext.replace("%TIME%", curtime()) # replace Wildcards
+ # send eMail
+ doSendmail(server, subject, mailtext)
+ except:
+ logging.error("%s to eMail failed", typ)
+ logging.debug("%s to eMail failed", typ, exc_info=True)
+ return
+
+ else:
+ logging.warning("Invalid Typ: %s", typ)
+
+ finally:
+ logging.debug("close eMail-Connection")
+ try:
+ server.quit()
+ except:
+ pass
except:
# something very mysterious
diff --git a/plugins/firEmergency/firEmergency.py b/plugins/firEmergency/firEmergency.py
index 89be104..6692a7b 100644
--- a/plugins/firEmergency/firEmergency.py
+++ b/plugins/firEmergency/firEmergency.py
@@ -71,59 +71,58 @@ def run(typ,freq,data):
except:
logging.error("cannot read config file")
logging.debug("cannot read config file", exc_info=True)
- # Without config, plugin couldn't work
- return
+ else: # Without config, plugin couldn't work
- try:
- #
- # connect to firEmergency
- #
- firSocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
- firSocket.connect((globals.config.get("firEmergency", "firserver"), globals.config.getint("firEmergency", "firport")))
- except:
- logging.error("cannot connect to firEmergency")
- logging.debug("cannot connect to firEmergency", exc_info=True)
- # Without connection, plugin couldn't work
- return
-
- else:
- #
- # Format given data-structure to xml-string for firEmergency
- #
- if typ == "FMS":
- logging.debug("FMS not supported by firEmgency")
-
- elif typ == "ZVEI":
- logging.debug("ZVEI to firEmergency")
- try:
- firXML = "\n"+data["zvei"]+"\n"+data["zvei"]+" alarmiert.\n\n"
- firSocket.send(firXML)
- except:
- logging.error("%s to firEmergency failed", typ)
- logging.debug("%s to firEmergency failed", typ, exc_info=True)
- # Without connection, plugin couldn't work
- return
-
- elif typ == "POC":
- logging.debug("POC to firEmergency")
- try:
- firXML = "\n"+data["ric"]+"\n"+data["msg"]+"\n\n"
- firSocket.send(firXML)
- except:
- logging.error("%s to firEmergency failed", typ)
- logging.debug("%s to firEmergency failed", typ, exc_info=True)
- # Without connection, plugin couldn't work
- return
-
- else:
- logging.warning("Invalid Typ: %s", typ)
-
- finally:
- logging.debug("close firEmergency-Connection")
- try:
- firSocket.close()
+ try:
+ #
+ # connect to firEmergency
+ #
+ firSocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+ firSocket.connect((globals.config.get("firEmergency", "firserver"), globals.config.getint("firEmergency", "firport")))
except:
- pass
+ logging.error("cannot connect to firEmergency")
+ logging.debug("cannot connect to firEmergency", exc_info=True)
+ # Without connection, plugin couldn't work
+ return
+
+ else:
+ #
+ # Format given data-structure to xml-string for firEmergency
+ #
+ if typ == "FMS":
+ logging.debug("FMS not supported by firEmgency")
+
+ elif typ == "ZVEI":
+ logging.debug("ZVEI to firEmergency")
+ try:
+ firXML = "\n"+data["zvei"]+"\n"+data["zvei"]+" alarmiert.\n\n"
+ firSocket.send(firXML)
+ except:
+ logging.error("%s to firEmergency failed", typ)
+ logging.debug("%s to firEmergency failed", typ, exc_info=True)
+ # Without connection, plugin couldn't work
+ return
+
+ elif typ == "POC":
+ logging.debug("POC to firEmergency")
+ try:
+ firXML = "\n"+data["ric"]+"\n"+data["msg"]+"\n\n"
+ firSocket.send(firXML)
+ except:
+ logging.error("%s to firEmergency failed", typ)
+ logging.debug("%s to firEmergency failed", typ, exc_info=True)
+ # Without connection, plugin couldn't work
+ return
+
+ else:
+ logging.warning("Invalid Typ: %s", typ)
+
+ finally:
+ logging.debug("close firEmergency-Connection")
+ try:
+ firSocket.close()
+ except:
+ pass
except:
logging.error("unknown error")
diff --git a/plugins/httpRequest/httpRequest.py b/plugins/httpRequest/httpRequest.py
index 97444a4..5455983 100644
--- a/plugins/httpRequest/httpRequest.py
+++ b/plugins/httpRequest/httpRequest.py
@@ -70,62 +70,61 @@ def run(typ,freq,data):
except:
logging.error("cannot read config file")
logging.debug("cannot read config file", exc_info=True)
- # Without config, plugin couldn't work
- return
-
- try:
- #
- # Create URL
- #
- logging.debug("send %s HTTP request", typ)
+ else: # Without config, plugin couldn't work
- if typ == "FMS":
- url = globals.config.get("httpRequest", "fms_url") #Get URL
- url = url.replace("%FMS%", data["fms"]).replace("%STATUS%", data["status"]) #replace Wildcards in URL
- url = url.replace("%DIR%", data["direction"]).replace("%TSI%", data["tsi"]) #replace Wildcards in URL
- elif typ == "ZVEI":
- url = globals.config.get("httpRequest", "zvei_url") #Get URL
- url = url.replace("%ZVEI%", data["zvei"]) #replace Wildcards in URL
- elif typ == "POC":
- url = globals.config.get("httpRequest", "poc_url") #Get URL
- url = url.replace("%RIC%", data["ric"]).replace("%FUNC%", data["function"]) #replace Wildcards in URL
- url = url.replace("%MSG%", data["msg"]).replace("%BITRATE%", data["bitrate"]) #replace Wildcards in URL
- else:
- logging.warning("Invalid Typ: %s", typ)
-
- #
- # HTTP-Request
- #
- url = urlparse(url) #split URL into path and querry
- httprequest = httplib.HTTPConnection(url[2]) #connect to URL Path
- httprequest.request("GET", url[5]) #send URL Querry per GET
-
- except:
- logging.error("cannot send HTTP request")
- logging.debug("cannot send HTTP request", exc_info=True)
- return
-
- else:
try:
- #
- # check HTTP-Response
#
- httpresponse = httprequest.getresponse()
- if str(httpresponse.status) == "200": #Check HTTP Response an print a Log or Error
- logging.debug("HTTP response: %s - %s" , str(httpresponse.status), str(httpresponse.reason))
+ # Create URL
+ #
+ logging.debug("send %s HTTP request", typ)
+
+ if typ == "FMS":
+ url = globals.config.get("httpRequest", "fms_url") #Get URL
+ url = url.replace("%FMS%", data["fms"]).replace("%STATUS%", data["status"]) #replace Wildcards in URL
+ url = url.replace("%DIR%", data["direction"]).replace("%TSI%", data["tsi"]) #replace Wildcards in URL
+ elif typ == "ZVEI":
+ url = globals.config.get("httpRequest", "zvei_url") #Get URL
+ url = url.replace("%ZVEI%", data["zvei"]) #replace Wildcards in URL
+ elif typ == "POC":
+ url = globals.config.get("httpRequest", "poc_url") #Get URL
+ url = url.replace("%RIC%", data["ric"]).replace("%FUNC%", data["function"]) #replace Wildcards in URL
+ url = url.replace("%MSG%", data["msg"]).replace("%BITRATE%", data["bitrate"]) #replace Wildcards in URL
else:
- logging.warning("HTTP response: %s - %s" , str(httpresponse.status), str(httpresponse.reason))
- except: #otherwise
- logging.error("cannot get HTTP response")
- logging.debug("cannot get HTTP response", exc_info=True)
+ logging.warning("Invalid Typ: %s", typ)
+
+ #
+ # HTTP-Request
+ #
+ url = urlparse(url) #split URL into path and querry
+ httprequest = httplib.HTTPConnection(url[2]) #connect to URL Path
+ httprequest.request("GET", url[5]) #send URL Querry per GET
+
+ except:
+ logging.error("cannot send HTTP request")
+ logging.debug("cannot send HTTP request", exc_info=True)
return
- finally:
- logging.debug("close HTTP-Connection")
- try:
- httprequest.close()
- except:
- pass
+ else:
+ try:
+ #
+ # check HTTP-Response
+ #
+ httpresponse = httprequest.getresponse()
+ if str(httpresponse.status) == "200": #Check HTTP Response an print a Log or Error
+ logging.debug("HTTP response: %s - %s" , str(httpresponse.status), str(httpresponse.reason))
+ else:
+ logging.warning("HTTP response: %s - %s" , str(httpresponse.status), str(httpresponse.reason))
+ except: #otherwise
+ logging.error("cannot get HTTP response")
+ logging.debug("cannot get HTTP response", exc_info=True)
+ return
+
+ finally:
+ logging.debug("close HTTP-Connection")
+ try:
+ httprequest.close()
+ except:
+ pass
except:
logging.error("unknown error")
diff --git a/plugins/jsonSocket/jsonSocket.py b/plugins/jsonSocket/jsonSocket.py
index 60b6f63..6bc6f42 100644
--- a/plugins/jsonSocket/jsonSocket.py
+++ b/plugins/jsonSocket/jsonSocket.py
@@ -74,51 +74,50 @@ def run(typ,freq,data):
except:
logging.error("cannot read config file")
logging.debug("cannot read config file", exc_info=True)
- # Without config, plugin couldn't work
- return
+ else: # Without config, plugin couldn't work
- try:
- #
- # initialize to socket-Server
- #
- # SOCK_DGRAM is the socket type to use for UDP sockets
- # SOCK_STREAM is the socket type to use for TCP sockets
- if globals.config.get("jsonSocket", "protocol") == "TCP":
- sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
- sock.connect((globals.config.get("jsonSocket", "server"), globals.config.getint("jsonSocket", "port")))
- else:
- sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
-
- except:
- logging.error("cannot initialize %s-socket", globals.config.get("jsonSocket", "protocol"))
- logging.debug("cannot initialize %s-socket", globals.config.get("jsonSocket", "protocol"), exc_info=True)
- # Without connection, plugin couldn't work
- return
-
- else:
- # toDo is equals for all types, so only check if typ is supported
- supportedTypes = ["FMS", "ZVEI", "POC"]
- if typ in supportedTypes:
- logging.debug("Start %s to %s", typ, globals.config.get("jsonSocket", "protocol"))
- try:
- # dump data to json-string
- sendData = json.dumps(data)
- # send data
- sock.sendto(sendData, (globals.config.get("jsonSocket", "server"), globals.config.getint("jsonSocket", "port")))
- except:
- logging.error("%s to %s failed", typ, globals.config.get("jsonSocket", "protocol"))
- logging.debug("%s to %s failed", typ, globals.config.get("jsonSocket", "protocol"), exc_info=True)
- return
-
- else:
- logging.warning("Invalid Typ: %s", typ)
-
- finally:
- logging.debug("close %s-Connection", globals.config.get("jsonSocket", "protocol"))
- try:
- sock.close()
+ try:
+ #
+ # initialize to socket-Server
+ #
+ # SOCK_DGRAM is the socket type to use for UDP sockets
+ # SOCK_STREAM is the socket type to use for TCP sockets
+ if globals.config.get("jsonSocket", "protocol") == "TCP":
+ sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+ sock.connect((globals.config.get("jsonSocket", "server"), globals.config.getint("jsonSocket", "port")))
+ else:
+ sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
+
except:
- pass
+ logging.error("cannot initialize %s-socket", globals.config.get("jsonSocket", "protocol"))
+ logging.debug("cannot initialize %s-socket", globals.config.get("jsonSocket", "protocol"), exc_info=True)
+ # Without connection, plugin couldn't work
+ return
+
+ else:
+ # toDo is equals for all types, so only check if typ is supported
+ supportedTypes = ["FMS", "ZVEI", "POC"]
+ if typ in supportedTypes:
+ logging.debug("Start %s to %s", typ, globals.config.get("jsonSocket", "protocol"))
+ try:
+ # dump data to json-string
+ sendData = json.dumps(data)
+ # send data
+ sock.sendto(sendData, (globals.config.get("jsonSocket", "server"), globals.config.getint("jsonSocket", "port")))
+ except:
+ logging.error("%s to %s failed", typ, globals.config.get("jsonSocket", "protocol"))
+ logging.debug("%s to %s failed", typ, globals.config.get("jsonSocket", "protocol"), exc_info=True)
+ return
+
+ else:
+ logging.warning("Invalid Typ: %s", typ)
+
+ finally:
+ logging.debug("close %s-Connection", globals.config.get("jsonSocket", "protocol"))
+ try:
+ sock.close()
+ except:
+ pass
except:
# something very mysterious