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
|
2015-05-18 12:03:42 +02:00
|
|
|
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)
|
2015-05-18 12:03:42 +02:00
|
|
|
|
|
|
|
|
#https://docs.python.org/2/howto/logging.html#logging-basic-tutorial
|
|
|
|
|
#log levels
|
2015-05-18 12:28:18 +02:00
|
|
|
#----------
|
2015-05-18 12:03:42 +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 15:27:50 +02:00
|
|
|
data = {"zvei":"12345"}
|
2015-05-18 12:28:18 +02:00
|
|
|
|
2015-05-18 09:04:16 +02:00
|
|
|
while True:
|
|
|
|
|
time.sleep(1)
|
2015-05-18 12:03:42 +02:00
|
|
|
logging.info("Alarm!")
|
2015-05-18 09:04:16 +02:00
|
|
|
for i in pluginloader.getPlugins():
|
2015-05-18 12:03:42 +02:00
|
|
|
logging.debug("Loading plugin " + i["name"])
|
2015-05-18 09:04:16 +02:00
|
|
|
plugin = pluginloader.loadPlugin(i)
|
2015-05-18 14:56:01 +02:00
|
|
|
plugin.run("zvei","80000000",data)
|