From 43e56967cc8b9a781191144fba1f03167635ad7b Mon Sep 17 00:00:00 2001 From: Bastian Schroll Date: Sat, 23 May 2015 08:47:05 +0200 Subject: [PATCH] add filter.py filtering alarms method getFilters() added --- config/config.template.ini | 7 +++++++ includes/filter.py | 17 +++++++++++++++++ includes/globals.py | 7 +++++-- 3 files changed, 29 insertions(+), 2 deletions(-) create mode 100644 includes/filter.py diff --git a/config/config.template.ini b/config/config.template.ini index cafa98f..cede352 100644 --- a/config/config.template.ini +++ b/config/config.template.ini @@ -24,6 +24,13 @@ poc_filter_range_start = 0000000 poc_filter_range_end = 9999999 +[Filters] +#NAME = TYP;PLUGIN;REGEX +zvei_local_filter = ZVEI;template;25[0-9F]{3} +zvei_mysql = ZVEI;MySQL;23[0-9F]{3} +fms_filter = FMS;template;25[0-9F]{3} + + [Plugins] #can take on or off the plugins (0|1) MySQL = 0 diff --git a/includes/filter.py b/includes/filter.py new file mode 100644 index 0000000..c4baadc --- /dev/null +++ b/includes/filter.py @@ -0,0 +1,17 @@ +#!/usr/bin/python +# -*- coding: cp1252 -*- + +import logging # Global logger + +from includes import globals # Global variables + + +def getFilters(): + logging.debug("reading config file") + try: + for key,val in globals.config.items("Filters"): + logging.debug(" - %s = %s", key, val) + filter = val.split(";") + globals.filterList.append({"name": key, "typ": filter[0], "plugin": filter[1], "regex": filter[2]}) + except: + logging.exception("cannot read config file") diff --git a/includes/globals.py b/includes/globals.py index 14fb308..f4af170 100644 --- a/includes/globals.py +++ b/includes/globals.py @@ -15,5 +15,8 @@ zvei_time_old = 0 poc_id_old = 0 poc_time_old = 0 -#pluginHandler -pluginList = {} \ No newline at end of file +#pluginLoader +pluginList = {} + +#filter +filterList = [] \ No newline at end of file