mirror of
https://github.com/Schrolli91/BOSWatch.git
synced 2026-04-04 14:07:25 +00:00
replace the return with an else: statement after config reading
This commit is contained in:
parent
95d2d2f119
commit
6371d1cf3c
6 changed files with 374 additions and 383 deletions
|
|
@ -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 = "<event>\n<address>"+data["zvei"]+"</address>\n<message>"+data["zvei"]+" alarmiert.</message>\n</event>\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 = "<event>\n<address>"+data["ric"]+"</address>\n<message>"+data["msg"]+"</message>\n</event>\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 = "<event>\n<address>"+data["zvei"]+"</address>\n<message>"+data["zvei"]+" alarmiert.</message>\n</event>\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 = "<event>\n<address>"+data["ric"]+"</address>\n<message>"+data["msg"]+"</message>\n</event>\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")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue