author | timothy.murphy@nokia.com |
Fri, 12 Feb 2010 14:57:02 +0200 | |
branch | fix |
changeset 204 | a19456c07783 |
parent 29 | ee00c00df073 |
permissions | -rw-r--r-- |
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 |
# Filter class for filtering XML logs and generate reports |
|
16 |
# Will ultimately do everything that scanlog does |
|
17 |
# |
|
18 |
||
29
ee00c00df073
Catchup to Perforce WIP with timing, python24
timothy.murphy@nokia.com
parents:
3
diff
changeset
|
19 |
import errno |
3 | 20 |
import os |
21 |
import sys |
|
22 |
import raptor |
|
23 |
import filter_interface |
|
24 |
||
25 |
class FilterLogfile(filter_interface.Filter): |
|
26 |
||
27 |
def open(self, raptor_instance): |
|
28 |
"""Open a log file for the various I/O methods to write to.""" |
|
29 |
||
30 |
self.raptor = raptor_instance |
|
31 |
self.logFileName = self.raptor.logFileName |
|
32 |
# insert the time into the log file name |
|
33 |
if self.logFileName: |
|
34 |
self.logFileName.path = self.logFileName.path.replace("%TIME", |
|
35 |
self.raptor.timestring) |
|
36 |
||
37 |
try: |
|
38 |
dirname = str(self.raptor.logFileName.Dir()) |
|
39 |
if dirname and not os.path.isdir(dirname): |
|
40 |
os.makedirs(dirname) |
|
41 |
except os.error, e: |
|
29
ee00c00df073
Catchup to Perforce WIP with timing, python24
timothy.murphy@nokia.com
parents:
3
diff
changeset
|
42 |
if e.errno != errno.EEXIST: |
3 | 43 |
sys.stderr.write("%s : error: cannot create directory %s\n" % \ |
44 |
(str(raptor.name), dirname)) |
|
45 |
return False |
|
46 |
try: |
|
47 |
self.out = open(str(self.logFileName), "w") |
|
48 |
except: |
|
49 |
self.out = None |
|
50 |
sys.stderr.write("%s : error: cannot write log %s\n" %\ |
|
51 |
(str(raptor.name), self.logFileName.GetShellPath())) |
|
52 |
return False |
|
53 |
else: |
|
54 |
self.out = sys.stdout |
|
55 |
||
56 |
return True |
|
57 |
||
58 |
def write(self, text): |
|
59 |
"""Write text into the log file""" |
|
60 |
||
61 |
self.out.write(text) |
|
62 |
return True |
|
63 |
||
64 |
def summary(self): |
|
65 |
"""Write Summary""" |
|
66 |
if self.logFileName and not self.raptor.quiet: |
|
67 |
sys.stdout.write("sbs: build log in %s\n" % str(self.logFileName)) |
|
68 |
return False |
|
69 |
||
70 |
def close(self): |
|
71 |
"""Close the log file""" |
|
72 |
||
73 |
try: |
|
74 |
self.out.close() |
|
75 |
return True |
|
76 |
except: |
|
77 |
self.out = None |
|
78 |
return False |