Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(11)

Unified Diff: tools/python/google/gethash_timer.py

Issue 8678023: Fix python scripts in src/tools/ (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixes Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/pragmaonce/pragmaonce.py ('k') | tools/python/google/httpd_utils.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/python/google/gethash_timer.py
diff --git a/tools/python/google/gethash_timer.py b/tools/python/google/gethash_timer.py
old mode 100644
new mode 100755
index e59690bf187a9b5c3808d0e144e1c30815465a3f..9c4bd460895cbcc937a0bcc28b971b03515a7dca
--- 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())
« no previous file with comments | « tools/pragmaonce/pragmaonce.py ('k') | tools/python/google/httpd_utils.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698