3
|
1 |
#
|
|
2 |
# Copyright (c) 2008-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 the License "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 |
# squash a raptor log file by removing commands from successful recipes
|
|
16 |
#
|
|
17 |
|
|
18 |
import sys
|
|
19 |
|
|
20 |
inRecipe = False
|
|
21 |
|
|
22 |
for line in sys.stdin.readlines():
|
|
23 |
# escape % characters otherwise print will fail
|
|
24 |
line = line.replace("%", "%%")
|
|
25 |
|
|
26 |
# detect the start of a recipe
|
|
27 |
if line.startswith("<recipe "):
|
|
28 |
inRecipe = True
|
|
29 |
recipeLines = [line]
|
|
30 |
squashRecipe = True
|
|
31 |
continue
|
|
32 |
|
|
33 |
# detect the status report from a recipe
|
|
34 |
if line.startswith("<status "):
|
|
35 |
if not "exit='ok'" in line:
|
|
36 |
# only squash ok recipes
|
|
37 |
squashRecipe = False
|
|
38 |
recipeLines.append(line)
|
|
39 |
continue
|
|
40 |
|
|
41 |
# detect the end of a recipe
|
|
42 |
if line.startswith("</recipe>"):
|
|
43 |
# print the recipe
|
|
44 |
if squashRecipe:
|
|
45 |
for text in recipeLines:
|
|
46 |
if not text.startswith("+"):
|
|
47 |
print text,
|
|
48 |
else:
|
|
49 |
for text in recipeLines:
|
|
50 |
print text,
|
|
51 |
print line,
|
|
52 |
continue
|
|
53 |
|
|
54 |
# remember the lines during a recipe
|
|
55 |
if inRecipe:
|
|
56 |
recipeLines.append(line)
|
|
57 |
else:
|
|
58 |
# print all lines outside a recipe
|
|
59 |
print line,
|
|
60 |
|
|
61 |
# end
|
|
62 |
|