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/python | |
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/python')
-rwxr-xr-x[-rw-r--r--] | tools/python/google/gethash_timer.py | 47 | ||||
-rwxr-xr-x[-rw-r--r--] | tools/python/google/httpd_utils.py | 12 | ||||
-rw-r--r-- | tools/python/google/logging_utils.py | 6 | ||||
-rw-r--r-- | tools/python/google/path_utils.py | 3 | ||||
-rw-r--r-- | tools/python/google/platform_utils.py | 1 | ||||
-rw-r--r-- | tools/python/google/platform_utils_linux.py | 3 | ||||
-rw-r--r-- | tools/python/google/platform_utils_mac.py | 3 | ||||
-rw-r--r-- | tools/python/google/platform_utils_win.py | 3 |
8 files changed, 39 insertions, 39 deletions
diff --git a/tools/python/google/gethash_timer.py b/tools/python/google/gethash_timer.py index e59690b..9c4bd46 100644..100755 --- a/tools/python/google/gethash_timer.py +++ b/tools/python/google/gethash_timer.py @@ -1,24 +1,25 @@ -#!/usr/bin/python -# Copyright (c) 2006-2008 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. -# Issue a series of GetHash requests to the SafeBrowsing servers and measure the -# response times. -# -# Usage: -# -# $ ./gethash_timer.py --period=600 --samples=20 --output=resp.csv -# -# --period (or -p): The amount of time (in seconds) to wait between GetHash -# requests. Using a value of more than 300 (5 minutes) to -# include the effect of DNS. -# -# --samples (or -s): The number of requests to issue. If this parameter is not -# specified, the test will run indefinitely. -# -# --output (or -o): The path to a file where the output will be written in -# CSV format: sample_number,response_code,elapsed_time_ms +"""Issue a series of GetHash requests to the SafeBrowsing servers and measure +the response times. + +Usage: + + $ ./gethash_timer.py --period=600 --samples=20 --output=resp.csv + + --period (or -p): The amount of time (in seconds) to wait between GetHash + requests. Using a value of more than 300 (5 minutes) to + include the effect of DNS. + + --samples (or -s): The number of requests to issue. If this parameter is not + specified, the test will run indefinitely. + + --output (or -o): The path to a file where the output will be written in + CSV format: sample_number,response_code,elapsed_time_ms +""" import getopt import httplib @@ -26,7 +27,8 @@ import sys import time _GETHASH_HOST = 'safebrowsing.clients.google.com' -_GETHASH_REQUEST = '/safebrowsing/gethash?client=googleclient&appver=1.0&pver=2.1' +_GETHASH_REQUEST = ( + '/safebrowsing/gethash?client=googleclient&appver=1.0&pver=2.1') # Global logging file handle. g_file_handle = None @@ -115,7 +117,7 @@ def SetupOutputFile(file_name): g_file_handle = open(file_name, 'w') -if __name__ == '__main__': +def main(): period = 10 samples = None @@ -131,7 +133,7 @@ if __name__ == '__main__': file_name = value else: print 'Bad option: %s' % option - sys.exit(1) + return 1 try: print 'Starting Timed GetHash ----------' SetupOutputFile(file_name) @@ -142,3 +144,6 @@ if __name__ == '__main__': print 'Timed GetHash complete ----------' g_file_handle.close() + +if __name__ == '__main__': + sys.exit(main()) diff --git a/tools/python/google/httpd_utils.py b/tools/python/google/httpd_utils.py index e7cfe09..4a03ffc 100644..100755 --- a/tools/python/google/httpd_utils.py +++ b/tools/python/google/httpd_utils.py @@ -1,5 +1,5 @@ -#!/bin/env python -# Copyright (c) 2006-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. @@ -169,7 +169,8 @@ class ApacheHttpd(object): stdout=subprocess.PIPE, stderr=subprocess.PIPE) -if '__main__' == __name__: + +def main(): # Provide some command line params for starting/stopping the http server # manually. option_parser = optparse.OptionParser() @@ -183,7 +184,7 @@ if '__main__' == __name__: if not options.server: print ("Usage: %s -k {start|stop} [-r document_root] [--apache2]" % sys.argv[0]) - sys.exit(0) + return 1 document_root = None if options.root: @@ -194,3 +195,6 @@ if '__main__' == __name__: else: StopServers(apache2=options.apache2) + +if '__main__' == __name__: + sys.exit(main()) diff --git a/tools/python/google/logging_utils.py b/tools/python/google/logging_utils.py index 5fd95d3..ef2d674 100644 --- a/tools/python/google/logging_utils.py +++ b/tools/python/google/logging_utils.py @@ -1,10 +1,7 @@ -#!/bin/env python -# Copyright (c) 2006-2008 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. -# logging_utils.py - ''' Utility functions and objects for logging. ''' @@ -83,4 +80,3 @@ def config_root(level=logging.INFO, threshold=logging.WARNING, format=FORMAT, handler.setLevel(level) handler.setFormatter(formatter) root.addHandler(handler) - diff --git a/tools/python/google/path_utils.py b/tools/python/google/path_utils.py index 6f94a84..6ab4312 100644 --- a/tools/python/google/path_utils.py +++ b/tools/python/google/path_utils.py @@ -1,4 +1,4 @@ -# Copyright (c) 2006-2008 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. @@ -82,4 +82,3 @@ def MaybeMakeDirectory(*path): # errno.EEXIST is "File exists". If we see another error, re-raise. if e.errno != errno.EEXIST: raise - diff --git a/tools/python/google/platform_utils.py b/tools/python/google/platform_utils.py index 1489fa2..50bfb70 100644 --- a/tools/python/google/platform_utils.py +++ b/tools/python/google/platform_utils.py @@ -1,4 +1,3 @@ -#!/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. diff --git a/tools/python/google/platform_utils_linux.py b/tools/python/google/platform_utils_linux.py index db4eb50..237565e3 100644 --- a/tools/python/google/platform_utils_linux.py +++ b/tools/python/google/platform_utils_linux.py @@ -1,5 +1,4 @@ -#!/usr/bin/python -# Copyright (c) 2006-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. diff --git a/tools/python/google/platform_utils_mac.py b/tools/python/google/platform_utils_mac.py index c0a13e8..2e56a3d 100644 --- a/tools/python/google/platform_utils_mac.py +++ b/tools/python/google/platform_utils_mac.py @@ -1,5 +1,4 @@ -#!/usr/bin/python -# Copyright (c) 2006-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. diff --git a/tools/python/google/platform_utils_win.py b/tools/python/google/platform_utils_win.py index eef2b50..65db96c 100644 --- a/tools/python/google/platform_utils_win.py +++ b/tools/python/google/platform_utils_win.py @@ -1,4 +1,4 @@ -# Copyright (c) 2006-2008 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. """Platform-specific utility methods shared by several scripts.""" @@ -192,4 +192,3 @@ def GetCygwinPath(path): return '/cygdrive/%s/' % matchobj.group(1).lower() path = drive_regexp.sub(LowerDrive, path) return path.replace('\\', '/') - |