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