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

Unified Diff: Tools/Scripts/webkitpy/layout_tests/port/server_process.py

Issue 546133003: Reformat webkitpy.layout_tests w/ format-webkitpy. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 3 months 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
Index: Tools/Scripts/webkitpy/layout_tests/port/server_process.py
diff --git a/Tools/Scripts/webkitpy/layout_tests/port/server_process.py b/Tools/Scripts/webkitpy/layout_tests/port/server_process.py
index f9ec1a7dc54de97f04c8820c79ed540e08faf48d..22c017a901ecdc34187dc53fbe4cbcc4b483d992 100644
--- a/Tools/Scripts/webkitpy/layout_tests/port/server_process.py
+++ b/Tools/Scripts/webkitpy/layout_tests/port/server_process.py
@@ -72,7 +72,9 @@ def quote_data(data):
lines.append(l)
return lines
+
class ServerProcess(object):
+
"""This class provides a wrapper around a subprocess that
implements a simple request/response usage model. The primary benefit
is that reading responses takes a deadline, so that we don't ever block
@@ -127,21 +129,21 @@ class ServerProcess(object):
def _start(self):
if self._proc:
- raise ValueError("%s already running" % self._name)
+ raise ValueError('%s already running' % self._name)
self._reset()
# close_fds is a workaround for http://bugs.python.org/issue2320
close_fds = not self._host.platform.is_win()
if self._logging:
env_str = ''
if self._env:
- env_str += '\n'.join("%s=%s" % (k, v) for k, v in self._env.items()) + '\n'
+ env_str += '\n'.join('%s=%s' % (k, v) for k, v in self._env.items()) + '\n'
_log.info('CMD: \n%s%s\n', env_str, _quote_cmd(self._cmd))
self._proc = self._host.executive.popen(self._cmd, stdin=self._host.executive.PIPE,
- stdout=self._host.executive.PIPE,
- stderr=self._host.executive.PIPE,
- close_fds=close_fds,
- env=self._env,
- universal_newlines=self._universal_newlines)
+ stdout=self._host.executive.PIPE,
+ stderr=self._host.executive.PIPE,
+ close_fds=close_fds,
+ env=self._env,
+ universal_newlines=self._universal_newlines)
self._pid = self._proc.pid
fd = self._proc.stdout.fileno()
if not self._use_win32_apis:
@@ -178,7 +180,7 @@ class ServerProcess(object):
try:
self._log_data(' IN', bytes)
self._proc.stdin.write(bytes)
- except IOError, e:
+ except IOError as e:
self.stop(0.0)
# stop() calls _reset(), so we have to set crashed to True after calling stop().
self._crashed = True
@@ -215,7 +217,8 @@ class ServerProcess(object):
return None # Instructs the caller to keep waiting.
return_value = self._read(deadline, retrieve_bytes_from_buffers)
- # FIXME: This is a bit of a hack around the fact that _read normally only returns one value, but this caller wants it to return two.
+ # FIXME: This is a bit of a hack around the fact that _read normally only
+ # returns one value, but this caller wants it to return two.
if return_value is None:
return None, None
return return_value
@@ -268,7 +271,7 @@ class ServerProcess(object):
select_fds = (out_fd, err_fd)
try:
read_fds, _, _ = select.select(select_fds, [], select_fds, max(deadline - time.time(), 0))
- except select.error, e:
+ except select.error as e:
# We can ignore EINVAL since it's likely the process just crashed and we'll
# figure that out the next time through the loop in _read().
if e.args[0] == errno.EINVAL:
@@ -294,7 +297,7 @@ class ServerProcess(object):
self._crashed = True
self._log_data('ERR', data)
self._error += data
- except IOError, e:
+ except IOError as e:
# We can ignore the IOErrors because we will detect if the subporcess crashed
# the next time through the loop in _read()
pass
@@ -327,7 +330,7 @@ class ServerProcess(object):
if avail > 0:
_, buf = win32file.ReadFile(handle, avail, None)
return buf
- except Exception, e:
+ except Exception as e:
if e[0] not in (109, errno.ESHUTDOWN): # 109 == win32 ERROR_BROKEN_PIPE
raise
return None

Powered by Google App Engine
This is Rietveld 408576698