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

Side by Side Diff: third_party/WebKit/Tools/Scripts/webkitpy/layout_tests/servers/server_base.py

Issue 1783073002: Run auto-formatter on files in webkitpy/layout_tests/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Ran yapf -i --style '{based_on_style: pep8, column_limit: 132}' then did manual fix-up Created 4 years, 9 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 unified diff | Download patch
OLDNEW
1 # Copyright (C) 2011 Google Inc. All rights reserved. 1 # Copyright (C) 2011 Google Inc. All rights reserved.
2 # 2 #
3 # Redistribution and use in source and binary forms, with or without 3 # Redistribution and use in source and binary forms, with or without
4 # modification, are permitted provided that the following conditions are 4 # modification, are permitted provided that the following conditions are
5 # met: 5 # met:
6 # 6 #
7 # * Redistributions of source code must retain the above copyright 7 # * Redistributions of source code must retain the above copyright
8 # notice, this list of conditions and the following disclaimer. 8 # notice, this list of conditions and the following disclaimer.
9 # * Redistributions in binary form must reproduce the above 9 # * Redistributions in binary form must reproduce the above
10 # copyright notice, this list of conditions and the following disclaimer 10 # copyright notice, this list of conditions and the following disclaimer
11 # in the documentation and/or other materials provided with the 11 # in the documentation and/or other materials provided with the
12 # distribution. 12 # distribution.
13 # * Neither the name of Google Inc. nor the names of its 13 # * Neither the name of Google Inc. nor the names of its
14 # contributors may be used to endorse or promote products derived from 14 # contributors may be used to endorse or promote products derived from
15 # this software without specific prior written permission. 15 # this software without specific prior written permission.
16 # 16 #
17 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 17 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 18 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 19 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 20 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 21 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 22 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 26 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28
29 """Base class used to start servers used by the layout tests.""" 28 """Base class used to start servers used by the layout tests."""
30 29
31 import errno 30 import errno
32 import logging 31 import logging
33 import socket 32 import socket
34 import tempfile 33 import tempfile
35 import time 34 import time
36 35
37
38 _log = logging.getLogger(__name__) 36 _log = logging.getLogger(__name__)
39 37
40 38
41 class ServerError(Exception): 39 class ServerError(Exception):
42 pass 40 pass
43 41
44 42
45 class ServerBase(object): 43 class ServerBase(object):
46 """A skeleton class for starting and stopping servers used by the layout tes ts.""" 44 """A skeleton class for starting and stopping servers used by the layout tes ts."""
47 45
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 if not self._pid: 120 if not self._pid:
123 self._pid = actual_pid 121 self._pid = actual_pid
124 122
125 if not self._pid: 123 if not self._pid:
126 return 124 return
127 125
128 if not actual_pid: 126 if not actual_pid:
129 _log.warning('Failed to stop %s: pid file is missing' % self._na me) 127 _log.warning('Failed to stop %s: pid file is missing' % self._na me)
130 return 128 return
131 if self._pid != actual_pid: 129 if self._pid != actual_pid:
132 _log.warning('Failed to stop %s: pid file contains %d, not %d' % 130 _log.warning('Failed to stop %s: pid file contains %d, not %d' % (self._name, actual_pid, self._pid))
133 (self._name, actual_pid, self._pid))
134 # Try to kill the existing pid, anyway, in case it got orphaned. 131 # Try to kill the existing pid, anyway, in case it got orphaned.
135 self._executive.kill_process(self._pid) 132 self._executive.kill_process(self._pid)
136 self._pid = None 133 self._pid = None
137 return 134 return
138 135
139 _log.debug("Attempting to shut down %s server at pid %d" % (self._na me, self._pid)) 136 _log.debug("Attempting to shut down %s server at pid %d" % (self._na me, self._pid))
140 self._stop_running_server() 137 self._stop_running_server()
141 _log.debug("%s server at pid %d stopped" % (self._name, self._pid)) 138 _log.debug("%s server at pid %d stopped" % (self._name, self._pid))
142 self._pid = None 139 self._pid = None
143 finally: 140 finally:
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 for mapping in self._mappings: 264 for mapping in self._mappings:
268 s = socket.socket() 265 s = socket.socket()
269 if not self._platform.is_win(): 266 if not self._platform.is_win():
270 s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) 267 s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
271 port = mapping['port'] 268 port = mapping['port']
272 try: 269 try:
273 s.bind(('localhost', port)) 270 s.bind(('localhost', port))
274 except IOError, e: 271 except IOError, e:
275 if e.errno in (errno.EALREADY, errno.EADDRINUSE): 272 if e.errno in (errno.EALREADY, errno.EADDRINUSE):
276 raise ServerError('Port %d is already in use.' % port) 273 raise ServerError('Port %d is already in use.' % port)
277 elif self._platform.is_win() and e.errno in (errno.WSAEACCES,): # pylint: disable=E1101 274 elif self._platform.is_win() and e.errno in (errno.WSAEACCES, ): # pylint: disable=E1101
278 raise ServerError('Port %d is already in use.' % port) 275 raise ServerError('Port %d is already in use.' % port)
279 else: 276 else:
280 raise 277 raise
281 finally: 278 finally:
282 s.close() 279 s.close()
283 _log.debug('all ports are available') 280 _log.debug('all ports are available')
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698