diff options
author | Andrew McDermott <andrew.mcdermott@linaro.org> | 2014-07-01 01:03:47 +0100 |
---|---|---|
committer | Andrew McDermott <andrew.mcdermott@linaro.org> | 2014-07-01 01:03:47 +0100 |
commit | c5531eb3c31cd48b3cb47220952d35b9ff54b205 (patch) | |
tree | 380788d7686a7e9eca89474ae719ec23349839c3 /jcstress-generate-html-report.py |
Initial import
Signed-off-by: Andrew McDermott <andrew.mcdermott@linaro.org>
Diffstat (limited to 'jcstress-generate-html-report.py')
-rwxr-xr-x | jcstress-generate-html-report.py | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/jcstress-generate-html-report.py b/jcstress-generate-html-report.py new file mode 100755 index 0000000..73c59ec --- /dev/null +++ b/jcstress-generate-html-report.py @@ -0,0 +1,70 @@ +#!/usr/bin/env python + +# Copyright (C) 2014, Linaro Limited. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +# Author: Andrew McDermott <andrew.mcdermott@linaro.org> + +from htmltags import * +import argparse +import os +import platform +import csv +import sys +import time +from datetime import datetime + +def remove_starting_path(full_path, start): + return os.path.relpath(full_path, start) + +def cell_style(status): + if 'success' in status: + return status.upper() + elif 'failed' in status: + return status.upper() + else: + return None + +parser = argparse.ArgumentParser() +parser.add_argument('--results', help='results filename', type=str, required=True) +parser.add_argument('--top-dir', help="top directory", type=str, required=True) +args = parser.parse_args() + +head = HEAD(TITLE("jcstress Result Archive ({})".format(platform.machine()))) +head <= LINK(rel="stylesheet", href="style.css") +body = BODY() +table = TABLE(border=1) +table <= TR(TH('Date') + TH('Results') + TH('Status')) + +with open(args.results, 'rb') as csvfile: + rdr = csv.reader(csvfile, delimiter=',', quotechar='|') + for row in rdr: + human_readable_date = time.strftime("%Y-%m-%d", time.localtime(int(row[0]))).lower() + human_readable_index = os.path.join(remove_starting_path(row[1], args.top_dir), 'results') + index_html = os.path.join(os.path.sep, remove_starting_path(row[1], args.top_dir), 'results', 'index.html') + html_row = TR() + html_row <= TD(human_readable_date) + html_row <= TD(A(human_readable_index, href=index_html)) + html_row <= TD(row[2], Class=cell_style(row[2])) + table <= html_row + +body <= H2("Historic Results") +body <= table +body <= HR() +body <= P("Page generated on: {}".format(time.strftime("%Y-%m-%d %H:%M:%S %Z"))) +head <= body + +print HTML(head) |