diff --git a/plugin_test/config/config.ini b/plugin_test/config/config.ini index ba86077..193ca98 100644 --- a/plugin_test/config/config.ini +++ b/plugin_test/config/config.ini @@ -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 diff --git a/plugin_test/plugin_test.py b/plugin_test/plugin_test.py index 86920df..06207ad 100755 --- a/plugin_test/plugin_test.py +++ b/plugin_test/plugin_test.py @@ -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!"} diff --git a/plugin_test/pluginloader.py b/plugin_test/pluginloader.py index 60e6e56..cb353e4 100644 --- a/plugin_test/pluginloader.py +++ b/plugin_test/pluginloader.py @@ -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)) diff --git a/plugin_test/plugins/BosMon/__init__.py b/plugin_test/plugins/BosMon/__init__.py index 00845c3..b66a4ce 100644 --- a/plugin_test/plugins/BosMon/__init__.py +++ b/plugin_test/plugins/BosMon/__init__.py @@ -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" diff --git a/plugin_test/plugins/template/__init__.py b/plugin_test/plugins/template/__init__.py index 0e10a17..f9008a2 100644 --- a/plugin_test/plugins/template/__init__.py +++ b/plugin_test/plugins/template/__init__.py @@ -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") \ No newline at end of file