提交 6a1311af 编写于 作者: R Rudá Moura 提交者: Ruda Moura

avocado.plugins.manager: Log when module has no plugin inside.

Log a message when loading external plugins discovers that
there is no plugin inside a module.

Plus: cosmetic formatting.
Signed-off-by: NRuda Moura <rmoura@redhat.com>
上级 72a883e2
......@@ -91,18 +91,26 @@ class ExternalPluginManager(PluginManager):
import imp
if path:
candidates = glob(os.path.join(path, pattern))
candidates = [(os.path.splitext(os.path.basename(x))[0], path) for x in candidates]
candidates = [(x[0], imp.find_module(x[0], [path])) for x in candidates]
candidates = [(os.path.splitext(os.path.basename(x))[0], path)
for x in candidates]
candidates = [(x[0], imp.find_module(x[0], [path]))
for x in candidates]
for candidate in candidates:
try:
mod = imp.load_module(candidate[0], *candidate[1])
except Exception as err:
log.error("Could not load plugin '%s': %s", candidate[0], err)
log.error("Could not load module plugin '%s': %s",
candidate[0], err)
else:
any_plugin = False
for name in mod.__dict__:
x = getattr(mod, name)
if isinstance(x, type) and issubclass(x, Plugin):
self.add_plugin(x())
any_plugin = True
if not any_plugin:
log.error("Could not find any plugin in module '%s'",
candidate[0])
def add_plugins(self, plugins):
for plugin in plugins:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册