#!/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 from htmltags import * import argparse import csv import os import platform import time from datetime import datetime from common import * def remove_starting_path(full_path, start): return os.path.relpath(full_path, start) 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) parser.add_argument('sub_dir', help="html subdirectory", type=str) args = parser.parse_args() head = HEAD(TITLE("jcstress Result Archive ({})".format(platform.machine()))) head <= LINK(rel="stylesheet", href="style.css") body = BODY() body <= P("""This page captures the historic results of running the {} tests on {}.""".format(A("jcstress", href="http://openjdk.java.net/projects/code-tools/jcstress/"), platform.machine())) table = TABLE(border=1) table <= TR(TH('Date') + TH('Pass Rate')) with open(args.results, 'rb') as csvfile: rdr = csv.reader(csvfile, delimiter=',', quotechar='|') for row in rdr: if os.path.exists(os.path.join(row[1], 'results', 'index.html')): html_row = TR() pass_fail = pass_fail_rate("{}/results/index.html".format(row[1])) human_readable_date = time.strftime("%Y-%m-%d", time.localtime(int(row[0]))).lower() html_row <= TD(human_readable_date) index_html = os.path.join(remove_starting_path(row[1], args.top_dir), 'results', 'index.html') index_html = remove_starting_path(index_html, "jcstress-nightly-runs") html_row <= TD(A("{}/{}".format(pass_fail[0], pass_fail[1]), href=index_html), align='right') table <= html_row body <= H2("Historic Results") body <= table body <= HR() body <= P("Page generated on: {}".format(time.strftime("%a, %d %b %Y %T %z"))) head <= body print HTML(head)