提交 fa0eeb90 编写于 作者: A Amador Pahim 提交者: GitHub

Merge pull request #1491 from clebergnu/handle_result_plugin_failures

Handle result plugin failures / HTML result fix with older pystache
......@@ -75,7 +75,7 @@ class JobPrePostDispatcher(Dispatcher):
def __init__(self):
super(JobPrePostDispatcher, self).__init__('avocado.plugins.job.prepost')
def map_methods(self, method_name, job):
def map_method(self, method_name, job):
for ext in self.extensions:
try:
if hasattr(ext.obj, method_name):
......@@ -94,3 +94,17 @@ class ResultDispatcher(Dispatcher):
def __init__(self):
super(ResultDispatcher, self).__init__('avocado.plugins.result')
def map_method(self, method_name, result, job):
for ext in self.extensions:
try:
if hasattr(ext.obj, method_name):
method = getattr(ext.obj, method_name)
method(result, job)
except SystemExit:
raise
except KeyboardInterrupt:
raise
except:
job.log.error('Error running method "%s" of plugin "%s": %s',
method_name, ext.name, sys.exc_info()[1])
......@@ -433,7 +433,7 @@ class Job(object):
self._remove_job_results()
raise exceptions.OptionValidationError(details)
self.job_pre_post_dispatcher.map_methods('pre', self)
self.job_pre_post_dispatcher.map_method('pre', self)
if not self.test_suite:
self._remove_job_results()
......@@ -527,7 +527,7 @@ class Job(object):
self.exitcode |= exit_codes.AVOCADO_FAIL
return self.exitcode
finally:
self.job_pre_post_dispatcher.map_methods('post', self)
self.job_pre_post_dispatcher.map_method('post', self)
if not settings.get_value('runner.behavior', 'keep_tmp_files',
key_type=bool, default=False):
data_dir.clean_tmp_files()
......
......@@ -248,8 +248,7 @@ class HTMLResult(Result):
else:
from pystache import view
v = view.View(template, context)
report_contents = v.render('utf8') # encodes into ascii
report_contents = codecs.decode("utf8") # decode to unicode
report_contents = v.render('utf8')
except UnicodeDecodeError as details:
# FIXME: Remove me when UnicodeDecodeError problem is fixed
import logging
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册