mirror of
https://github.com/Schrolli91/BOSWatch.git
synced 2026-04-05 06:25:10 +00:00
Merge branch 'pr/20' into develop
Conflicts: boswatch.py Merge branch 'pr/20' into develop Conflicts: boswatch.py
This commit is contained in:
commit
5a405e1ddb
3 changed files with 34 additions and 17 deletions
|
|
@ -3,6 +3,8 @@
|
|||
|
||||
import logging # Global logger
|
||||
import globals # Global variables
|
||||
import mysql
|
||||
import mysql.connector
|
||||
|
||||
def run(typ,freq,data):
|
||||
try:
|
||||
|
|
@ -13,18 +15,33 @@ def run(typ,freq,data):
|
|||
logging.debug(" - %s = %s", key, val)
|
||||
except:
|
||||
logging.exception("cannot read config file")
|
||||
|
||||
if typ == "FMS":
|
||||
#logging.debug("FMS: %s Status: %s Dir: %s", data["fms"], data["status"], data["direction"])
|
||||
logging.debug("FMS")
|
||||
elif typ == "ZVEI":
|
||||
#logging.debug("ZVEI: %s", data["zvei"])
|
||||
logging.debug("ZVEI")
|
||||
elif typ == "POC":
|
||||
#logging.debug("POC: %s/%s - %s", data["ric"], data["function"], data["msg"])
|
||||
logging.debug("POC")
|
||||
else:
|
||||
logging.warning(typ + " not supportet")
|
||||
|
||||
#open DB-Connection
|
||||
try:
|
||||
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()
|
||||
|
||||
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}
|
||||
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(typ + " not supportet")
|
||||
return
|
||||
|
||||
cursor.close()
|
||||
connection.commit()
|
||||
except:
|
||||
logging.exception("%s to MySQL failed", typ)
|
||||
finally:
|
||||
connection.close() #Close connection in every case
|
||||
except:
|
||||
logging.exception("unknown error")
|
||||
|
|
@ -14,7 +14,7 @@ FMS:
|
|||
- fms
|
||||
- status
|
||||
- direction
|
||||
- tki
|
||||
- tsi
|
||||
|
||||
POCSAG:
|
||||
- ric
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue