|
1 # |
|
2 # Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 # All rights reserved. |
|
4 # This component and the accompanying materials are made available |
|
5 # under the terms of "Eclipse Public License v1.0" |
|
6 # which accompanies this distribution, and is available |
|
7 # at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 # |
|
9 # Initial Contributors: |
|
10 # Nokia Corporation - initial contribution. |
|
11 # |
|
12 # Contributors: |
|
13 # |
|
14 # Description: |
|
15 # |
|
16 |
|
17 import sys, re, os, os.path, fnmatch |
|
18 |
|
19 # This utility reads a compilation log file, and writes last 50 lines up to error |
|
20 # to an output tail file. If no errors, then file is not written |
|
21 |
|
22 RE_ERROR = re.compile(r"fatal error|Build FAILED|make(\.exe)?(\[[^]]+\])?: \*\*\* .+ (Error [0-9]+|Stop\.)|.+[0-9]+: error:|status exit='failed'|<error>.*</error>|<center>[1-9]*</center></td><td><center>High</center>") |
|
23 |
|
24 def errortail(logfile, tailfile, tailLines = 50): |
|
25 tail = [] |
|
26 for line in open(logfile).readlines(): |
|
27 tail.append(line.rstrip()) |
|
28 if (len(tail) > tailLines): |
|
29 del tail[0] |
|
30 if RE_ERROR.search(line): |
|
31 tail = tail[-50:] |
|
32 open(tailfile, "w").write("\n".join(tail)) |
|
33 return |
|
34 |
|
35 def main(): |
|
36 if len(sys.argv) != 3: |
|
37 print "Usage: %s <build log file> <tail output file>" % sys.argv[0] |
|
38 sys.exit(1) |
|
39 errortail(sys.argv[1], sys.argv[2]) |
|
40 |
|
41 if __name__ == "__main__": |
|
42 main() |