From e9e3bc022f50b246dfe290e77b596835c5dbcd9d Mon Sep 17 00:00:00 2001 From: Martin Klozik Date: Thu, 21 Jan 2016 09:33:30 +0000 Subject: report: add rst template for results reporting Add a template that can be used for reporting vsperf release B results. This patch also fixes the line length issues in the markdown template. Change-Id: Id03f5c7eb84536697deca73d3fb397629b647a85 JIRA: VSPERF-181 Signed-off-by: Maryam Tahhan Signed-off-by: Martin Klozik (cherry picked from commit e4718a97deafdb853335b13d472de0e273e191af) --- tools/report/report.py | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) (limited to 'tools/report/report.py') diff --git a/tools/report/report.py b/tools/report/report.py index 4264c055..1e0f87bc 100644 --- a/tools/report/report.py +++ b/tools/report/report.py @@ -27,7 +27,7 @@ from core.results.results_constants import ResultsConstants from conf import settings as S from tools import systeminfo -_TEMPLATE_FILE = 'report.jinja' +_TEMPLATE_FILES = ['report.jinja', 'report_rst.jinja'] _ROOT_DIR = os.path.normpath(os.path.dirname(os.path.realpath(__file__))) @@ -48,7 +48,7 @@ def _get_env(result): env = { 'os': systeminfo.get_os(), 'kernel': systeminfo.get_kernel(), - 'nic': systeminfo.get_nic(), + 'nics': systeminfo.get_nic(), 'cpu': systeminfo.get_cpu(), 'cpu_cores': systeminfo.get_cpu_cores(), 'memory' : systeminfo.get_memory(), @@ -78,11 +78,10 @@ def generate(input_file, tc_results, tc_stats): :returns: Path to generated report """ - output_file = '.'.join([os.path.splitext(input_file)[0], 'md']) - + output_files = [('.'.join([os.path.splitext(input_file)[0], 'md'])), + ('.'.join([os.path.splitext(input_file)[0], 'rst']))] template_loader = jinja2.FileSystemLoader(searchpath=_ROOT_DIR) template_env = jinja2.Environment(loader=template_loader) - template = template_env.get_template(_TEMPLATE_FILE) tests = [] try: @@ -112,17 +111,20 @@ def generate(input_file, tc_results, tc_stats): template_vars = { 'tests': tests, } - - output_text = template.render(template_vars) #pylint: disable=no-member - with open(output_file, 'w') as file_: - file_.write(output_text) - logging.info('Test report written to "%s"', output_file) + i = 0 + for output_file in output_files: + template = template_env.get_template(_TEMPLATE_FILES[i]) + output_text = template.render(template_vars) #pylint: disable=no-member + with open(output_file, 'w') as file_: + file_.write(output_text) + logging.info('Test report written to "%s"', output_file) + i += 1 except KeyError: logging.info("Report: Ignoring file (Wrongly defined columns): %s", (input_file)) raise - return output_file + return output_files if __name__ == '__main__': -- cgit 1.2.3-korg