Merge branch 'develop' of https://github.com/JHCD/BOSWatch into develop

Imnport new stuff
This commit is contained in:
JHCD 2015-05-19 19:12:03 +02:00
commit 1354bb9906
9 changed files with 487 additions and 121 deletions

View file

@ -1,50 +0,0 @@
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

365
plugin_test/boswatch.py Normal file
View file

@ -0,0 +1,365 @@
#!/usr/bin/python
# -*- coding: cp1252 -*-
##### Info #####
# BOSWatch
# Autor: Bastian Schroll
# Python Script to receive and decode German BOS Information with rtl_fm and multimon-NG
# For more Information see the README.md
##### Info #####
import globals # Global variables
import pluginloader
import logging
import argparse #for parse the args
import ConfigParser #for parse the config file
import re #Regex for validation
import os #for script path
import time #timestamp for doublealarm
#create new logger
logger = logging.getLogger()
logger.setLevel(logging.DEBUG)
#set log string format
formatter = logging.Formatter('%(asctime)s - %(module)-15s [%(levelname)-8s] %(message)s', '%d.%m.%Y %H:%M:%S')
#create a file logger
fh = logging.FileHandler('log/boswatch.log', 'w')
fh.setLevel(logging.DEBUG) #log level >= Debug
fh.setFormatter(formatter)
logger.addHandler(fh)
#create a display logger
ch = logging.StreamHandler()
ch.setLevel(logging.INFO) #log level >= info
ch.setFormatter(formatter)
logger.addHandler(ch)
def throwAlarm(typ,data):
for i in pluginloader.getPlugins():
plugin = pluginloader.loadPlugin(i)
logging.debug(i["name"] + " Plugin called")
plugin.run(typ,"0",data)
# Programm
try:
#first Clear the Logfiles for logging
try:
script_path = os.path.dirname(os.path.abspath(__file__))
if not os.path.exists(script_path+"/log/"):
os.mkdir(script_path+"/log/")
bos_log = open(script_path+"/log/boswatch.log", "w")
rtl_log = open(script_path+"/log/rtl_fm.log", "w")
mon_log = open(script_path+"/log/multimon.log", "w")
# bos_log.write("##### "+curtime()+" #####\n\n")
# rtl_log.write("##### "+curtime()+" #####\n\n")
# mon_log.write("##### "+curtime()+" #####\n\n")
bos_log.close()
rtl_log.close()
mon_log.close()
logging.debug("BOSWatch has started")
except:
logging.exception("cannot clear Logfiles")
try:
logging.debug("parse args")
#With -h or --help you get the Args help
#ArgsParser
parser = argparse.ArgumentParser(prog="boswatch.py", description="BOSWatch is a Python Script to Recive and Decode German BOS Information with rtl_fm and multimon-NG", epilog="More Options you can find in the extern config.ini File in this Folder")
#parser.add_argument("-c", "--channel", help="BOS Channel you want to listen")
parser.add_argument("-f", "--freq", help="Frequency you want to listen", required=True)
parser.add_argument("-d", "--device", help="Device you want to use (Check with rtl_test)", type=int, default=0)
parser.add_argument("-e", "--error", help="Frequency-Error of your Device in PPM", type=int, default=0)
parser.add_argument("-a", "--demod", help="Demodulation Functions", choices=['FMS', 'ZVEI', 'POC512', 'POC1200', 'POC2400'], required=True, nargs="+")
parser.add_argument("-s", "--squelch", help="Level of Squelch", type=int, default=0)
parser.add_argument("-v", "--verbose", help="Shows more Information", action="store_true")
parser.add_argument("-q", "--quiet", help="Shows no Information. Only Logfiles", action="store_true")
args = parser.parse_args()
except:
logging.exception("cannot parse args")
#Read Data from Args, Put it into working Variables
freq = args.freq
device = args.device
error = args.error
squelch = args.squelch
logging.debug(" - Frequency: %s", freq)
logging.debug(" - Device: %s", device)
logging.debug(" - PPM Error: %s", error)
logging.debug(" - Squelch: %s", squelch)
demodulation = ""
if "FMS" in args.demod:
demodulation += "-a FMSFSK "
logging.debug(" - Demod: FMS")
if "ZVEI" in args.demod:
demodulation += "-a ZVEI2 "
logging.debug(" - Demod: ZVEI")
if "POC512" in args.demod:
demodulation += "-a POCSAG512 "
logging.debug(" - Demod: POC512")
if "POC1200" in args.demod:
demodulation += "-a POCSAG1200 "
logging.debug(" - Demod: P")
if "POC2400" in args.demod:
demodulation += "-a POCSAG2400 "
logging.debug(" - Demod: POC2400")
logging.debug(" - Verbose Mode: %s", args.verbose)
logging.debug(" - Quiet Mode: %s", args.quiet)
if args.verbose:
ch.setLevel(logging.DEBUG)
if args.quiet:
ch.setLevel(logging.CRITICAL)
if not args.quiet: #only if not quiet mode
print " ____ ____ ______ __ __ __ "
print " / __ )/ __ \/ ___/ | / /___ _/ /______/ /_ b"
print " / __ / / / /\__ \| | /| / / __ `/ __/ ___/ __ \ e"
print " / /_/ / /_/ /___/ /| |/ |/ / /_/ / /_/ /__/ / / / t"
print " /_____/\____//____/ |__/|__/\__,_/\__/\___/_/ /_/ a"
print " German BOS Information Script "
print " by Bastian Schroll "
print ""
print "Frequency: "+freq
print "Device-ID: "+str(device)
print "Error in PPM: "+str(error)
print "Active Demods: "+str(len(args.demod))
if "FMS" in args.demod:
print "- FMS"
if "ZVEI" in args.demod:
print "- ZVEI"
if "POC512" in args.demod:
print "- POC512"
if "POC1200" in args.demod:
print "- POC1200"
if "POC2400" in args.demod:
print "- POC2400"
print "Squelch: "+str(squelch)
if args.verbose:
print "Verbose Mode!"
print ""
#variables pre-load
logging.debug("pre-load variables")
fms_id = 0
fms_id_old = 0
fms_time_old = 0
zvei_id = 0
zvei_id_old = 0
zvei_time_old = 0
poc_id = 0
poc_id_old = 0
poc_time_old = 0
#ConfigParser
logging.debug("reading config file")
try:
globals.config = ConfigParser.ConfigParser()
globals.config.read(script_path+"/config/config.ini")
fms_double_ignore_time = int(globals.config.get("FMS", "double_ignore_time"))
zvei_double_ignore_time = int(globals.config.get("ZVEI", "double_ignore_time"))
poc_double_ignore_time = int(globals.config.get("POC", "double_ignore_time"))
poc_filter_range_start = int(globals.config.get("POC", "filter_range_start"))
poc_filter_range_end = int(globals.config.get("POC", "filter_range_end"))
except:
logging.exception("cannot read config file")
#in case of reading error, set standard values
logging.debug("set to standard configuration")
fms_double_ignore_time = 5
zvei_double_ignore_time = 5
poc_double_ignore_time = 10
poc_filter_range_start = 0000000
poc_filter_range_end = 9999999
finally:
logging.debug(" - fms_double_ignore_time = %s", fms_double_ignore_time)
logging.debug(" - zvei_double_ignore_time = %s", zvei_double_ignore_time)
logging.debug(" - poc_double_ignore_time = %s", poc_double_ignore_time)
logging.debug(" - poc_filter_range_start = %s", poc_filter_range_start)
logging.debug(" - poc_filter_range_end = %s", poc_filter_range_end)
logging.debug("starting rtl_fm")
# try:
# rtl_fm = subprocess.Popen("rtl_fm -d "+str(device)+" -f "+str(freq)+" -M fm -s 22050 -p "+str(error)+" -E DC -F 0 -l "+str(squelch)+" -g 100",
# #stdin=rtl_fm.stdout,
# stdout=subprocess.PIPE,
# stderr=open(script_path+"/log/rtl_fm.log","a"),
# shell=True)
# except:
# logging.exception("cannot start rtl_fm")
#
logging.debug("starting multimon-ng")
# try:
# multimon_ng = subprocess.Popen("multimon-ng "+str(demodulation)+" -f alpha -t raw /dev/stdin - ",
# stdin=rtl_fm.stdout,
# stdout=subprocess.PIPE,
# stderr=open(script_path+"/log/multimon.log","a"),
# shell=True)
# except:
# logging.exception("cannot start multimon-ng")
logging.debug("start decoding")
while True:
#RAW Data from Multimon-NG
#ZVEI2: 25832
#FMS: 43f314170000 (9=Rotkreuz 3=Bayern 1 Ort 0x25=037FZG 7141Status 3=Einsatz Ab 0=FZG->LST2=III(mit NA,ohneSIGNAL)) CRC correct\n'
#decoded = str(multimon_ng.stdout.readline()) #Get line data from multimon stdout
#only for develop
#decoded = "ZVEI2: 25832"
decoded = "FMS: 43f314170000 (9=Rotkreuz 3=Bayern 1 Ort 0x25=037FZG 7141Status 3=Einsatz Ab 0=FZG->LST 2=III(mit NA,ohneSIGNAL)) CRC correct\n'"
time.sleep(1)
if True: #if input data avalable
timestamp = int(time.time())#Get Timestamp
#FMS Decoder Section
#check FMS: -> check CRC -> validate -> check double alarm -> log
if "FMS:" in decoded:
logging.debug("recieved FMS")
fms_service = decoded[19] #Organisation
fms_country = decoded[36] #Bundesland
fms_location = decoded[65:67] #Ort
fms_vehicle = decoded[72:76] #Fahrzeug
fms_status = decoded[84] #Status
fms_direction = decoded[101] #Richtung
fms_tsi = decoded[114:117] #Taktische Kruzinformation
if "CRC correct" in decoded: #check CRC is correct
fms_id = fms_service+fms_country+fms_location+fms_vehicle+fms_status+fms_direction #build FMS id
if re.search("[0-9a-f]{8}[0-9a-f]{1}[01]{1}", fms_id): #if FMS is valid
if fms_id == fms_id_old and timestamp < fms_time_old + fms_double_ignore_time: #check for double alarm
logging.warning("FMS double alarm: %s within %s second(s)", fms_id_old, timestamp-fms_time_old)
fms_time_old = timestamp #in case of double alarm, fms_double_ignore_time set new
else:
logging.info("FMS:%s Status:%s Richtung:%s TKI:%s", fms_id[0:8], fms_status, fms_direction, fms_tsi)
data = {"fms":fms_id[0:8], "status":fms_status, "direction":fms_direction, "tki":fms_tsi}
throwAlarm("FMS",data)
fms_id_old = fms_id #save last id
fms_time_old = timestamp #save last time
else:
logging.warning("No valid FMS: %s", fms_id)
else:
logging.warning("FMS CRC incorrect")
#ZVEI Decoder Section
#check ZVEI: -> validate -> check double alarm -> log
if "ZVEI2:" in decoded:
logging.debug("recieved ZVEI")
zvei_id = decoded[7:12] #ZVEI Code
if re.search("[0-9F]{5}", zvei_id): #if ZVEI is valid
if zvei_id == zvei_id_old and timestamp < zvei_time_old + zvei_double_ignore_time: #check for double alarm
logging.warning("ZVEI double alarm: %s within %s second(s)", zvei_id_old, timestamp-zvei_time_old)
zvei_time_old = timestamp #in case of double alarm, zvei_double_ignore_time set new
else:
logging.info("5-Ton: %s", zvei_id)
data = {"zvei":zvei_id}
throwAlarm("ZVEI",data)
zvei_id_old = zvei_id #save last id
zvei_time_old = timestamp #save last time
else:
logging.warning("No valid ZVEI: %s", zvei_id)
#POCSAG512 Decoder Section
#check POCSAG512: -> validate -> check double alarm -> log
#POCSAG512: Address: 1234567 Function: 1 Alpha: XXMSG MEfeweffsjh
if "POCSAG512:" in decoded:
logging.debug("recieved POCSAG512")
poc_id = decoded[20:27] #POC Code
poc_sub = decoded[39].replace("3", "4").replace("2", "3").replace("1", "2").replace("0", "1")
if "Alpha:" in decoded: #check if there is a text message
poc_text = decoded.split('Alpha: ')[1].strip().rstrip('<EOT>').strip()
else:
poc_text = ""
if re.search("[0-9]{7}", poc_id): #if POC is valid
if poc_id >= poc_filter_range_start:
if poc_id >= poc_filter_range_start:
if poc_id == poc_id_old and timestamp < poc_time_old + poc_double_ignore_time: #check for double alarm
logging.warning("POC512 double alarm: %s within %s second(s)", poc_id_old, timestamp-poc_time_old)
poc_time_old = timestamp #in case of double alarm, poc_double_ignore_time set new
else:
logging.info("POCSAG512: %s %s %s ", poc_id, poc_sub, poc_text)
data = {"ric":poc_id, "function":poc_sub, "msg":poc_text}
throwAlarm("POC",data)
poc_id_old = poc_id #save last id
poc_time_old = timestamp #save last time
else:
logging.warning("POCSAG512: %s out of filter range", poc_id)
else:
logging.warning("POCSAG512: %s out of filter range", poc_id)
else:
logging.warning("No valid POCSAG512: %s", poc_id)
#POCSAG1200 Decoder Section
#check POCSAG1200: -> validate -> check double alarm -> log
#POCSAG1200: Address: 1234567 Function: 1 Alpha: XXMSG MEfeweffsjh
if "POCSAG1200:" in decoded:
logging.debug("recieved POCSAG1200")
poc_id = decoded[21:28] #POC Code
poc_sub = decoded[40].replace("3", "4").replace("2", "3").replace("1", "2").replace("0", "1")
if "Alpha:" in decoded: #check if there is a text message
poc_text = decoded.split('Alpha: ')[1].strip().rstrip('<EOT>').strip()
else:
poc_text = ""
if re.search("[0-9]{7}", poc_id): #if POC is valid
if poc_id >= poc_filter_range_start:
if poc_id >= poc_filter_range_start:
if poc_id == poc_id_old and timestamp < poc_time_old + poc_double_ignore_time: #check for double alarm
logging.warning("POC1200 double alarm: %s within %s second(s)", poc_id_old, timestamp-poc_time_old)
poc_time_old = timestamp #in case of double alarm, poc_double_ignore_time set new
else:
logging.info("POCSAG1200: %s %s %s", poc_id, poc_sub, poc_text)
data = {"ric":poc_id, "function":poc_sub, "msg":poc_text}
throwAlarm("POC",data)
poc_id_old = poc_id #save last id
poc_time_old = timestamp #save last time
else:
logging.warning("POCSAG1200: %s out of filter range", poc_id)
else:
logging.warning("POCSAG1200: %s out of filter range", poc_id)
else:
logging.warning("No valid POCSAG1200: %s", poc_id)
except KeyboardInterrupt:
logging.warning("Keyboard Interrupt")
except:
logging.exception("unknown error")
finally:
try:
# rtl_fm.terminate()
logging.debug("rtl_fm terminated")
# multimon_ng.terminate()
logging.debug("multimon-ng terminated")
logging.debug("exiting BOSWatch")
except:
logging.exception("failed in clean-up routine")
finally:
exit(0)

View file

@ -2,13 +2,27 @@
# BOSWatch Config File #
########################
[FMS]
#time to ignore same alarm in a row (sek)
double_ignore_time = 5
[ZVEI]
#time to ignore same alarm in a row (sek)
double_ignore_time = 5
[POC]
#time to ignore same alarm in a row (sek)
double_ignore_time = 10
filter_range_start = 0000000
filter_range_end = 9999999
#can take on or off the modules (0|1)
[Module]
MySQL = 0
HTTPrequest = 0
BosMon = 0
# for developing template-module is enabled
template = 1
none = 1
[BosMon]
#Server as IP of DNS-Name (without http://)
@ -20,3 +34,10 @@ bosmon_channel = pocsag
#Use this, when BosMon has restricted access
bosmon_user =
bosmon_password =
[template]
data1 = test123
data2 = test345
data3 = test567
data4 = test789

View file

@ -8,13 +8,14 @@ import pluginloader
import os #for absolute path: os.path.dirname(os.path.abspath(__file__))
import ConfigParser #for parse the config file
#create new logger
import logging
#create new logger
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')
formatter = logging.Formatter('%(asctime)s - %(module)s [%(levelname)s] %(message)s', '%d.%m.%Y %H:%M:%S')
#create a file loger
fh = logging.FileHandler('boswatch.log', 'w')
@ -24,7 +25,7 @@ logger.addHandler(fh)
#create a display loger
ch = logging.StreamHandler()
ch.setLevel(logging.ERROR) #log level >= Error
ch.setLevel(logging.INFO) #log level >= info
ch.setFormatter(formatter)
logger.addHandler(ch)
@ -32,28 +33,32 @@ logger.addHandler(ch)
#log levels
#----------
#debug - debug messages only for log
#info - only an information
#info - information for normal display
#warning
#error - normal error - program goes further
#exception - error handler in try:exc: into the message
#exception - error with exception message in log
#critical - critical error, program exit
#ConfigParser
logging.info("reading config file")
#configparser
try:
logging.debug("reading config file")
script_path = os.path.dirname(os.path.abspath(__file__))
globals.config = ConfigParser.ConfigParser()
globals.config.read(script_path+"/config/config.ini")
except:
logging.error("cannot read config file","error")
logging.exception("cannot read config file")
#data = {"zvei":"12345"}
data = {"ric":"1234567", "function":"1", "msg":"Hello World!"}
while True:
time.sleep(1)
logging.info("Alarm!")
for i in pluginloader.getPlugins():
logging.debug("Load Plugin: " + i["name"])
plugin = pluginloader.loadPlugin(i)
plugin.run("POC","80000000",data)
try:
time.sleep(1)
logging.info("Alarm!")
for i in pluginloader.getPlugins():
plugin = pluginloader.loadPlugin(i)
logging.debug(i["name"] + " Plugin called")
plugin.run("POC","80000000",data)
except:
logging.exception("Cannot Throw Modules")
exit()

View file

@ -7,28 +7,29 @@ import imp
import os
PluginFolder = "./plugins"
MainModule = "__init__"
def getPlugins():
plugins = []
possibleplugins = os.listdir(PluginFolder)
for i in possibleplugins:
location = os.path.join(PluginFolder, i)
# plugins have to be a subdir with MainModule, if not skip
if not os.path.isdir(location) or not MainModule + ".py" in os.listdir(location):
continue
logging.debug("found plugin: "+i)
# is the plugin enabled in the config-file?
try:
usePlugin = int(globals.config.get("Module", i))
except: #no entry for plugin found in config-file, skip
continue
logging.debug("use Plugin: "+str(usePlugin))
if usePlugin:
info = imp.find_module(MainModule, [location])
plugins.append({"name": i, "info": info})
logging.debug("append Plugin: "+i)
return plugins
plugins = []
possibleplugins = os.listdir(PluginFolder)
for i in possibleplugins:
location = os.path.join(PluginFolder, i)
# plugins have to be a subdir with MainModule, if not skip
if not os.path.isdir(location) or not i + ".py" in os.listdir(location):
continue
logging.debug("found plugin: "+i)
# is the plugin enabled in the config-file?
try:
usePlugin = int(globals.config.get("Module", i))
except: #no entry for plugin found in config-file, skip
logging.warning("Plugin not in config: "+i)
logging.debug("use Plugin: "+str(usePlugin))
if usePlugin:
info = imp.find_module(i, [location])
plugins.append({"name": i, "info": info})
logging.debug("append Plugin: "+i)
return plugins
def loadPlugin(plugin):
return imp.load_module(MainModule, *plugin["info"])
return imp.load_module(plugin["name"], *plugin["info"])

View file

@ -8,38 +8,38 @@ import httplib #for the HTTP request
import urllib #for the HTTP request with parameters
import base64 #for the HTTP request with User/Password
def run(typ,frequenz,daten):
logging.debug("BosMon Plugin called")
logging.debug(" - typ: " +typ)
def run(typ,freq,data):
try:
#get BosMon-Config
logging.debug("read config file")
bosmon_server = globals.config.get("BosMon", "bosmon_server")
bosmon_port = globals.config.get("BosMon", "bosmon_port")
bosmon_user = globals.config.get("BosMon", "bosmon_user")
bosmon_password = globals.config.get("BosMon", "bosmon_password")
bosmon_channel = globals.config.get("BosMon", "bosmon_channel")
logging.debug(" - Server: " +bosmon_server)
logging.debug(" - Port: " +bosmon_port)
logging.debug(" - User: " +bosmon_user)
logging.debug(" - Channel: " +bosmon_channel)
logging.debug(" - typ: %s", typ)
logging.debug(" - Server: %s", bosmon_server)
logging.debug(" - Port: %s", bosmon_port)
logging.debug(" - User: %s", bosmon_user)
logging.debug(" - Channel: %s", bosmon_channel)
if typ == "FMS":
logging.warning("FMS not implemented in BosMon plugin")
logging.warning("FMS not implemented")
elif typ == "ZVEI":
logging.warning("ZVEI not implemented in BosMon plugin")
logging.warning("ZVEI not implemented")
elif typ == "POC":
logging.debug("Start POC to BosMon")
try:
#Defined data structure:
# daten["ric"]
# daten["function"]
# daten["msg"]
# data["ric"]
# data["function"]
# data["msg"]
#BosMon-Telegramin expected "a-d" as RIC-sub/function
daten["function"] = daten["function"].replace("1", "a").replace("2", "b").replace("3", "c").replace("4", "d")
params = urllib.urlencode({'type':'pocsag', 'address':daten["ric"], 'flags':'0', 'function':daten["function"], 'message':daten["msg"]})
logging.debug(" - Params:" +params)
data["function"] = data["function"].replace("1", "a").replace("2", "b").replace("3", "c").replace("4", "d")
params = urllib.urlencode({'type':'pocsag', 'address':data["ric"], 'flags':'0', 'function':data["function"], 'message':data["msg"]})
logging.debug(" - Params: %s", params)
headers = {}
headers['Content-type'] = "application/x-www-form-urlencoded"
headers['Accept'] = "text/plain"
@ -49,12 +49,12 @@ def run(typ,frequenz,daten):
httprequest.request("POST", "/telegramin/"+bosmon_channel+"/input.xml", params, headers)
httpresponse = httprequest.getresponse()
if str(httpresponse.status) == "200": #Check HTTP Response an print a Log or Error
logging.debug("BosMon response: "+str(httpresponse.status)+" - "+str(httpresponse.reason))
logging.debug("BosMon response: %s - %s", str(httpresponse.status), str(httpresponse.reason))
else:
logging.warning("BosMon response: "+str(httpresponse.status)+" - "+str(httpresponse.reason))
logging.warning("BosMon response: %s - %s", str(httpresponse.status), str(httpresponse.reason))
except:
logging.warning("POC to BosMon failed")
logging.error("POC to BosMon failed")
else:
logging.warning("typ '"+typ+"' undefined in BosMon plugin")
logging.warning("undefined typ '%s'", typ)
except:
logging.exception("Error in BosMon Plugin")
logging.exception("")

View file

@ -0,0 +1,9 @@
#!/usr/bin/python
# -*- coding: cp1252 -*-
import logging # Global logger
import globals # Global variables
def run(typ,freq,data):
logging.info("Nothing to do")

View file

@ -1,14 +0,0 @@
#!/usr/bin/python
# -*- coding: cp1252 -*-
import logging # Global logger
import globals # Global variables
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")

View file

@ -0,0 +1,29 @@
#!/usr/bin/python
# -*- coding: cp1252 -*-
import logging # Global logger
import globals # Global variables
def run(typ,freq,data):
try:
logging.debug("read config file")
data1 = globals.config.get("template", "data1")
data2 = globals.config.get("template", "data2")
data3 = globals.config.get("template", "data3")
data4 = globals.config.get("template", "data4")
logging.debug(" - Data1: %s", data1)
logging.debug(" - Data2: %s", data2)
logging.debug(" - Data3: %s", data3)
logging.debug(" - Data4: %s", data4)
if typ == "FMS":
logging.debug("FMS: %s Status: %s Dir: %s", data["fms"], data["status"], data["direction"])
elif typ == "ZVEI":
logging.debug("ZVEI: %s", data["zvei"])
elif typ == "POC":
logging.debug("POC: %s/%s - %s", data["ric"], data["function"], data["msg"])
else:
logging.warning(typ + " not supportet")
except:
logging.exception("unknown error")