From 61623adf102be03fb7c795193b5076657200c9ba Mon Sep 17 00:00:00 2001 From: Lucas Meneghel Rodrigues Date: Mon, 8 Jun 2015 20:15:29 -0300 Subject: [PATCH] avocado: Add a mechanism to skip notifying broken plugins on stderr Implement a feature to skip notifying broken plugins on stderr. Let's say a user has a broken plugin that can't be fixed right now, and he/she doesn't want to be bothered by having it notified in stderr all the time avocado is executed, add a configuration option that allows you to selectively ignore plugins to display errors in stderr. The reason why the feature is configurable is that we want users to be notified when a new plugin is present and for some reason is also broken, this finer grained control is more useful to users IMHO. Signed-off-by: Lucas Meneghel Rodrigues --- avocado/core/plugins/builtin.py | 7 ++++++- etc/avocado/avocado.conf | 8 ++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/avocado/core/plugins/builtin.py b/avocado/core/plugins/builtin.py index 182681a7..711974de 100644 --- a/avocado/core/plugins/builtin.py +++ b/avocado/core/plugins/builtin.py @@ -19,6 +19,7 @@ import logging from importlib import import_module from avocado.core.plugins.plugin import Plugin +from avocado.core.settings import settings log = logging.getLogger("avocado.app") @@ -46,13 +47,17 @@ def load_builtins(): :return: a list of plugin classes, ordered by `priority`. """ plugins = [] + skip_notify = settings.get_value(section='plugins', + key='skip_broken_plugin_notification', + key_type=list) for module in Builtins: try: plugin_mod = import_module(module) except Exception as err: name = str(module) reason = '%s %s' % (str(err.__class__.__name__), err) - log.error('Error loading %s -> %s', name, reason) + if name not in skip_notify: + log.error('Error loading %s -> %s', name, reason) ErrorsLoading.append((name, reason)) continue for name in plugin_mod.__dict__: diff --git a/etc/avocado/avocado.conf b/etc/avocado/avocado.conf index 54176225..e96bf491 100644 --- a/etc/avocado/avocado.conf +++ b/etc/avocado/avocado.conf @@ -46,3 +46,11 @@ port = 9405 username = # If authentication is set, pass password password = + +[plugins] +# Suppress notification about broken plugins in the app standard error. +# Add the name of each broken plugin you want to suppress the notification +# in the list. The names can be easily seen from the stderr messages. Example: +# avocado.core.plugins.htmlresult ImportError No module named pystache +# add 'avocado.core.plugins.htmlresult' as an element of the list below. +skip_broken_plugin_notification = [] -- GitLab