BOSWatch/includes/alarmHandler.py

54 lines
1.4 KiB
Python
Raw Normal View History

#!/usr/bin/python
# -*- coding: cp1252 -*-
2015-05-27 07:48:24 +02:00
"""
2015-06-14 20:21:21 +02:00
Handler for the filter and plugins at an alarm
2015-05-27 07:48:24 +02:00
@author: Bastian Schroll
2015-06-14 20:21:21 +02:00
@author: Jens Herrmann
2015-05-27 07:48:24 +02:00
@requires: none
"""
import logging # Global logger
from includes import globals # Global variables
2015-06-14 20:21:21 +02:00
##
#
# main function for central filtering and calling the plugins
#
def processAlarm(typ,freq,data):
2015-05-27 07:48:24 +02:00
"""
2015-06-14 20:21:21 +02:00
Function to process filters and plugins at Alarm
2015-05-27 07:48:24 +02:00
@type typ: string (FMS|ZVEI|POC)
@param typ: Typ of the dataset
@type freq: string
@param freq: frequency of the SDR Stick
@type data: map of data (structure see interface.txt)
@param data: Contains the parameter
2015-06-14 20:21:21 +02:00
@requires: active plugins in pluginList
2015-05-27 07:48:24 +02:00
@return: nothing
@exception: Exception if Alarm processing failed
"""
2015-05-26 11:41:05 +02:00
try:
logging.debug("[ ALARM ]")
2015-06-14 20:21:21 +02:00
# Go to all plugins in pluginList
2015-05-26 11:41:05 +02:00
for pluginName, plugin in globals.pluginList.items():
2015-06-14 20:21:21 +02:00
# if enabled use RegEx-filter
2015-05-26 11:41:05 +02:00
if globals.config.getint("BOSWatch","useRegExFilter"):
from includes import filter
2015-05-28 09:18:21 +02:00
if filter.checkFilters(typ,data,pluginName,freq):
2015-05-26 11:41:05 +02:00
logging.debug("call Plugin: %s", pluginName)
plugin.run(typ,freq,data)
logging.debug("return from: %s", pluginName)
2015-06-14 20:21:21 +02:00
else: # RegEX filter off - call plugin directly
logging.debug("call Plugin: %s", pluginName)
plugin.run(typ,freq,data)
logging.debug("return from: %s", pluginName)
2015-05-26 11:41:05 +02:00
logging.debug("[END ALARM]")
except:
logging.exception("Error in Alarm processing")