2015-05-18 21:04:10 +02:00
|
|
|
#!/usr/bin/python
|
|
|
|
|
# -*- coding: cp1252 -*-
|
|
|
|
|
|
2015-05-20 15:20:40 +02:00
|
|
|
#########
|
|
|
|
|
# USAGE
|
|
|
|
|
#
|
|
|
|
|
# Config
|
|
|
|
|
# ======
|
|
|
|
|
# to read a option from config File
|
|
|
|
|
# VALUE = globals.config.get("SECTION", "OPTION")
|
|
|
|
|
#
|
|
|
|
|
# Data from boswatch.py
|
|
|
|
|
# =====================
|
|
|
|
|
# use data["KEY"] for Alarm Data from boswatch.py
|
|
|
|
|
# for usable KEYs in different Functions (FMS|ZVEI|POC) see interface.txt
|
|
|
|
|
#
|
|
|
|
|
# LOG Messages
|
|
|
|
|
# ============
|
|
|
|
|
# send Log Messages with logging.LOGLEVEL("MESSAGE")
|
|
|
|
|
# usable Loglevels debug|info|warning|error|exception|critical
|
|
|
|
|
# if you use .exception in Try:Exception: Construct, it logs the Python EX.message too
|
|
|
|
|
|
2015-05-22 16:44:23 +02:00
|
|
|
import logging # Global logger
|
|
|
|
|
|
|
|
|
|
from includes import globals # Global variables
|
|
|
|
|
|
2015-06-23 18:37:32 +02:00
|
|
|
##
|
|
|
|
|
#
|
|
|
|
|
# Main function of plugin
|
|
|
|
|
# will be called by the alarmHandler
|
|
|
|
|
#
|
2015-05-18 14:56:01 +02:00
|
|
|
def run(typ,freq,data):
|
2015-06-23 18:37:32 +02:00
|
|
|
"""
|
|
|
|
|
This function is the implementation of the Plugin.
|
|
|
|
|
|
|
|
|
|
If necessary the configuration hast to be set in the config.ini.
|
|
|
|
|
|
|
|
|
|
@type typ: string (FMS|ZVEI|POC)
|
|
|
|
|
@param typ: Typ of the dataset
|
|
|
|
|
@type data: map of data (structure see interface.txt)
|
|
|
|
|
@param data: Contains the parameter for dispatch
|
|
|
|
|
@type freq: string
|
|
|
|
|
@keyword freq: frequency of the SDR Stick
|
|
|
|
|
|
|
|
|
|
@requires: If necessary the configuration hast to be set in the config.ini.
|
|
|
|
|
|
|
|
|
|
@return: nothing
|
|
|
|
|
"""
|
2015-05-18 22:10:23 +02:00
|
|
|
try:
|
2015-06-23 18:37:32 +02:00
|
|
|
#
|
|
|
|
|
# ConfigParser
|
|
|
|
|
#
|
2015-05-20 09:38:30 +02:00
|
|
|
logging.debug("reading config file")
|
|
|
|
|
try:
|
2015-05-20 17:25:22 +02:00
|
|
|
for key,val in globals.config.items("template"):
|
2015-05-20 09:38:30 +02:00
|
|
|
logging.debug(" - %s = %s", key, val)
|
|
|
|
|
except:
|
2015-06-23 18:37:32 +02:00
|
|
|
logging.error("cannot read config file")
|
|
|
|
|
logging.debug("cannot read config file", exc_info=True)
|
|
|
|
|
# Without config, plugin couldn't work
|
|
|
|
|
return
|
|
|
|
|
|
2015-05-22 07:32:39 +02:00
|
|
|
########## User Plugin CODE ##########
|
2015-05-19 12:58:13 +02:00
|
|
|
if typ == "FMS":
|
2015-05-22 10:00:09 +02:00
|
|
|
logging.warning("%s not supported", typ)
|
2015-05-19 12:58:13 +02:00
|
|
|
elif typ == "ZVEI":
|
2015-05-22 10:00:09 +02:00
|
|
|
logging.warning("%s not supported", typ)
|
2015-05-19 12:58:13 +02:00
|
|
|
elif typ == "POC":
|
2015-05-22 10:00:09 +02:00
|
|
|
logging.warning("%s not supported", typ)
|
2015-05-19 14:04:50 +02:00
|
|
|
else:
|
2015-05-22 10:00:09 +02:00
|
|
|
logging.warning("Invalid Typ: %s", typ)
|
2015-05-22 07:32:39 +02:00
|
|
|
########## User Plugin CODE ##########
|
|
|
|
|
|
2015-05-18 22:10:23 +02:00
|
|
|
except:
|
2015-06-23 18:37:32 +02:00
|
|
|
logging.error("unknown error")
|
|
|
|
|
logging.debug("unknown error", exc_info=True)
|