checkFilters() with freq und wildcards

This commit is contained in:
Schrolli 2015-05-28 09:18:21 +02:00
parent 9bfe832530
commit b3ee8d29ae
4 changed files with 36 additions and 23 deletions

View file

@ -38,7 +38,7 @@ def processAlarm(typ,freq,data):
#if enabled use RegEx-Filter
if globals.config.getint("BOSWatch","useRegExFilter"):
from includes import filter
if filter.checkFilters(data,typ,pluginName):
if filter.checkFilters(typ,data,pluginName,freq):
logging.debug("call Plugin: %s", pluginName)
plugin.run(typ,freq,data)
logging.debug("return from: %s", pluginName)

View file

@ -32,22 +32,24 @@ def loadFilters():
logging.debug(" - %s = %s", key, val)
filter = val.split(";")
#insert splitet Data into globals.filterList
globals.filterList.append({"name": key, "typ": filter[0], "dataField": filter[1], "plugin": filter[2], "regex": filter[3]})
globals.filterList.append({"name": key, "typ": filter[0], "dataField": filter[1], "plugin": filter[2], "freq": filter[3], "regex": filter[4]})
except:
logging.exception("cannot read config file")
def checkFilters(data,typ,plugin):
def checkFilters(typ,data,plugin,freq):
"""
Check the Typ/Plugin combination with the RegEX Filter
If no Filter for the combination is found, Function returns True.
@type data: map of data (structure see interface.txt)
@param data: Contains the parameter
@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
@type plugin: string
@param plugin: Name of the Plugin to checked
@type freq: string
@param freq: frequency of the SDR Stick
@requires: all Filters in the filterList
@ -55,13 +57,13 @@ def checkFilters(data,typ,plugin):
@exception: Exception if Filter check failed
"""
try:
logging.debug("search Filter for %s to %s", typ, plugin)
logging.debug("search Filter for %s to %s at %s Hz", typ, plugin, freq)
foundFilter = False
#go to all Filter in globals.filterList
for i in globals.filterList:
#if Typ/Plugin combination is found
if i["typ"] == typ and i["plugin"] == plugin:
#if Typ/Plugin/Freq combination is found
if i["typ"] == typ and (i["plugin"] == plugin or i['plugin'] == "*") and (i["freq"] == freq or i['freq'] == "*"):
foundFilter = True
logging.debug("found Filter: %s = %s", i["name"], i["regex"])
#Check the RegEX