提交 153bbf0d 编写于 作者: R Rudá Moura 提交者: Ruda Moura

avocado.plugins: Check and log when loading plugins behaves bad.

Signed-off-by: NRuda Moura <rmoura@redhat.com>
上级 b959e41a
......@@ -14,8 +14,11 @@
"""Builtin plugins."""
import logging
from importlib import import_module
log = logging.getLogger("avocado.plugins")
__all__ = ['load_builtins']
Builtins = [('avocado.plugins.runner', 'TestLister'),
......@@ -33,7 +36,11 @@ def load_builtins(set_globals=True):
for module, klass in Builtins:
try:
plugin_mod = import_module(module)
except ImportError:
except ImportError as err:
log.error("Could not import pluging '': %s", klass, err)
continue
except SyntaxError as err:
log.error("Plugin '%s' with syntax error: %s", klass, err)
continue
if hasattr(plugin_mod, klass):
plugin = getattr(plugin_mod, klass)
......
......@@ -53,7 +53,11 @@ class PluginManager(object):
def activate(self, app_args):
for plugin in self.plugins:
if plugin.configured:
plugin.activate(app_args)
try:
plugin.activate(app_args)
except Exception as err:
log.error("Could not activate plugin '%s': %s",
plugin.name, err)
class BuiltinPluginManager(PluginManager):
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册