| #!/usr/bin/env python |
| |
| from htmltags import * |
| |
| import glob |
| import os |
| import sys |
| import platform |
| import time |
| import datetime |
| |
| days = os.getenv("DAYS", "10") |
| build_dir = None |
| report_dir = None |
| source_dir = None |
| jdk_version = os.getenv("JDK_VERSION", "8u") |
| |
| class cd(object): |
| """Context manager for changing the current working directory""" |
| |
| def __init__(self, newPath): |
| self.newPath = newPath |
| |
| def __enter__(self): |
| self.savedPath = os.getcwd() |
| os.chdir(self.newPath) |
| |
| def __exit__(self, etype, value, traceback): |
| os.chdir(self.savedPath) |
| |
| def list_j2sdk_images(top_dir): |
| alist = UL() |
| # wildcards are build-configuration, YEAR and DAY_OF_YEAR |
| for filename in sorted(glob.iglob(os.path.join(top_dir, 'builds', '*', '*', '*', 'jdk%s-*.tar.gz' % jdk_version))): |
| alist <= LI(A(os.path.basename(filename), href=filename), Class='image_filename') |
| return alist |
| |
| def main(top_dir): |
| global report_dir |
| report_dir = os.path.join(top_dir, "reports") |
| build_dir = os.path.join(top_dir, "builds") |
| src_dir = os.path.join(top_dir, "src") |
| head = HEAD(TITLE('OpenJDK ' + jdk_version + ' JTREG Test Result Archive (' + platform.machine() + ')')) |
| head <= LINK(rel="stylesheet", href="style.css") |
| body = BODY() |
| body <= B("This page maintains an index of the available JTREG test results for OpenJDK {} on {}.".format(jdk_version, platform.machine())) |
| body <= H2("Test Results") |
| with cd(os.path.join(top_dir, 'summary')): |
| alist = UL() |
| for year in sorted(glob.glob('*'), reverse=True): |
| with cd(year): |
| for day_of_year in sorted(glob.glob('*'), reverse=True): |
| result_date = datetime.datetime.strptime("{}/{}".format(year, day_of_year), '%Y/%j') |
| human_readable_date = result_date.strftime("%a, %d %b %Y") |
| alist <= LI(A(human_readable_date, href=os.path.join('summary', year, day_of_year, 'summary.html')), Class='historic_results') |
| body <= alist |
| body <= H2('Images') |
| body <= list_j2sdk_images(top_dir) |
| body <= H2("Directory Index") |
| alist = UL() |
| alist <= LI(A("JTREG Work directories", href="builds")) |
| alist <= LI(A("JTREG Report directories", href="reports")) |
| alist <= LI(A("JTREG Test Directories", href="src")) |
| body <= alist |
| body <= P("Page generated on: {}".format(time.strftime("%a, %d %b %Y %T %z"))) |
| print HTML(head + body) |
| |
| if __name__ == '__main__': |
| main(sys.argv[1]) |