13
|
1 |
#!/usr/bin/python
|
|
2 |
|
18
|
3 |
# Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
13
|
4 |
# All rights reserved.
|
|
5 |
# This component and the accompanying materials are made available
|
|
6 |
# under the terms of the License "Symbian Foundation License v1.0"
|
|
7 |
# which accompanies this distribution, and is available
|
|
8 |
# at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html".
|
|
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)
|
18
|
49 |
the_raptor = raptor.Raptor.CreateCommandlineAnalysis(sys.argv[1:])
|
13
|
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
|
18
|
61 |
the_raptor.out.open(raptor_params, the_raptor.filterList, pbox)
|
13
|
62 |
|
|
63 |
except Exception, e:
|
|
64 |
sys.stderr.write("error: problem while creating filters %s\n" % str(e))
|
|
65 |
traceback.print_exc()
|
|
66 |
sys.exit(1)
|
|
67 |
|
|
68 |
# read stdin a line at a time and pass it to the Raptor object
|
|
69 |
try:
|
|
70 |
line = " "
|
|
71 |
while line:
|
|
72 |
line = sys.stdin.readline()
|
|
73 |
the_raptor.out.write(line)
|
|
74 |
except Exception,e:
|
|
75 |
sys.stderr.write("error: problem while filtering: %s\n" % str(e))
|
|
76 |
traceback.print_exc()
|
|
77 |
sys.exit(1)
|
|
78 |
|
|
79 |
|
|
80 |
# Print the summary (this can't return errors)
|
|
81 |
the_raptor.out.summary()
|
|
82 |
|
|
83 |
if not the_raptor.out.close():
|
|
84 |
the_raptor.errorCode = 2
|
|
85 |
|
|
86 |
# return the error code
|
|
87 |
sys.exit(the_raptor.errorCode)
|
|
88 |
|