提交 fb5ab545 编写于 作者: C Cleber Rosa

HTML output support: behave when the plugin is not installed

We currently only set HTML support as disabled if the `html.py`
library fails to import. The truth is that missing files that
are intended to be present on the (separately packaged) HTML
plugin package can cause other kinds of exceptions.

Let's add an extra check, looking if the resource files are
present (currently the template file).

Note: there's one outstanding bug, for which a fix is being
worked on. When Avocado is installed, either from packages
or from source code, the HTML plugin entry point is always
registered. That means the plugin Python module is always
tried to be loaded. If the plugin *package* is not installed,
an error message is given on the command line.
Signed-off-by: NCleber Rosa <crosa@redhat.com>
上级 b67a2753
......@@ -30,6 +30,18 @@ from ..utils import path as utils_path
from ..utils import runtime
def check_resource_requirements():
"""
Checks if necessary resource files to render the report are in place
Currently, only the template file is looked for
"""
base_path = os.path.dirname(sys.modules[__name__].__file__)
html_resources_path = os.path.join(base_path, 'resources', 'htmlresult')
template = os.path.join(html_resources_path, 'templates', 'report.mustache')
return os.path.exists(template)
class ReportModel(object):
"""
......
......@@ -53,7 +53,7 @@ from ..utils import data_structures
try:
from . import html
HTML_REPORT_SUPPORT = True
HTML_REPORT_SUPPORT = html.check_resource_requirements()
except ImportError:
HTML_REPORT_SUPPORT = False
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册