Merge pull request #15 from Schrolli91/develop

Develop
This commit is contained in:
Schrolli91 2015-05-18 15:45:39 +02:00
commit b9596bcee4
7 changed files with 119 additions and 10 deletions

5
.gitignore vendored
View file

@ -1 +1,4 @@
*.psd
*.psd
*.pyc
*.log
*.log

50
plugin_test/boswatch.log Normal file
View file

@ -0,0 +1,50 @@
18.05.2015 03:30:59 - INFO: Alarm!
18.05.2015 03:30:59 - DEBUG: Loading plugin template
18.05.2015 03:30:59 - DEBUG: Throw Template Plugin
18.05.2015 03:30:59 - INFO: ZVEI: 12345 wurde auf 80000000 empfangen!
18.05.2015 03:30:59 - DEBUG: try 5/0
18.05.2015 03:30:59 - ERROR: Error in Template Plugin
Traceback (most recent call last):
File "./plugins\template\__init__.py", line 8, in run
test = 5/0
ZeroDivisionError: division by zero
18.05.2015 03:31:00 - INFO: Alarm!
18.05.2015 03:31:00 - DEBUG: Loading plugin template
18.05.2015 03:31:00 - DEBUG: Throw Template Plugin
18.05.2015 03:31:00 - INFO: ZVEI: 12345 wurde auf 80000000 empfangen!
18.05.2015 03:31:00 - DEBUG: try 5/0
18.05.2015 03:31:00 - ERROR: Error in Template Plugin
Traceback (most recent call last):
File "./plugins\template\__init__.py", line 8, in run
test = 5/0
ZeroDivisionError: division by zero
18.05.2015 03:31:01 - INFO: Alarm!
18.05.2015 03:31:01 - DEBUG: Loading plugin template
18.05.2015 03:31:01 - DEBUG: Throw Template Plugin
18.05.2015 03:31:01 - INFO: ZVEI: 12345 wurde auf 80000000 empfangen!
18.05.2015 03:31:01 - DEBUG: try 5/0
18.05.2015 03:31:01 - ERROR: Error in Template Plugin
Traceback (most recent call last):
File "./plugins\template\__init__.py", line 8, in run
test = 5/0
ZeroDivisionError: division by zero
18.05.2015 03:31:02 - INFO: Alarm!
18.05.2015 03:31:02 - DEBUG: Loading plugin template
18.05.2015 03:31:02 - DEBUG: Throw Template Plugin
18.05.2015 03:31:02 - INFO: ZVEI: 12345 wurde auf 80000000 empfangen!
18.05.2015 03:31:02 - DEBUG: try 5/0
18.05.2015 03:31:02 - ERROR: Error in Template Plugin
Traceback (most recent call last):
File "./plugins\template\__init__.py", line 8, in run
test = 5/0
ZeroDivisionError: division by zero
18.05.2015 03:31:03 - INFO: Alarm!
18.05.2015 03:31:03 - DEBUG: Loading plugin template
18.05.2015 03:31:03 - DEBUG: Throw Template Plugin
18.05.2015 03:31:03 - INFO: ZVEI: 12345 wurde auf 80000000 empfangen!
18.05.2015 03:31:03 - DEBUG: try 5/0
18.05.2015 03:31:03 - ERROR: Error in Template Plugin
Traceback (most recent call last):
File "./plugins\template\__init__.py", line 8, in run
test = 5/0
ZeroDivisionError: division by zero

View file

@ -4,10 +4,43 @@
import time
import pluginloader
#create new logger
import logging
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
#----------
#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
#critical - critical error, program exit
data = {"zvei":"12345"}
while True:
time.sleep(1)
print ("Alarm!")
logging.info("Alarm!")
for i in pluginloader.getPlugins():
print("Loading plugin " + i["name"])
logging.debug("Load Plugin: " + i["name"])
plugin = pluginloader.loadPlugin(i)
plugin.run()
plugin.run("zvei","80000000",data)

View file

@ -1,2 +0,0 @@
def run():
print("throw HTTP Plugin")

View file

@ -0,0 +1,19 @@
Übergabe an Plugin:
typ = FMS, ZVEI oder POC
freq = Frequenz in Hz
data = {"KEY":"VALUE"} als Python Dict
ZVEI:
- zvei
FMS:
- fms
- status
- direction
- tki
POCSAG:
- ric
- sub_ric
- text

View file

@ -1,2 +0,0 @@
def run():
print("Throw MySql Plugin")

View file

@ -1,2 +1,10 @@
def run():
print("Throw template Plugin")
import logging
def run(typ,freq,data):
logging.debug("Strat Plugin: template")
try:
logging.info("ZVEI: %s wurde auf %s empfangen!", data["zvei"],freq)
logging.debug("try 5/0")
test = 5/0
except:
logging.exception("Error in Template Plugin")