def load_module(module_path):
"""(re) load an external module
Args:
module_path: string, the path to the module relative to the main script
Returns:
boolean, True if no Exception was raised on (re)load, otherwise False
"""
message = "search for plugin in sys.modules"
try:
if module_path in sys.modules:
message = "reload"
importlib.reload(sys.modules[module_path])
else:
message = "import"
importlib.import_module(module_path)
return True
except: # capture all Exceptions # pylint: disable=bare-except
logger.exception("load_module %s: %s", module_path, message)
return False
评论列表
文章目录