diff --git a/plugins/BosMon/BosMon.py b/plugins/BosMon/BosMon.py index 2072e7c..8ccb7b0 100644 --- a/plugins/BosMon/BosMon.py +++ b/plugins/BosMon/BosMon.py @@ -19,6 +19,8 @@ import base64 #for the HTTP request with User/Password from includes import globals # Global variables +from includes.helper import configHandler + ## # # onLoad (init) function of plugin @@ -98,17 +100,7 @@ def run(typ,freq,data): @return: nothing """ try: - # - # ConfigParser - # - logging.debug("reading config file") - try: - for key,val in globals.config.items("BosMon"): - logging.debug(" - %s = %s", key, val) - except: - logging.error("cannot read config file") - logging.debug("cannot read config file", exc_info=True) - else: # Without config, plugin couldn't work + if configHandler.checkConfig("BosMon"): #read and debug the config try: # diff --git a/plugins/MySQL/MySQL.py b/plugins/MySQL/MySQL.py index b545dce..39cab72 100644 --- a/plugins/MySQL/MySQL.py +++ b/plugins/MySQL/MySQL.py @@ -18,6 +18,8 @@ import mysql.connector from includes import globals # Global variables +from includes.helper import configHandler + ## # # onLoad (init) function of plugin @@ -62,17 +64,7 @@ def run(typ,freq,data): @return: nothing """ try: - # - #ConfigParser - # - logging.debug("reading config file") - try: - for key,val in globals.config.items("MySQL"): - logging.debug(" - %s = %s", key, val) - except: - logging.error("cannot read config file") - logging.debug("cannot read config file", exc_info=True) - else: # Without config, plugin couldn't work + if configHandler.checkConfig("MySQL"): #read and debug the config try: # diff --git a/plugins/eMail/eMail.py b/plugins/eMail/eMail.py index 586696a..f7c7448 100644 --- a/plugins/eMail/eMail.py +++ b/plugins/eMail/eMail.py @@ -18,7 +18,9 @@ from email.utils import formatdate # need for confirm to RFC2822 standard from email.utils import make_msgid # need for confirm to RFC2822 standard from includes import globals # Global variables + from includes.helper import timeHandler # helper function +from includes.helper import configHandler ## # @@ -95,18 +97,7 @@ def run(typ,freq,data): @return: nothing """ try: - # - # ConfigParser - # - logging.debug("reading config file") - try: - for key,val in globals.config.items("eMail"): - logging.debug(" - %s = %s", key, val) - - except: - logging.error("cannot read config file") - logging.debug("cannot read config file", exc_info=True) - else: # Without config, plugin couldn't work + if configHandler.checkConfig("eMail"): #read and debug the config try: # diff --git a/plugins/firEmergency/firEmergency.py b/plugins/firEmergency/firEmergency.py index d62dcb4..84fefa3 100644 --- a/plugins/firEmergency/firEmergency.py +++ b/plugins/firEmergency/firEmergency.py @@ -17,6 +17,8 @@ import socket from includes import globals # Global variables +from includes.helper import configHandler + ### # # onLoad (init) function of plugin @@ -59,17 +61,7 @@ def run(typ,freq,data): @return: nothing """ try: - # - #ConfigParser - # - logging.debug("reading config file") - try: - for key,val in globals.config.items("firEmergency"): - logging.debug(" - %s = %s", key, val) - except: - logging.error("cannot read config file") - logging.debug("cannot read config file", exc_info=True) - else: # Without config, plugin couldn't work + if configHandler.checkConfig("firEmergency"): #read and debug the config try: # diff --git a/plugins/httpRequest/httpRequest.py b/plugins/httpRequest/httpRequest.py index df16543..fd6815b 100644 --- a/plugins/httpRequest/httpRequest.py +++ b/plugins/httpRequest/httpRequest.py @@ -15,8 +15,10 @@ import httplib #for the HTTP request from urlparse import urlparse #for split the URL into url and path from includes import globals # Global variables + from includes.helper import timeHandler from includes.helper import wildcardHandler +from includes.helper import configHandler ## # @@ -58,17 +60,7 @@ def run(typ,freq,data): @return: nothing """ try: - # - # ConfigParser - # - logging.debug("reading config file") - try: - for key,val in globals.config.items("httpRequest"): - logging.debug(" - %s = %s", key, val) - except: - logging.error("cannot read config file") - logging.debug("cannot read config file", exc_info=True) - else: # Without config, plugin couldn't work + if configHandler.checkConfig("httpRequest"): #read and debug the config try: # diff --git a/plugins/jsonSocket/jsonSocket.py b/plugins/jsonSocket/jsonSocket.py index 1445aa9..4bb7162 100644 --- a/plugins/jsonSocket/jsonSocket.py +++ b/plugins/jsonSocket/jsonSocket.py @@ -16,6 +16,8 @@ import json # for data-transfer from includes import globals # Global variables +from includes.helper import configHandler + ## # # onLoad (init) function of plugin @@ -58,18 +60,7 @@ def run(typ,freq,data): @return: nothing """ try: - # - # ConfigParser - # - logging.debug("reading config file") - try: - for key,val in globals.config.items("jsonSocket"): - logging.debug(" - %s = %s", key, val) - - except: - logging.error("cannot read config file") - logging.debug("cannot read config file", exc_info=True) - else: # Without config, plugin couldn't work + if configHandler.checkConfig("jsonSocket"): #read and debug the config try: # diff --git a/plugins/template/template.py b/plugins/template/template.py index 33401c2..148fb44 100644 --- a/plugins/template/template.py +++ b/plugins/template/template.py @@ -73,9 +73,6 @@ def run(typ,freq,data): @exception: nothing, make sure this function will never thrown an exception """ try: - # - # ConfigParser - # if configHandler.checkConfig("template"): #read and debug the config (let empty if no config used) ########## User Plugin CODE ##########