mirror of
https://github.com/BOSWatch/BW3-Core.git
synced 2026-04-04 22:07:45 +00:00
add template plugin
This commit is contained in:
parent
9c824ff862
commit
d80db0d6cc
6 changed files with 68 additions and 8 deletions
|
|
@ -51,12 +51,12 @@ class Config:
|
||||||
@param sharePoint: Name of the global share point
|
@param sharePoint: Name of the global share point
|
||||||
@return True or False"""
|
@return True or False"""
|
||||||
try:
|
try:
|
||||||
bool(self._sharePoints[sharePoint])
|
bool(self._sharePoints[sharePoint]) # todo not a nice method to check
|
||||||
logging.error("cannot share config - name is always in use: %s", sharePoint)
|
logging.error("cannot share config - name is always in use: %s", sharePoint)
|
||||||
return False
|
return False
|
||||||
except:
|
except:
|
||||||
self._sharePoints[sharePoint] = self._config
|
self._sharePoints[sharePoint] = self._config
|
||||||
logging.debug("configuration sharePoint: %s", sharePoint)
|
logging.debug("add config sharePoint: %s", sharePoint)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def getInt(self, section, key, sharePoint=""):
|
def getInt(self, section, key, sharePoint=""):
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,9 @@
|
||||||
import logging
|
import logging
|
||||||
import time
|
import time
|
||||||
|
|
||||||
|
from boswatch.utils import paths
|
||||||
|
from boswatch.config import Config
|
||||||
|
|
||||||
logging.debug("- %s loaded", __name__)
|
logging.debug("- %s loaded", __name__)
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -43,6 +46,10 @@ class Plugin:
|
||||||
self._alarmErrorCount = 0
|
self._alarmErrorCount = 0
|
||||||
self._teardownErrorCount = 0
|
self._teardownErrorCount = 0
|
||||||
|
|
||||||
|
if paths.FileExist(paths.PLUGIN_PATH + pluginName + "/" + pluginName + ".ini"):
|
||||||
|
self.config = Config()
|
||||||
|
self.config.loadConfigFile(paths.PLUGIN_PATH + pluginName + "/" + pluginName + ".ini", pluginName)
|
||||||
|
|
||||||
logging.debug("[%s] onLoad()", pluginName)
|
logging.debug("[%s] onLoad()", pluginName)
|
||||||
self.onLoad()
|
self.onLoad()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -29,8 +29,8 @@ BIN_PATH = ROOT_PATH + "_bin/"
|
||||||
TEST_PATH = ROOT_PATH + "test/"
|
TEST_PATH = ROOT_PATH + "test/"
|
||||||
|
|
||||||
|
|
||||||
def ifFileExist(filePath):
|
def FileExist(filePath):
|
||||||
pass
|
return os.path.exists(filePath)
|
||||||
|
|
||||||
|
|
||||||
def makeDirIfNotExist(dirPath):
|
def makeDirIfNotExist(dirPath):
|
||||||
|
|
|
||||||
|
|
@ -57,7 +57,4 @@ zvei = 0
|
||||||
# all greater than 0 enable the plugin
|
# all greater than 0 enable the plugin
|
||||||
# the higher the number the earlier the plugin is called on alarm
|
# the higher the number the earlier the plugin is called on alarm
|
||||||
# we call ist Plugin Prioority
|
# we call ist Plugin Prioority
|
||||||
template = 11
|
template = 1
|
||||||
test = 23
|
|
||||||
testPlugin = 0
|
|
||||||
abcPlugin = 0
|
|
||||||
4
plugins/template/template.ini
Normal file
4
plugins/template/template.ini
Normal file
|
|
@ -0,0 +1,4 @@
|
||||||
|
[Example]
|
||||||
|
String = Hello World!
|
||||||
|
bool = 1
|
||||||
|
integer = 12
|
||||||
52
plugins/template/template.py
Normal file
52
plugins/template/template.py
Normal file
|
|
@ -0,0 +1,52 @@
|
||||||
|
#!/usr/bin/python
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
"""!
|
||||||
|
____ ____ ______ __ __ __ _____
|
||||||
|
/ __ )/ __ \/ ___/ | / /___ _/ /______/ /_ |__ /
|
||||||
|
/ __ / / / /\__ \| | /| / / __ `/ __/ ___/ __ \ /_ <
|
||||||
|
/ /_/ / /_/ /___/ /| |/ |/ / /_/ / /_/ /__/ / / / ___/ /
|
||||||
|
/_____/\____//____/ |__/|__/\__,_/\__/\___/_/ /_/ /____/
|
||||||
|
German BOS Information Script
|
||||||
|
by Bastian Schroll
|
||||||
|
|
||||||
|
@file: template.py
|
||||||
|
@date: 14.01.2018
|
||||||
|
@author: Bastian Schroll
|
||||||
|
@description: Template Plugin File
|
||||||
|
"""
|
||||||
|
import logging
|
||||||
|
from boswatch.plugin.plugin import Plugin
|
||||||
|
|
||||||
|
logging.debug("- %s loaded", __name__)
|
||||||
|
|
||||||
|
|
||||||
|
class BoswatchPlugin(Plugin):
|
||||||
|
def __init__(self):
|
||||||
|
"""!Do not change anything here except the PLUGIN NAME in the super() call"""
|
||||||
|
# PLEASE SET YOU PLUGIN NAME HERE !!!!
|
||||||
|
super().__init__("template")
|
||||||
|
|
||||||
|
def onLoad(self):
|
||||||
|
"""!Called by import of the plugin"""
|
||||||
|
logging.debug("onLoad")
|
||||||
|
|
||||||
|
def setup(self):
|
||||||
|
"""!Called before alarm"""
|
||||||
|
logging.info(self.config.getStr("Example", "String"))
|
||||||
|
|
||||||
|
def alarm(self, bwPacket):
|
||||||
|
"""!Called on alarm
|
||||||
|
|
||||||
|
@param bwPacket: bwPacket instance"""
|
||||||
|
logging.info(bwPacket)
|
||||||
|
logging.info(self.config.getBool("Example", "bool"))
|
||||||
|
|
||||||
|
def teardown(self):
|
||||||
|
"""!Called after alarm
|
||||||
|
Must be inherit"""
|
||||||
|
logging.info(self.config.getInt("Example", "integer"))
|
||||||
|
|
||||||
|
def onUnload(self):
|
||||||
|
logging.debug("onUnload")
|
||||||
|
"""!Called by destruction of the plugin"""
|
||||||
|
pass
|
||||||
Loading…
Add table
Add a link
Reference in a new issue