author | raptorbot <raptorbot@systemstesthead.symbian.intra> |
Mon, 18 Jan 2010 17:03:32 +0000 | |
branch | wip |
changeset 132 | 2022a4abb126 |
parent 29 | ee00c00df073 |
permissions | -rw-r--r-- |
3 | 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 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 |
# Format Raptor verbose log output for the Carbide IDE |
|
16 |
# |
|
17 |
||
18 |
||
19 |
import os |
|
20 |
import re |
|
21 |
import sys |
|
22 |
import raptor |
|
23 |
import filter_interface |
|
24 |
import filter_utils |
|
25 |
||
26 |
||
27 |
class FilterCarbide(filter_interface.Filter): |
|
28 |
"""Carbide IDE filter |
|
29 |
Strips most verbose output leaving tools calls, tool output and formatted errors/warnings.""" |
|
30 |
||
31 |
# ignore all general, benign, make output |
|
32 |
ignore = re.compile('(make(\.exe)?: Nothing to be done for \`.+\'|make(\.exe)?: \[.+\] Error \d+ \(ignored\)|.*make(.exe)?\[\d\]: (Entering|Leaving) directory \`.+\')') |
|
33 |
||
34 |
stdout = filter_utils.AutoFlushedStream(sys.stdout) |
|
35 |
stderr = filter_utils.AutoFlushedStream(sys.stderr) |
|
36 |
||
37 |
recipeFactory = filter_utils.RecipeFactory() |
|
38 |
||
39 |
def __init__(self): |
|
40 |
self.__errors = 0 |
|
41 |
self.__warnings = 0 |
|
42 |
self.__recipe = None |
|
43 |
||
44 |
def open(self, aRaptorInstance): |
|
45 |
return True |
|
46 |
||
47 |
def write(self, aLine): |
|
48 |
"""Process output on the fly and format appropriately for the Carbide IDE. |
|
49 |
Most verbose output is discarded leaving tools calls, tool output and formatted errors |
|
50 |
and warnings. |
|
51 |
Identified errors go to stderr so that they will be highlighted in the IDE console.""" |
|
52 |
||
53 |
if FilterCarbide.ignore.match(aLine): |
|
54 |
return |
|
55 |
||
56 |
logHeader = filter_utils.logHeader.match(aLine) |
|
57 |
if logHeader: |
|
58 |
FilterCarbide.stdout.write("sbs version: " + logHeader.group("version")+"\n\n") |
|
59 |
return |
|
60 |
||
61 |
clean = filter_utils.clean.match(aLine) |
|
62 |
if clean: |
|
63 |
for file in clean.group("removals").split(): |
|
64 |
FilterCarbide.stdout.write("clean: " + file + "\n") |
|
65 |
return |
|
66 |
||
67 |
exports = filter_utils.exports.match(aLine) |
|
68 |
if exports: |
|
69 |
FilterCarbide.stdout.write("export: " + exports.group("source") + " to " + exports.group("destination") + "\n") |
|
70 |
return |
|
71 |
||
72 |
||
73 |
if self.__recipe: |
|
74 |
self.__recipe.addLine(aLine) |
|
75 |
||
76 |
if self.__recipe.isComplete(): |
|
77 |
for call in self.__recipe.getCalls(): |
|
78 |
FilterCarbide.stdout.write(call + "\n") |
|
79 |
else: |
|
80 |
logTag = filter_utils.logTag.match(aLine) |
|
81 |
if logTag: |
|
82 |
tagName = logTag.group("name") |
|
83 |
if tagName == "recipe": |
|
84 |
if self.__recipe: |
|
85 |
self.__recipe.addLine(aLine) |
|
86 |
else: |
|
87 |
self.__recipe = FilterCarbide.recipeFactory.newRecipe(aLine) |
|
88 |
elif tagName == "error": |
|
89 |
self.__errors += 1 |
|
90 |
FilterCarbide.stderr.write("Error: " + filter_utils.logTag.sub("", aLine) + "\n") |
|
91 |
elif tagName == "warning": |
|
92 |
self.__warnings += 1 |
|
93 |
FilterCarbide.stdout.write("Warning: " + filter_utils.logTag.sub("", aLine) + "\n") |
|
94 |
# we're not interested in any other tagged output |
|
95 |
return |
|
96 |
else: |
|
97 |
# Not a recipe, and not tagged output that we know about. |
|
98 |
# Output this anyway, just in case it's something important |
|
99 |
FilterCarbide.stdout.write(aLine) |
|
100 |
||
101 |
||
102 |
if self.__recipe and self.__recipe.isComplete(): |
|
103 |
errors = 0 |
|
104 |
warnings = 0 |
|
105 |
||
106 |
recipeOutput = self.__recipe.getOutput() |
|
107 |
recipeWarnings = self.__recipe.getWarnings() |
|
108 |
recipeErrors = self.__recipe.getErrors() |
|
109 |
||
110 |
if len(recipeOutput): |
|
111 |
FilterCarbide.stdout.writelines(recipeOutput) |
|
112 |
if len(recipeWarnings): |
|
113 |
FilterCarbide.stdout.writelines(recipeWarnings) |
|
114 |
warnings += len(recipeWarnings) |
|
115 |
if len(recipeErrors): |
|
116 |
FilterCarbide.stderr.writelines(recipeErrors) |
|
117 |
errors += len(recipeErrors) |
|
118 |
||
119 |
# Per-recipe summary |
|
120 |
self.__errors += errors |
|
121 |
self.__warnings += warnings |
|
122 |
FilterCarbide.stdout.write("Errors: %d, (Total for build: %d)\n" % (errors, self.__errors)) |
|
123 |
FilterCarbide.stdout.write("Warnings: %d, (Total for build: %d)\n\n" % (warnings, self.__warnings)) |
|
124 |
self.__recipe = None |
|
125 |
||
126 |
return True |
|
127 |
||
128 |
def close(self): |
|
129 |
FilterCarbide.stdout.write("Overall Errors: %d\n" % self.__errors) |
|
130 |
FilterCarbide.stdout.write("Overall Warnings: %d\n\n" % self.__warnings) |
|
131 |
||
29
ee00c00df073
Catchup to Perforce WIP with timing, python24
timothy.murphy@nokia.com
parents:
3
diff
changeset
|
132 |
return (self.__errors == 0) |