diff --git a/plugins/BosMon/BosMon.py b/plugins/BosMon/BosMon.py index 2c67f8f..f93d4da 100644 --- a/plugins/BosMon/BosMon.py +++ b/plugins/BosMon/BosMon.py @@ -11,12 +11,16 @@ from includes import globals # Global variables def bosMonRequest(httprequest, params, headers): - httprequest.request("POST", "/telegramin/"+globals.config.get("BosMon", "bosmon_channel")+"/input.xml", params, headers) - httpresponse = httprequest.getresponse() - if str(httpresponse.status) == "200": #Check HTTP Response an print a Log or Error - logging.debug("BosMon response: %s - %s", str(httpresponse.status), str(httpresponse.reason)) - else: - logging.warning("BosMon response: %s - %s", str(httpresponse.status), str(httpresponse.reason)) + try: + httprequest.request("POST", "/telegramin/"+globals.config.get("BosMon", "bosmon_channel")+"/input.xml", params, headers) + except: + logging.exception("request to BosMon failed") + else: + httpresponse = httprequest.getresponse() + if str(httpresponse.status) == "200": #Check HTTP Response an print a Log or Error + logging.debug("BosMon response: %s - %s", str(httpresponse.status), str(httpresponse.reason)) + else: + logging.warning("BosMon response: %s - %s", str(httpresponse.status), str(httpresponse.reason)) def run(typ,freq,data): @@ -38,15 +42,32 @@ def run(typ,freq,data): 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") httprequest = httplib.HTTPConnection(globals.config.get("BosMon", "bosmon_server"), globals.config.get("BosMon", "bosmon_port")) + #debug-level to shell (0=no debug|1) + httprequest.set_debuglevel(1) except: logging.exception("cannot connect to BosMon") else: if typ == "FMS": logging.warning("%s not supported", typ) + #logging.debug("Start FMS to BosMon") + #try: + #BosMon-Telegramin expected assembly group, direction and tsi in one field + #structure: + #params = urllib.urlencode({'type':'fms', 'address':data["fms"], 'status':data["status"], 'info':'0', 'flags':'0'}) + #logging.debug(" - Params: %s", params) + #bosMonRequest(httprequest, params, headers) + #except: + #logging.error("FMS to BosMon failed") elif typ == "ZVEI": - logging.warning("%s not supported", typ) + logging.debug("Start ZVEI to BosMon") + try: + params = urllib.urlencode({'type':'zvei', 'address':data["zvei"], 'flags':'0'}) + logging.debug(" - Params: %s", params) + bosMonRequest(httprequest, params, headers) + except: + logging.error("ZVEI to BosMon failed") elif typ == "POC": logging.debug("Start POC to BosMon")