author | Jon Chatten |
Fri, 12 Nov 2010 14:49:36 +0000 | |
changeset 674 | 37ee82a83d43 |
parent 616 | 24e4ef208cca |
permissions | -rw-r--r-- |
591 | 1 |
#!/usr/bin/python |
2 |
||
3 |
# Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). |
|
4 |
# All rights reserved. |
|
5 |
# This component and the accompanying materials are made available |
|
616
24e4ef208cca
sbs version 2.14.2
Richard Taylor <richard.i.taylor@nokia.com>
parents:
591
diff
changeset
|
6 |
# under the terms of the License "Symbian Foundation License v1.0" |
591 | 7 |
# which accompanies this distribution, and is available |
616
24e4ef208cca
sbs version 2.14.2
Richard Taylor <richard.i.taylor@nokia.com>
parents:
591
diff
changeset
|
8 |
# at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". |
591 | 9 |
# |
10 |
# Initial Contributors: |
|
11 |
# Nokia Corporation - initial contribution. |
|
12 |
# |
|
13 |
# Contributors: |
|
14 |
# |
|
15 |
# Description: |
|
16 |
# |
|
17 |
||
18 |
import os |
|
19 |
import sys |
|
20 |
import traceback |
|
21 |
||
22 |
# intercept the -h option |
|
23 |
if "-h" in sys.argv or "--help" in sys.argv: |
|
24 |
print "usage:", sys.argv[0], "[sbs options]" |
|
25 |
print " The log data is read from stdin." |
|
26 |
print " Type 'sbs -h' for a list of sbs options." |
|
27 |
sys.exit(0) |
|
28 |
||
29 |
# get the absolute path to this script |
|
30 |
script = os.path.abspath(sys.argv[0]) |
|
31 |
||
32 |
# add the Raptor python directory to the PYTHONPATH |
|
33 |
sys.path.append(os.path.join(os.path.dirname(script), "..", "python")) |
|
34 |
||
35 |
# now we should be able to find the raptor modules |
|
36 |
import raptor |
|
37 |
import pluginbox |
|
38 |
||
39 |
# make sure that HOSTPLATFORM is set |
|
40 |
if not "HOSTPLATFORM" in os.environ: |
|
41 |
sys.stderr.write("HOSTPLATFORM is not set ... try running gethost.sh\n") |
|
42 |
sys.exit(1) |
|
43 |
||
44 |
if not "HOSTPLATFORM_DIR" in os.environ: |
|
45 |
sys.stderr.write("HOSTPLATFORM_DIR is not set ... try running gethost.sh\n") |
|
46 |
sys.exit(1) |
|
47 |
||
48 |
# construct a Raptor object from our command-line (less the name of this script) |
|
616
24e4ef208cca
sbs version 2.14.2
Richard Taylor <richard.i.taylor@nokia.com>
parents:
591
diff
changeset
|
49 |
the_raptor = raptor.Raptor.CreateCommandlineAnalysis(sys.argv[1:]) |
591 | 50 |
|
51 |
# from Raptor.OpenLog() |
|
52 |
try: |
|
53 |
# Find all the raptor plugins and put them into a pluginbox. |
|
54 |
if not the_raptor.systemPlugins.isAbsolute(): |
|
55 |
the_raptor.systemPlugins = the_raptor.home.Append(the_raptor.systemPlugins) |
|
56 |
||
57 |
pbox = pluginbox.PluginBox(str(the_raptor.systemPlugins)) |
|
58 |
raptor_params = raptor.BuildStats(the_raptor) |
|
59 |
||
60 |
# Open the requested plugins using the pluginbox |
|
61 |
the_raptor.out.open(raptor_params, the_raptor.filterList, pbox) |
|
674 | 62 |
|
63 |
except ValueError, e: |
|
64 |
sys.stderr.write("error: problem while creating filters: {0}\n".format(str(e))) |
|
65 |
sys.exit(1) |
|
591 | 66 |
except Exception, e: |
674 | 67 |
# Unrecognised exception: print a traceback |
68 |
sys.stderr.write("error: problem while creating filters: {0}\n".format(str(e))) |
|
591 | 69 |
traceback.print_exc() |
70 |
sys.exit(1) |
|
71 |
||
72 |
# read stdin a line at a time and pass it to the Raptor object |
|
73 |
try: |
|
74 |
line = " " |
|
75 |
while line: |
|
76 |
line = sys.stdin.readline() |
|
77 |
the_raptor.out.write(line) |
|
78 |
except Exception,e: |
|
79 |
sys.stderr.write("error: problem while filtering: %s\n" % str(e)) |
|
80 |
traceback.print_exc() |
|
81 |
sys.exit(1) |
|
82 |
||
83 |
||
84 |
# Print the summary (this can't return errors) |
|
85 |
the_raptor.out.summary() |
|
86 |
||
87 |
if not the_raptor.out.close(): |
|
88 |
the_raptor.errorCode = 2 |
|
89 |
||
90 |
# return the error code |
|
91 |
sys.exit(the_raptor.errorCode) |
|
92 |