BOSWatch/plugin_test/plugin_test.py

46 lines
1.1 KiB
Python
Raw Normal View History

2015-05-18 09:04:16 +02:00
#!/usr/bin/python
# -*- coding: cp1252 -*-
import time
import pluginloader
2015-05-18 12:28:18 +02:00
#create new logger
import logging
2015-05-18 12:28:18 +02:00
logger = logging.getLogger()
logger.setLevel(logging.DEBUG)
#set log string format
formatter = logging.Formatter('%(asctime)s - %(levelname)s: %(message)s', '%d.%m.%Y %I:%M:%S')
#create a file loger
fh = logging.FileHandler('boswatch.log', 'w')
fh.setLevel(logging.DEBUG) #log level >= Debug
fh.setFormatter(formatter)
logger.addHandler(fh)
#create a display loger
ch = logging.StreamHandler()
ch.setLevel(logging.ERROR) #log level >= Error
ch.setFormatter(formatter)
logger.addHandler(ch)
#https://docs.python.org/2/howto/logging.html#logging-basic-tutorial
#log levels
2015-05-18 12:28:18 +02:00
#----------
#debug - debug messages only for log
#info - only an information
#warning
#error - normal error - program goes further
#exception - error handler in try:exc: into the message
2015-05-18 14:49:10 +02:00
#critical - critical error, program exit
2015-05-18 12:28:18 +02:00
2015-05-18 14:49:10 +02:00
daten = ["12345"]
2015-05-18 12:28:18 +02:00
2015-05-18 09:04:16 +02:00
while True:
time.sleep(1)
logging.info("Alarm!")
2015-05-18 09:04:16 +02:00
for i in pluginloader.getPlugins():
logging.debug("Loading plugin " + i["name"])
2015-05-18 09:04:16 +02:00
plugin = pluginloader.loadPlugin(i)
2015-05-18 14:49:10 +02:00
plugin.run("zvei","00000000",daten)