mirror of
https://github.com/BOSWatch/BW3-Core.git
synced 2026-01-20 15:40:24 +01:00
add a modeFilter module
This commit is contained in:
parent
35c6de4c54
commit
2e9681b7d4
|
|
@ -65,7 +65,7 @@ class RouterManager:
|
|||
for route in router.get("route"):
|
||||
routeType = route.get("type")
|
||||
routeName = route.get("name")
|
||||
routeConfig = route.get("Config", default=ConfigYAML()) # if no config - build a empty
|
||||
routeConfig = route.get("config", default=ConfigYAML()) # if no config - build a empty
|
||||
|
||||
if routeType is None or routeName is None:
|
||||
logging.error("type or name not found in route: %s", route)
|
||||
|
|
|
|||
|
|
@ -69,7 +69,8 @@ if not bwConfig.loadConfigFile(paths.CONFIG_PATH + args.config):
|
|||
try:
|
||||
|
||||
bwRoutMan = RouterManager()
|
||||
bwRoutMan.buildRouter(bwConfig)
|
||||
if not bwRoutMan.buildRouter(bwConfig):
|
||||
exit()
|
||||
|
||||
if bwConfig.get("server", "useBroadcast", default=False):
|
||||
bcServer = BroadcastServer()
|
||||
|
|
|
|||
|
|
@ -14,25 +14,13 @@ server:
|
|||
|
||||
alarmRouter:
|
||||
- Router 1
|
||||
- Test
|
||||
|
||||
router:
|
||||
- name: Router 1
|
||||
route:
|
||||
- type: module
|
||||
name: template_module
|
||||
name: filter.modeFilter
|
||||
config:
|
||||
maxEntry: 30
|
||||
ignoreTime: 10
|
||||
checkMsg: no
|
||||
- type: router
|
||||
name: Router 2
|
||||
- type: plugin
|
||||
name: template_plugin
|
||||
config:
|
||||
user: test
|
||||
pass: test
|
||||
- name: Router 2
|
||||
route:
|
||||
- type: module
|
||||
name: template_module
|
||||
allowed:
|
||||
- fms
|
||||
- zvei
|
||||
|
|
|
|||
53
module/filter/modeFilter.py
Normal file
53
module/filter/modeFilter.py
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
"""!
|
||||
____ ____ ______ __ __ __ _____
|
||||
/ __ )/ __ \/ ___/ | / /___ _/ /______/ /_ |__ /
|
||||
/ __ / / / /\__ \| | /| / / __ `/ __/ ___/ __ \ /_ <
|
||||
/ /_/ / /_/ /___/ /| |/ |/ / /_/ / /_/ /__/ / / / ___/ /
|
||||
/_____/\____//____/ |__/|__/\__,_/\__/\___/_/ /_/ /____/
|
||||
German BOS Information Script
|
||||
by Bastian Schroll
|
||||
|
||||
@file: modeFilter.py
|
||||
@date: 09.03.2019
|
||||
@author: Bastian Schroll
|
||||
@description: Filter module for the packet type
|
||||
"""
|
||||
import logging
|
||||
from module.module import Module
|
||||
|
||||
# ###################### #
|
||||
# Custom plugin includes #
|
||||
|
||||
# ###################### #
|
||||
|
||||
logging.debug("- %s loaded", __name__)
|
||||
|
||||
|
||||
class BoswatchModule(Module):
|
||||
"""!Filter of specific bwPacket mode"""
|
||||
def __init__(self, config):
|
||||
"""!Do not change anything here!"""
|
||||
super().__init__(__name__, config) # you can access the config DICT by 'self._config'
|
||||
|
||||
def onLoad(self):
|
||||
"""!Called by import of the plugin"""
|
||||
pass
|
||||
|
||||
def doWork(self, bwPacket):
|
||||
"""!start an rund of the module.
|
||||
|
||||
@param bwPacket: A BOSWatch packet instance
|
||||
@return bwPacket or False"""
|
||||
|
||||
for mode in self.config.get("allowed"):
|
||||
if bwPacket.get("mode") == mode:
|
||||
logging.debug("mode is allowed: %s", bwPacket.get("mode"))
|
||||
return None
|
||||
logging.debug("mode is denied: %s", bwPacket.get("mode"))
|
||||
return False
|
||||
|
||||
def onUnload(self):
|
||||
"""!Called by destruction of the plugin"""
|
||||
pass
|
||||
Loading…
Reference in a new issue