diff -r f5050f1da672 -r 04becd199f91 build/buildutils/errortail.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/build/buildutils/errortail.py Tue Apr 27 16:30:29 2010 +0300 @@ -0,0 +1,42 @@ +# +# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +# All rights reserved. +# This component and the accompanying materials are made available +# under the terms of "Eclipse Public License v1.0" +# which accompanies this distribution, and is available +# at the URL "http://www.eclipse.org/legal/epl-v10.html". +# +# Initial Contributors: +# Nokia Corporation - initial contribution. +# +# Contributors: +# +# Description: +# + +import sys, re, os, os.path, fnmatch + +# This utility reads a compilation log file, and writes last 50 lines up to error +# to an output tail file. If no errors, then file is not written + +RE_ERROR = re.compile(r"fatal error|Build FAILED|make(\.exe)?(\[[^]]+\])?: \*\*\* .+ (Error [0-9]+|Stop\.)|.+[0-9]+: error:|status exit='failed'|.*|
[1-9]*
High
") + +def errortail(logfile, tailfile, tailLines = 50): + tail = [] + for line in open(logfile).readlines(): + tail.append(line.rstrip()) + if (len(tail) > tailLines): + del tail[0] + if RE_ERROR.search(line): + tail = tail[-50:] + open(tailfile, "w").write("\n".join(tail)) + return + +def main(): + if len(sys.argv) != 3: + print "Usage: %s " % sys.argv[0] + sys.exit(1) + errortail(sys.argv[1], sys.argv[2]) + +if __name__ == "__main__": + main()