提交 c679f530 编写于 作者: R Rudá Moura

Merge pull request #589 from clebergnu/plugins-improve-list-view-v2

Plugins improve list view [v2]
......@@ -45,10 +45,10 @@ from avocado.settings import settings
try:
from avocado.core.plugins import htmlresult
HTML_REPORT_SUPPORT = True
except ImportError:
HTML_REPORT_SUPPORT = False
else:
HTML_REPORT_SUPPORT = htmlresult.HTML_REPORT_CAPABLE
_NEW_ISSUE_LINK = 'https://github.com/avocado-framework/avocado/issues/new'
......
......@@ -36,6 +36,8 @@ Exclude = ['avocado.core.plugins.__init__',
Builtins = [x for x in Modules if x not in Exclude]
ErrorsLoading = []
def load_builtins():
"""
......@@ -47,11 +49,10 @@ def load_builtins():
for module in Builtins:
try:
plugin_mod = import_module(module)
except ImportError as err:
log.error("Could not import module plugin '%s': %s", module, err)
continue
except Exception as err:
log.error("Module plugin '%s' with error: %s", module, err)
name = str(module)
reason = '%s %s' % (str(err.__class__.__name__), err)
ErrorsLoading.append((name, reason))
continue
for name in plugin_mod.__dict__:
obj = getattr(plugin_mod, name)
......
......@@ -20,13 +20,7 @@ import shutil
import sys
import time
import subprocess
try:
import pystache
except ImportError:
HTML_REPORT_CAPABLE = False
else:
HTML_REPORT_CAPABLE = True
import pystache
from avocado import runtime
from avocado.core import exit_codes
......@@ -282,9 +276,6 @@ class HTML(plugin.Plugin):
enabled = True
def configure(self, parser):
if HTML_REPORT_CAPABLE is False:
self.enabled = False
return
self.parser = parser
self.parser.runner.output.add_argument(
'--html', type=str,
......
......@@ -35,7 +35,6 @@ class PluginManager(object):
def __init__(self):
self.plugins = []
self.disabled_plugins = []
def add_plugin(self, plugin):
self.plugins.append(plugin)
......
......@@ -12,9 +12,10 @@
# Copyright: Red Hat Inc. 2013-2014
# Author: Ruda Moura <rmoura@redhat.com>
from avocado.core import output
from avocado.core.plugins import plugin
from avocado.core.plugins.builtin import ErrorsLoading
from avocado.core.plugins.manager import get_plugin_manager
from avocado.core import output
class PluginList(plugin.Plugin):
......@@ -40,18 +41,34 @@ class PluginList(plugin.Plugin):
view = output.View(app_args=args,
use_paginator=args.paginator == 'on')
pm = get_plugin_manager()
view.notify(event='message', msg='Plugins loaded:')
enabled = [p for p in pm.plugins if p.enabled]
disabled = [p for p in pm.plugins if not p.enabled]
blength = 0
for plug in pm.plugins:
clength = len(plug.name)
if clength > blength:
blength = clength
for load_error in ErrorsLoading:
clength = len(load_error[0])
if clength > blength:
blength = clength
format_str = " %-" + str(blength + 1) + "s %s"
if enabled:
view.notify(event='message', msg=output.term_support.healthy_str("Plugins enabled:"))
for plug in sorted(enabled):
view.notify(event='minor', msg=format_str % (plug.name, plug.description))
if disabled:
view.notify(event='message', msg=output.term_support.fail_header_str('Plugins disabled:'))
for plug in sorted(disabled):
view.notify(event='minor', msg=format_str % (plug.name, "Disabled during plugin configuration"))
if ErrorsLoading:
view.notify(event='message', msg=output.term_support.fail_header_str('Unloadable plugin modules:'))
for load_error in sorted(ErrorsLoading):
view.notify(event='minor', msg=format_str % (load_error[0], load_error[1]))
format_str = " %-" + str(blength) + "s %s %s"
for plug in sorted(pm.plugins):
if plug.enabled:
status = "(Enabled)"
else:
status = "(Disabled)"
view.notify(event='minor', msg=format_str % (plug.name, plug.description, status))
view.cleanup()
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册