diff --git a/includes/pluginLoader.py b/includes/pluginLoader.py index 3b606af..45b811b 100644 --- a/includes/pluginLoader.py +++ b/includes/pluginLoader.py @@ -29,20 +29,21 @@ def loadPlugins(): for i in getPlugins(): # call for each Plugin the loadPlugin() Methode plugin = loadPlugin(i) - # Add it to globals.pluginList - globals.pluginList[i["name"]] = plugin - - #call the .onLoad() routine for all active plugins - for pluginName, plugin in globals.pluginList.items(): - logging.debug("call %s.onLoad()", pluginName) + # Try to call the .onLoad() routine for all active plugins try: - plugin.onLoad(typ,freq,data) + logging.debug("call %s.onLoad()", i["name"]) + plugin.onLoad() + # Add it to globals.pluginList + globals.pluginList[i["name"]] = plugin except: # call next plugin, if one has thrown an exception + logging.error("error calling %s.onLoad()", i["name"]) + logging.debug("error calling %s.onLoad()", exc_info=True) pass - except: - logging.exception("cannot load Plugins") + logging.error("cannot load Plugins") + logging.debug("cannot load Plugins", exc_info=True) + raise def getPlugins(): @@ -77,7 +78,9 @@ def getPlugins(): logging.warning("Plugin [NO CONF ] %s", i) pass except: - logging.exception("Error during Plugin search") + logging.error("Error during Plugin search") + logging.debug("cannot load Plugins", exc_info=True) + raise return plugins @@ -97,4 +100,6 @@ def loadPlugin(plugin): logging.debug("load Plugin: %s", plugin["name"]) return imp.load_module(plugin["name"], *plugin["info"]) except: - logging.exception("cannot load Plugin: %s", plugin["name"]) \ No newline at end of file + logging.error("cannot load Plugin: %s", plugin["name"]) + logging.debug("cannot load Plugin: %s", plugin["name"], exc_info=True) + raise \ No newline at end of file diff --git a/plugins/BosMon/BosMon.py b/plugins/BosMon/BosMon.py index 760cc44..40b54cb 100644 --- a/plugins/BosMon/BosMon.py +++ b/plugins/BosMon/BosMon.py @@ -21,24 +21,20 @@ from includes import globals # Global variables ## # -# onLoad function of plugin -# will be called by the pluginLoader +# onLoad (init) function of plugin +# will be called one time by the pluginLoader on start # def onLoad(): """ While loading the plugins by pluginLoader.loadPlugins() - this onLoad() routine are called + this onLoad() routine is called one time for initialize the plugin @requires: nothing @return: nothing """ - try: - # we have to do nothing here... - pass - except: - logging.error("unknown error") - logging.debug("unknown error", exc_info=True) + # nothing to do for this plugin + return ## # diff --git a/plugins/MySQL/MySQL.py b/plugins/MySQL/MySQL.py index ceb377d..c321cc1 100644 --- a/plugins/MySQL/MySQL.py +++ b/plugins/MySQL/MySQL.py @@ -20,24 +20,21 @@ from includes import globals # Global variables ## # -# onLoad function of plugin -# will be called by the pluginLoader +# onLoad (init) function of plugin +# will be called one time by the pluginLoader on start # def onLoad(): """ While loading the plugins by pluginLoader.loadPlugins() - this onLoad() routine are called + this onLoad() routine is called one time for initialize the plugin @requires: nothing @return: nothing """ - try: - # we have to do nothing here... - pass - except: - logging.error("unknown error") - logging.debug("unknown error", exc_info=True) + # nothing to do for this plugin + return + ## # diff --git a/plugins/eMail/eMail.py b/plugins/eMail/eMail.py index ec72743..904a62a 100644 --- a/plugins/eMail/eMail.py +++ b/plugins/eMail/eMail.py @@ -21,25 +21,22 @@ from includes import globals # Global variables ## # -# onLoad function of plugin -# will be called by the pluginLoader +# onLoad (init) function of plugin +# will be called one time by the pluginLoader on start # def onLoad(): """ While loading the plugins by pluginLoader.loadPlugins() - this onLoad() routine are called + this onLoad() routine is called one time for initialize the plugin @requires: nothing @return: nothing """ - try: - # we have to do nothing here... - pass - except: - logging.error("unknown error") - logging.debug("unknown error", exc_info=True) - + # nothing to do for this plugin + return + + ## # # Private helper function for a printable Timestamp @@ -47,6 +44,7 @@ def onLoad(): def curtime(): return time.strftime("%Y-%m-%d %H:%M:%S") + ## # # do send mail diff --git a/plugins/firEmergency/firEmergency.py b/plugins/firEmergency/firEmergency.py index 5ea918b..4d40f87 100644 --- a/plugins/firEmergency/firEmergency.py +++ b/plugins/firEmergency/firEmergency.py @@ -14,26 +14,23 @@ import socket from includes import globals # Global variables -## +### # -# onLoad function of plugin -# will be called by the pluginLoader +# onLoad (init) function of plugin +# will be called one time by the pluginLoader on start # def onLoad(): """ While loading the plugins by pluginLoader.loadPlugins() - this onLoad() routine are called + this onLoad() routine is called one time for initialize the plugin @requires: nothing @return: nothing """ - try: - # we have to do nothing here... - pass - except: - logging.error("unknown error") - logging.debug("unknown error", exc_info=True) + # nothing to do for this plugin + return + ## # diff --git a/plugins/httpRequest/httpRequest.py b/plugins/httpRequest/httpRequest.py index 0f8a22e..74d6df3 100644 --- a/plugins/httpRequest/httpRequest.py +++ b/plugins/httpRequest/httpRequest.py @@ -17,24 +17,21 @@ from includes import globals # Global variables ## # -# onLoad function of plugin -# will be called by the pluginLoader +# onLoad (init) function of plugin +# will be called one time by the pluginLoader on start # def onLoad(): """ While loading the plugins by pluginLoader.loadPlugins() - this onLoad() routine are called + this onLoad() routine is called one time for initialize the plugin @requires: nothing @return: nothing """ - try: - # we have to do nothing here... - pass - except: - logging.error("unknown error") - logging.debug("unknown error", exc_info=True) + # nothing to do for this plugin + return + ## # diff --git a/plugins/interface.txt b/plugins/interface.txt index f2e8c01..d8b7718 100644 --- a/plugins/interface.txt +++ b/plugins/interface.txt @@ -1,9 +1,9 @@ Handover to Plugin: +------------------- typ = [FMS|ZVEI|POC] freq = [Freq in Hz] data = {"KEY1":"VALUE1","KEY2":"VALUE2"} - The following informations are included in the var "data". They can be used by their Index Names: data['OPTION'] @@ -29,6 +29,7 @@ POCSAG: Global Objects: +--------------- 1.) import logging # Global logger @@ -38,4 +39,40 @@ Loglevel: debug|info|warning|error|exception|critical 2.) import globals # Global variables reads Data from the config.ini -VALUE = globals.config.get("SECTION", "OPTION") \ No newline at end of file +VALUE = globals.config.get("SECTION", "OPTION") + + +General for plugins: +-------------------- +All Plugins have to implement the following functions (see template.py): + +def onLoad(): + """ + While loading the plugins by pluginLoader.loadPlugins() + this onLoad() routine is called one time for initialize the plugin + + @requires: nothing + + @return: nothing + @exception: Exception if init has an fatal error so that the plugin couldn't work + + """ + +def run(typ,freq,data): + """ + This function is the implementation of the Plugin. + + If necessary the configuration hast to be set in the config.ini. + + @type typ: string (FMS|ZVEI|POC) + @param typ: Typ of the dataset + @type data: map of data (structure see interface.txt) + @param data: Contains the parameter for dispatch + @type freq: string + @keyword freq: frequency of the SDR Stick + + @requires: If necessary the configuration hast to be set in the config.ini. + + @return: nothing + @exception: nothing, make sure this function will never thrown an exception + """ \ No newline at end of file diff --git a/plugins/jsonSocket/jsonSocket.py b/plugins/jsonSocket/jsonSocket.py index 4dec8a5..01afeb2 100644 --- a/plugins/jsonSocket/jsonSocket.py +++ b/plugins/jsonSocket/jsonSocket.py @@ -18,24 +18,21 @@ from includes import globals # Global variables ## # -# onLoad function of plugin -# will be called by the pluginLoader +# onLoad (init) function of plugin +# will be called one time by the pluginLoader on start # def onLoad(): """ While loading the plugins by pluginLoader.loadPlugins() - this onLoad() routine are called + this onLoad() routine is called one time for initialize the plugin @requires: nothing @return: nothing """ - try: - # we have to do nothing here... - pass - except: - logging.error("unknown error") - logging.debug("unknown error", exc_info=True) + # nothing to do for this plugin + return + ## # diff --git a/plugins/template/template.py b/plugins/template/template.py index 9d306c0..b20c3eb 100644 --- a/plugins/template/template.py +++ b/plugins/template/template.py @@ -26,17 +26,19 @@ from includes import globals # Global variables ## # -# onLoad function of plugin -# will be called by the pluginLoader +# onLoad (init) function of plugin +# will be called one time by the pluginLoader on start # def onLoad(): """ While loading the plugins by pluginLoader.loadPlugins() - this onLoad() routine are called + this onLoad() routine is called one time for initialize the plugin @requires: nothing @return: nothing + @exception: Exception if init has an fatal error so that the plugin couldn't work + """ try: ########## User onLoad CODE ########## @@ -45,6 +47,7 @@ def onLoad(): except: logging.error("unknown error") logging.debug("unknown error", exc_info=True) + raise ## # @@ -67,6 +70,7 @@ def run(typ,freq,data): @requires: If necessary the configuration hast to be set in the config.ini. @return: nothing + @exception: nothing, make sure this function will never thrown an exception """ try: #