diff options
author | Mehrdad Afshari <mmx@google.com> | 2018-01-02 14:40:00 -0800 |
---|---|---|
committer | Mehrdad Afshari <mmx@google.com> | 2018-01-02 14:40:00 -0800 |
commit | 87cd994b0477e98c976e7b321b3c1f52666ab5e0 (patch) | |
tree | 8590a82e599e0c763f32f835ef2bbb129871e75b /tools/run_tests/python_utils | |
parent | 63392f682e21543099926251b642cdcd0be2a17f (diff) |
Upgrade yapf to 0.20.0
Upgrade yapf version to 0.20.0 and reformat Python files.
Diffstat (limited to 'tools/run_tests/python_utils')
-rwxr-xr-x | tools/run_tests/python_utils/dockerjob.py | 4 | ||||
-rw-r--r-- | tools/run_tests/python_utils/filter_pull_request_tests.py | 8 | ||||
-rwxr-xr-x | tools/run_tests/python_utils/jobset.py | 30 | ||||
-rw-r--r-- | tools/run_tests/python_utils/start_port_server.py | 15 |
4 files changed, 30 insertions, 27 deletions
diff --git a/tools/run_tests/python_utils/dockerjob.py b/tools/run_tests/python_utils/dockerjob.py index d2941c0811..2d22dc13a0 100755 --- a/tools/run_tests/python_utils/dockerjob.py +++ b/tools/run_tests/python_utils/dockerjob.py @@ -50,8 +50,8 @@ def docker_mapped_port(cid, port, timeout_seconds=15): return int(output.split(':', 2)[1]) except subprocess.CalledProcessError as e: pass - raise Exception('Failed to get exposed port %s for container %s.' % - (port, cid)) + raise Exception('Failed to get exposed port %s for container %s.' % (port, + cid)) def wait_for_healthy(cid, shortname, timeout_seconds): diff --git a/tools/run_tests/python_utils/filter_pull_request_tests.py b/tools/run_tests/python_utils/filter_pull_request_tests.py index 8e0dc708dd..4c09b3414e 100644 --- a/tools/run_tests/python_utils/filter_pull_request_tests.py +++ b/tools/run_tests/python_utils/filter_pull_request_tests.py @@ -124,10 +124,10 @@ def _get_changed_files(base_branch): """ # Get file changes between branch and merge-base of specified branch # Not combined to be Windows friendly - base_commit = check_output( - ["git", "merge-base", base_branch, "HEAD"]).rstrip() - return check_output( - ["git", "diff", base_commit, "--name-only", "HEAD"]).splitlines() + base_commit = check_output(["git", "merge-base", base_branch, + "HEAD"]).rstrip() + return check_output(["git", "diff", base_commit, "--name-only", + "HEAD"]).splitlines() def _can_skip_tests(file_names, triggers): diff --git a/tools/run_tests/python_utils/jobset.py b/tools/run_tests/python_utils/jobset.py index 454d09bf0d..6a3391337e 100755 --- a/tools/run_tests/python_utils/jobset.py +++ b/tools/run_tests/python_utils/jobset.py @@ -133,12 +133,13 @@ def message(tag, msg, explanatory_text=None, do_newline=False): logging.info(explanatory_text) logging.info('%s: %s', tag, msg) else: - sys.stdout.write('%s%s%s\x1b[%d;%dm%s\x1b[0m: %s%s' % ( - _BEGINNING_OF_LINE, _CLEAR_LINE, '\n%s' % explanatory_text - if explanatory_text is not None else '', - _COLORS[_TAG_COLOR[tag]][1], _COLORS[_TAG_COLOR[tag]][0], - tag, msg, '\n' - if do_newline or explanatory_text is not None else '')) + sys.stdout.write( + '%s%s%s\x1b[%d;%dm%s\x1b[0m: %s%s' % + (_BEGINNING_OF_LINE, _CLEAR_LINE, '\n%s' % explanatory_text + if explanatory_text is not None else '', + _COLORS[_TAG_COLOR[tag]][1], _COLORS[_TAG_COLOR[tag]][0], + tag, msg, '\n' + if do_newline or explanatory_text is not None else '')) sys.stdout.flush() return except IOError, e: @@ -210,8 +211,8 @@ class JobSpec(object): def __str__(self): return '%s: %s %s' % (self.shortname, ' '.join( - '%s=%s' % kv - for kv in self.environ.items()), ' '.join(self.cmdline)) + '%s=%s' % kv for kv in self.environ.items()), + ' '.join(self.cmdline)) class JobResult(object): @@ -284,8 +285,9 @@ class Job(object): self._process = try_start() break except OSError: - message('WARNING', 'Failed to start %s, retrying in %f seconds' - % (self._spec.shortname, delay)) + message('WARNING', + 'Failed to start %s, retrying in %f seconds' % + (self._spec.shortname, delay)) time.sleep(delay) delay *= 2 else: @@ -343,8 +345,8 @@ class Job(object): if real > 0.5: cores = (user + sys) / real self.result.cpu_measured = float('%.01f' % cores) - self.result.cpu_estimated = float('%.01f' % - self._spec.cpu_cost) + self.result.cpu_estimated = float( + '%.01f' % self._spec.cpu_cost) measurement = '; cpu_cost=%.01f; estimated=%.01f' % ( self.result.cpu_measured, self.result.cpu_estimated) if not self._quiet_success: @@ -378,8 +380,8 @@ class Job(object): else: message( 'TIMEOUT', - '%s [pid=%d, time=%.1fsec]' % - (self._spec.shortname, self._process.pid, elapsed), + '%s [pid=%d, time=%.1fsec]' % (self._spec.shortname, + self._process.pid, elapsed), stdout(), do_newline=True) self.kill() diff --git a/tools/run_tests/python_utils/start_port_server.py b/tools/run_tests/python_utils/start_port_server.py index 5572cdcfe7..37995acbdf 100644 --- a/tools/run_tests/python_utils/start_port_server.py +++ b/tools/run_tests/python_utils/start_port_server.py @@ -43,16 +43,16 @@ def start_port_server(): if running: current_version = int( subprocess.check_output([ - sys.executable, os.path.abspath( - 'tools/run_tests/python_utils/port_server.py'), + sys.executable, + os.path.abspath('tools/run_tests/python_utils/port_server.py'), 'dump_version' ])) logging.info('my port server is version %d', current_version) running = (version >= current_version) if not running: logging.info('port_server version mismatch: killing the old one') - urllib.urlopen('http://localhost:%d/quitquitquit' % - _PORT_SERVER_PORT).read() + urllib.urlopen( + 'http://localhost:%d/quitquitquit' % _PORT_SERVER_PORT).read() time.sleep(1) if not running: fd, logfile = tempfile.mkstemp() @@ -61,7 +61,8 @@ def start_port_server(): args = [ sys.executable, os.path.abspath('tools/run_tests/python_utils/port_server.py'), - '-p', '%d' % _PORT_SERVER_PORT, '-l', logfile + '-p', + '%d' % _PORT_SERVER_PORT, '-l', logfile ] env = dict(os.environ) env['BUILD_ID'] = 'pleaseDontKillMeJenkins' @@ -91,8 +92,8 @@ def start_port_server(): # try one final time: maybe another build managed to start one time.sleep(1) try: - urllib.urlopen('http://localhost:%d/get' % - _PORT_SERVER_PORT).read() + urllib.urlopen( + 'http://localhost:%d/get' % _PORT_SERVER_PORT).read() logging.info( 'last ditch attempt to contact port server succeeded') break |