diff -r f70b728ea30c -r a1925fb7753a sbsv2/raptor/bin/sbs_index.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sbsv2/raptor/bin/sbs_index.py Thu Aug 12 09:00:16 2010 +0100 @@ -0,0 +1,144 @@ +#!/usr/bin/python + +# Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +# All rights reserved. +# This component and the accompanying materials are made available +# under the terms of the License "Symbian Foundation License v1.0" +# which accompanies this distribution, and is available +# at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +# +# Initial Contributors: +# Nokia Corporation - initial contribution. +# +# Contributors: +# +# Description: +# +# Tie together a set of HTML build summaries by creating a single index page +# which shows the total number of Errors, Warnings etc. across all the parts +# of the build and links to the individual summaries. + +import os +import sys + +# get the absolute path to this script +script = os.path.abspath(sys.argv[0]) +bindir = os.path.dirname(script) +# add the Raptor python and plugins directories to the PYTHONPATH +sys.path.append(os.path.join(bindir, "..", "python")) +sys.path.append(os.path.join(bindir, "..", "python", "plugins")) + +if len(sys.argv) < 3: + sys.stderr.write("""usage: %s input_dir1 [input_dir2...] output_index_file + +The input directories are scanned recursively for totals.txt files and all +those found are added to the generated index. +""" % os.path.basename(script)) + sys.exit(1) + +roots = [] +for a in sys.argv[1:-1]: + if os.path.isdir(a): + roots.append(a) + else: + sys.stderr.write("warning: %s is not a directory\n" % a) + +indexfile = sys.argv[-1] +indexdir = os.path.dirname(indexfile) + +def findtotals(dirs, files): + "recurse directories until we find a totals.txt file." + sub = [] + for d in dirs: + name = os.path.join(d, "totals.txt") + if os.path.isfile(name): + files.append(name) + else: + for s in os.listdir(d): + dir = os.path.join(d,s) + if os.path.isdir(dir): + sub.append(dir) + if sub: + findtotals(sub, files) + +totals = [] +findtotals(roots, totals) +totals.sort() + +# look for a style file we can link to +css = "style.css" +for t in totals: + c = os.path.join(os.path.dirname(t),"style.css") + if os.path.isfile(c): + css = os.path.relpath(c, indexdir) + break + +# write the header of the index +import filter_html +try: + index = open(indexfile, "w") + index.write(""" +
+build | """ % css) + + for i in filter_html.Records.TITLES: + index.write('%s | ' % i) + index.write("|
---|---|---|
%s | ' % (linkname, linktext)) + for (style, count) in columns: + index.write('%d | ' % (style, count)) + index.write("|
total | ') + for i, count in enumerate(grandtotal): + if count == 0: + index.write('0 | ') + else: + index.write('%d | ' % (filter_html.Records.SUBDIRS[i], count)) + index.write("