diff options
author | maruel@chromium.org <maruel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-11-29 17:25:34 +0000 |
---|---|---|
committer | maruel@chromium.org <maruel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-11-29 17:25:34 +0000 |
commit | cb155a802bdc49cfafea1c41e0f0a92168f1da09 (patch) | |
tree | bf0fae4855c7f4458d8e959455b9d12d6cd54d9d /tools/traceline | |
parent | 9bec23957253b83955c4096903ad6293d1c6e1bb (diff) | |
download | chromium_src-cb155a802bdc49cfafea1c41e0f0a92168f1da09.zip chromium_src-cb155a802bdc49cfafea1c41e0f0a92168f1da09.tar.gz chromium_src-cb155a802bdc49cfafea1c41e0f0a92168f1da09.tar.bz2 |
Fix python scripts in src/tools/
Make sure that:
- shebang is only present for executable files
- shebang is #!/usr/bin/env python
- __main__ is only present for executable files
- file's executable bit is coherent
Also fix EOF LF to be only one.
TBR=timurrrr@chromium.org
BUG=105108
TEST=
Review URL: http://codereview.chromium.org/8678023
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@111960 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'tools/traceline')
-rw-r--r-- | tools/traceline/traceline/scripts/__init__.py | 0 | ||||
-rwxr-xr-x | tools/traceline/traceline/scripts/alloc.py | 16 | ||||
-rwxr-xr-x | tools/traceline/traceline/scripts/crit_sec.py | 16 | ||||
-rwxr-xr-x | tools/traceline/traceline/scripts/filter_short.py | 21 | ||||
-rwxr-xr-x[-rw-r--r--] | tools/traceline/traceline/scripts/filter_split.sh | 5 | ||||
-rwxr-xr-x | tools/traceline/traceline/scripts/scstats.py | 16 | ||||
-rwxr-xr-x | tools/traceline/traceline/scripts/split.py | 40 | ||||
-rwxr-xr-x | tools/traceline/traceline/scripts/syscalls.py | 2 |
8 files changed, 75 insertions, 41 deletions
diff --git a/tools/traceline/traceline/scripts/__init__.py b/tools/traceline/traceline/scripts/__init__.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/tools/traceline/traceline/scripts/__init__.py diff --git a/tools/traceline/traceline/scripts/alloc.py b/tools/traceline/traceline/scripts/alloc.py index d89447a..ee4af22 100755 --- a/tools/traceline/traceline/scripts/alloc.py +++ b/tools/traceline/traceline/scripts/alloc.py @@ -1,12 +1,12 @@ -# Copyright (c) 2009 The Chromium Authors. All rights reserved. +#!/usr/bin/env python +# Copyright (c) 2011 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. import sys -execfile(os.path.join( - os.path.dirname(os.path.join(os.path.curdir, __file__)), - 'syscalls.py')) +from syscalls import syscalls + def parseEvents(z): calls = { } @@ -18,4 +18,10 @@ def parseEvents(z): print '%f - %f - %x' % ( delta, ms, tid) -execfile(sys.argv[1]) + +def main(): + execfile(sys.argv[1]) + + +if __name__ == '__main__': + sys.exit(main()) diff --git a/tools/traceline/traceline/scripts/crit_sec.py b/tools/traceline/traceline/scripts/crit_sec.py index f43f50d..ee710bd 100755 --- a/tools/traceline/traceline/scripts/crit_sec.py +++ b/tools/traceline/traceline/scripts/crit_sec.py @@ -1,13 +1,13 @@ -# Copyright (c) 2009 The Chromium Authors. All rights reserved. +#!/usr/bin/env python +# Copyright (c) 2011 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. import sys import os -execfile(os.path.join( - os.path.dirname(os.path.join(os.path.curdir, __file__)), - 'syscalls.py')) +from syscalls import syscalls + def parseEvents(z): crits = { } @@ -48,4 +48,10 @@ def parseEvents(z): #raise repr(tid_stack) pass -execfile(sys.argv[1]) + +def main(): + execfile(sys.argv[1]) + + +if __name__ == '__main__': + main() diff --git a/tools/traceline/traceline/scripts/filter_short.py b/tools/traceline/traceline/scripts/filter_short.py index 9d8466e..1b73bf9 100755 --- a/tools/traceline/traceline/scripts/filter_short.py +++ b/tools/traceline/traceline/scripts/filter_short.py @@ -1,14 +1,19 @@ -# Copyright (c) 2009 The Chromium Authors. All rights reserved. +#!/usr/bin/env python +# Copyright (c) 2011 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. -# This script takes an input JSON, and filters out all system call events that -# took less than 0.2ms. This helps trim down the JSON data to only the most -# interesting / time critical events. +"""Takes an input JSON, and filters out all system call events that +took less than 0.2ms. + +This helps trim down the JSON data to only the most interesting / time critical +events. +""" import sys import re + def parseEvents(z): print 'parseEvents([' for e in z: @@ -20,4 +25,10 @@ def parseEvents(z): print '%s,' % re.sub('([0-9])L\\b', '\\1', str(e)) print '])' -execfile(sys.argv[1]) + +def main(): + execfile(sys.argv[1]) + + +if __name__ == '__main__': + main() diff --git a/tools/traceline/traceline/scripts/filter_split.sh b/tools/traceline/traceline/scripts/filter_split.sh index 19a2891..876488e 100644..100755 --- a/tools/traceline/traceline/scripts/filter_split.sh +++ b/tools/traceline/traceline/scripts/filter_split.sh @@ -1,6 +1,5 @@ #!/bin/bash - -# Copyright (c) 2009 The Chromium Authors. All rights reserved. +# Copyright (c) 2011 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. @@ -10,6 +9,6 @@ echo "parseEvents([" > totalsplit for f in split.*; do - python scripts/filter_short.py "$f" | tail -n +2 | head -n -1 >> totalsplit + ./scripts/filter_short.py "$f" | tail -n +2 | head -n -1 >> totalsplit done echo "]);" >> totalsplit diff --git a/tools/traceline/traceline/scripts/scstats.py b/tools/traceline/traceline/scripts/scstats.py index 21f28d8..e2f28dc 100755 --- a/tools/traceline/traceline/scripts/scstats.py +++ b/tools/traceline/traceline/scripts/scstats.py @@ -1,12 +1,12 @@ -# Copyright (c) 2009 The Chromium Authors. All rights reserved. +#!/usr/bin/env python +# Copyright (c) 2011 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. import sys -execfile(os.path.join( - os.path.dirname(os.path.join(os.path.curdir, __file__)), - 'syscalls.py')) +from syscalls import syscalls + def parseEvents(z): calls = { } @@ -23,4 +23,10 @@ def parseEvents(z): #for syscall, delta in calls.items(): # print '%f - %d %s' % (delta, syscall, syscalls.get(syscall, 'unknown')) -execfile(sys.argv[1]) + +def main(): + execfile(sys.argv[1]) + + +if __name__ == '__main__': + main() diff --git a/tools/traceline/traceline/scripts/split.py b/tools/traceline/traceline/scripts/split.py index 9e9f7dd..3b7bf90 100755 --- a/tools/traceline/traceline/scripts/split.py +++ b/tools/traceline/traceline/scripts/split.py @@ -1,25 +1,31 @@ -# Copyright (c) 2009 The Chromium Authors. All rights reserved. +#!/usr/bin/env python +# Copyright (c) 2011 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. -# Splits a single json file (read from stdin) into separate files of 40k -# records, named split.X. +"""Splits a single json file (read from stdin) into separate files of 40k +records, named split.X. +""" import sys -filecount = 0; -count = 0; -f = open('split.0', 'wb'); +def main(): + filecount = 0 + count = 0 + f = open('split.0', 'wb') + for l in sys.stdin: + if l == "},\r\n": + count += 1 + if count == 40000: + f.write("}]);\r\n") + count = 0 + filecount += 1 + f = open('split.%d' % filecount, 'wb') + f.write("parseEvents([\r\n") + continue + f.write(l) -for l in sys.stdin: - if l == "},\r\n": - count += 1 - if count == 40000: - f.write("}]);\r\n") - count = 0; - filecount += 1 - f = open('split.%d' % filecount, 'wb'); - f.write("parseEvents([\r\n") - continue - f.write(l) + +if __name__ == '__main__': + main() diff --git a/tools/traceline/traceline/scripts/syscalls.py b/tools/traceline/traceline/scripts/syscalls.py index 6a25c77..6800b45 100755 --- a/tools/traceline/traceline/scripts/syscalls.py +++ b/tools/traceline/traceline/scripts/syscalls.py @@ -1,4 +1,4 @@ -# Copyright (c) 2009 The Chromium Authors. All rights reserved. +# Copyright (c) 2011 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. |