mirror of
https://github.com/Schrolli91/BOSWatch.git
synced 2025-12-06 07:42:03 +01:00
error handling pluginloader.py
This commit is contained in:
parent
247be7f333
commit
ed9a7619b4
|
|
@ -8,27 +8,35 @@ import os
|
|||
|
||||
|
||||
def getPlugins():
|
||||
PluginFolder = globals.script_path+"/plugins"
|
||||
plugins = []
|
||||
for i in os.listdir(PluginFolder):
|
||||
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
|
||||
try:
|
||||
logging.debug("Search in Plugin Folder")
|
||||
PluginFolder = globals.script_path+"/plugins"
|
||||
plugins = []
|
||||
for i in os.listdir(PluginFolder):
|
||||
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
|
||||
|
||||
# is the plugin enabled in the config-file?
|
||||
try:
|
||||
if globals.config.getint("Plugins", i):
|
||||
info = imp.find_module(i, [location])
|
||||
plugins.append({"name": i, "info": info})
|
||||
logging.debug("Plugin [ENABLED ] %s", i)
|
||||
else:
|
||||
# is the plugin enabled in the config-file?
|
||||
try:
|
||||
logging.debug("Plugin [DISABLED] %s ", i)
|
||||
except: #no entry for plugin found in config-file, skip
|
||||
logging.warning("Plugin [NO CONF ] %s", i)
|
||||
|
||||
if globals.config.getint("Plugins", i):
|
||||
info = imp.find_module(i, [location])
|
||||
plugins.append({"name": i, "info": info})
|
||||
logging.debug("Plugin [ENABLED ] %s", i)
|
||||
else:
|
||||
logging.debug("Plugin [DISABLED] %s ", i)
|
||||
except: #no entry for plugin found in config-file, skip
|
||||
logging.warning("Plugin [NO CONF ] %s", i)
|
||||
except:
|
||||
logging.exception("Error during Plugin search")
|
||||
|
||||
return plugins
|
||||
|
||||
def loadPlugin(plugin):
|
||||
logging.debug("load Plugin: %s", plugin["name"])
|
||||
return imp.load_module(plugin["name"], *plugin["info"])
|
||||
try:
|
||||
logging.debug("load Plugin: %s", plugin["name"])
|
||||
return imp.load_module(plugin["name"], *plugin["info"])
|
||||
except:
|
||||
logging.exception("cannot load Plugin: %s", plugin["name"])
|
||||
Loading…
Reference in a new issue