mirror of
https://github.com/Schrolli91/BOSWatch.git
synced 2026-01-09 09:59:58 +01:00
little changes
This commit is contained in:
parent
e2b4ef82c9
commit
7731031a15
|
|
@ -4,8 +4,6 @@
|
|||
|
||||
#can take on or off the modules (0|1)
|
||||
[Module]
|
||||
MySQL = 0
|
||||
HTTPrequest = 0
|
||||
BosMon = 0
|
||||
# for developing template-module is enabled
|
||||
template = 1
|
||||
|
|
|
|||
|
|
@ -8,8 +8,9 @@ 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)
|
||||
|
||||
|
|
@ -32,20 +33,20 @@ logger.addHandler(ch)
|
|||
#log levels
|
||||
#----------
|
||||
#debug - debug messages only for log
|
||||
#info - only an information
|
||||
#info - inormation 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")
|
||||
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!"}
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ def getPlugins():
|
|||
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))
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ 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):
|
||||
def run(typ,freq,data):
|
||||
logging.debug("BosMon Plugin called")
|
||||
logging.debug(" - typ: " +typ)
|
||||
try:
|
||||
|
|
@ -33,12 +33,12 @@ def run(typ,frequenz,daten):
|
|||
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"]})
|
||||
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:" +params)
|
||||
headers = {}
|
||||
headers['Content-type'] = "application/x-www-form-urlencoded"
|
||||
|
|
|
|||
|
|
@ -5,10 +5,8 @@ import logging # Global logger
|
|||
import globals # Global variables
|
||||
|
||||
def run(typ,freq,data):
|
||||
logging.debug("Strat Plugin: template")
|
||||
logging.debug("template Plugin called")
|
||||
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")
|
||||
Loading…
Reference in a new issue