From a8438b2e64196bf6f5151005cee2cee2a26d4099 Mon Sep 17 00:00:00 2001 From: qyearsley Date: Sun, 20 Sep 2015 15:36:54 -0700 Subject: [PATCH] Minor Python style clean-up Review URL: https://codereview.chromium.org/1354793002 Cr-Commit-Position: refs/heads/master@{#349883} --- chrome/test/chromedriver/archive.py | 3 +++ chrome/test/chromedriver/cpp_source.py | 20 ++++++++++---------- .../test/chromedriver/embed_mobile_devices_in_cpp.py | 3 +-- chrome/test/chromedriver/embed_networks_in_cpp.py | 2 +- chrome/test/chromedriver/embed_version_in_cpp.py | 3 +-- chrome/test/chromedriver/run_buildbot_steps.py | 4 ++-- chrome/test/chromedriver/test/test_environment.py | 1 + chrome/test/chromedriver/util.py | 2 +- 8 files changed, 20 insertions(+), 18 deletions(-) diff --git a/chrome/test/chromedriver/archive.py b/chrome/test/chromedriver/archive.py index 7929b8bb5653..387a3964e362 100644 --- a/chrome/test/chromedriver/archive.py +++ b/chrome/test/chromedriver/archive.py @@ -51,6 +51,7 @@ def DownloadChrome(revision, dest_dir, site=Site.CONTINUOUS): return 'chrome-mac' elif util.IsLinux(): return 'chrome-linux' + def GetChromePathFromPackage(): if util.IsWindows(): return 'chrome.exe' @@ -80,10 +81,12 @@ def _GetDownloadPlatform(): else: return 'Linux' + def GetLatestSnapshotVersion(): """Returns the latest revision of snapshot build.""" return GetLatestRevision(GetSnapshotDownloadSite()) + def GetSnapshotDownloadSite(): """Returns the site to download snapshot build according to the platform.""" return Site.CHROMIUM_SNAPSHOT diff --git a/chrome/test/chromedriver/cpp_source.py b/chrome/test/chromedriver/cpp_source.py index c91eca956e81..dd6114b38e6b 100644 --- a/chrome/test/chromedriver/cpp_source.py +++ b/chrome/test/chromedriver/cpp_source.py @@ -23,14 +23,14 @@ def WriteSource(base_name, global_string_map: Map of variable names to their string values. These variables will be available as globals. """ - copyright = '\n'.join([ - '// Copyright %s 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 file was generated at (%s) by running:', - '// %s']) % ( + copyright_header_template = ( + '// Copyright %s The Chromium Authors. All rights reserved.\n' + '// Use of this source code is governed by a BSD-style license ' + 'that can be\n' + '// found in the LICENSE file.\n\n' + '// This file was generated at (%s) by running:\n' + '// %s') + copyright_header = copyright_header_template % ( datetime.date.today().year, datetime.datetime.now().isoformat(' '), ' '.join(sys.argv)) @@ -43,7 +43,7 @@ def WriteSource(base_name, temp = '_'.join(dir_from_src.split('/') + [base_name]) define = temp.upper() + '_H_' header = '\n'.join([ - copyright, + copyright_header, '', '#ifndef ' + define, '#define ' + define, @@ -71,7 +71,7 @@ def WriteSource(base_name, definitions += ['const char %s[] =\n%s;' % (name, '\n'.join(lines))] cc = '\n'.join([ - copyright, + copyright_header, '', '#include "%s"' % (dir_from_src + '/' + base_name + '.h'), '', diff --git a/chrome/test/chromedriver/embed_mobile_devices_in_cpp.py b/chrome/test/chromedriver/embed_mobile_devices_in_cpp.py index 2aed44b1ee7c..9fe2ad419d0f 100755 --- a/chrome/test/chromedriver/embed_mobile_devices_in_cpp.py +++ b/chrome/test/chromedriver/embed_mobile_devices_in_cpp.py @@ -12,7 +12,6 @@ JSONReader. """ import optparse -import os import re import subprocess import sys @@ -21,7 +20,7 @@ import cpp_source def quotizeKeys(s, keys): - """Returns the string s with each instance of each key wrapped in quotes. + """Returns the string |s| with each instance of each key wrapped in quotes. Args: s: a string containing keys that need to be wrapped in quotes. diff --git a/chrome/test/chromedriver/embed_networks_in_cpp.py b/chrome/test/chromedriver/embed_networks_in_cpp.py index 45797abc34ca..b258fa5a0c95 100755 --- a/chrome/test/chromedriver/embed_networks_in_cpp.py +++ b/chrome/test/chromedriver/embed_networks_in_cpp.py @@ -12,7 +12,6 @@ be parsed with JSONReader. """ import optparse -import os import re import subprocess import sys @@ -34,6 +33,7 @@ def quotizeKeys(s, keys): s = re.sub('%s: ' % key, '"%s": ' % key, s) return s + def evaluateMultiplications(s): """Returns the string s with each bare multiplication evaluated. diff --git a/chrome/test/chromedriver/embed_version_in_cpp.py b/chrome/test/chromedriver/embed_version_in_cpp.py index b7f953b9564a..5caf77243b69 100755 --- a/chrome/test/chromedriver/embed_version_in_cpp.py +++ b/chrome/test/chromedriver/embed_version_in_cpp.py @@ -23,7 +23,7 @@ def main(): parser.add_option( '', '--directory', type='string', default='.', help='Path to directory where the cc/h file should be created') - options, args = parser.parse_args() + options, _ = parser.parse_args() version = open(options.version_file, 'r').read().strip() revision = lastchange.FetchVersionInfo(None).revision @@ -49,4 +49,3 @@ def main(): if __name__ == '__main__': sys.exit(main()) - diff --git a/chrome/test/chromedriver/run_buildbot_steps.py b/chrome/test/chromedriver/run_buildbot_steps.py index 7673b7a43f48..4c1cee2d6903 100755 --- a/chrome/test/chromedriver/run_buildbot_steps.py +++ b/chrome/test/chromedriver/run_buildbot_steps.py @@ -170,7 +170,7 @@ def _CommitPositionState(test_results_log, commit_position): """Check the state of tests at a given commit position. Considers tests as having passed at a commit position if they passed at - revisons both before and after. + revisions both before and after. Args: test_results_log: A test results log dictionary from _GetTestResultsLog(). @@ -541,7 +541,7 @@ def main(): util.MarkBuildStepError() # Add a "cleanup" step so that errors from runtest.py or bb_device_steps.py - # (which invoke this script) are kept in thier own build step. + # (which invoke this script) are kept in their own build step. util.MarkBuildStepStart('cleanup') diff --git a/chrome/test/chromedriver/test/test_environment.py b/chrome/test/chromedriver/test/test_environment.py index f90c12e1e0d2..be7061a6c203 100644 --- a/chrome/test/chromedriver/test/test_environment.py +++ b/chrome/test/chromedriver/test/test_environment.py @@ -8,6 +8,7 @@ These classes abstract away the various setups needed to run the WebDriver java tests in various environments. """ +import logging import os import sys diff --git a/chrome/test/chromedriver/util.py b/chrome/test/chromedriver/util.py index d8eed0cc02de..8f67b9ea5268 100644 --- a/chrome/test/chromedriver/util.py +++ b/chrome/test/chromedriver/util.py @@ -161,7 +161,7 @@ def DoesUrlExist(url): conn = httplib.HTTPConnection(parsed.netloc) conn.request('HEAD', parsed.path) response = conn.getresponse() - except (socket.gaierror, socket.error): + except httplib.HTTPException: return False finally: conn.close() -- 2.11.4.GIT