a little bit documentation

This commit is contained in:
JHCD 2015-05-31 12:40:43 +02:00
parent 1ee27afbf0
commit 0a621b283a
10 changed files with 97 additions and 20 deletions

View file

@ -1,6 +1,16 @@
#!/usr/bin/python
# -*- coding: cp1252 -*-
"""
MySQL-Plugin to dispatch FMS-, ZVEI- and POCSAG - messages to a MySQL database
@author: Jens Herrmann
@author: Bastian Schroll
@requires: MySQL-Configuration has to be set in the config.ini
@requires: Created Database/Tables, see boswatch.sql
"""
import logging # Global logger
import mysql
@ -9,7 +19,35 @@ import mysql.connector
from includes import globals # Global variables
##
#
# Main function of MySQL-plugin
# will be called by the alarmHandler
#
def run(typ,freq,data):
"""
This function is the implementation of the MySQL-Plugin.
It will store the data to an MySQL database
The configuration for the MySQL-Connection is set in the config.ini.
For DB- and tablestructure see boswatch.sql
@type typ: string (FMS|ZVEI|POC)
@param typ: Typ of the dataset for sending to BosMon
@type data: map of data (structure see interface.txt)
@param data: Contains the parameter for dispatch to BosMon.
@type freq: string
@keyword freq: frequency is not used in this plugin
@requires: MySQL-Configuration has to be set in the config.ini
@requires: Created Database/Tables, see boswatch.sql
@return: nothing
@exception: Exception if ConfigParser failed
@exception: Exception if connect to MySQL failed
@exception: Exception if executing the sql-statement is failed
"""
try:
#ConfigParser
logging.debug("reading config file")
@ -20,14 +58,19 @@ def run(typ,freq,data):
logging.exception("cannot read config file")
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.exception("cannot connect to MySQL")
else:
try:
#
# Create and execute SQL-statement
#
logging.debug("Insert %s", typ)
if typ == "FMS":