| OLD | NEW |
| 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 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 | 40 |
| 41 class ServerError(Exception): | 41 class ServerError(Exception): |
| 42 pass | 42 pass |
| 43 | 43 |
| 44 | 44 |
| 45 class ServerBase(object): | 45 class ServerBase(object): |
| 46 """A skeleton class for starting and stopping servers used by the layout tes
ts.""" | 46 """A skeleton class for starting and stopping servers used by the layout tes
ts.""" |
| 47 | 47 |
| 48 def __init__(self, port_obj, output_dir): | 48 def __init__(self, port_obj, output_dir): |
| 49 self._port_obj = port_obj | 49 self._port_obj = port_obj |
| 50 self._executive = port_obj._executive | 50 self._executive = port_obj.host.executive |
| 51 self._filesystem = port_obj._filesystem | 51 self._filesystem = port_obj.host.filesystem |
| 52 self._platform = port_obj.host.platform | 52 self._platform = port_obj.host.platform |
| 53 self._output_dir = output_dir | 53 self._output_dir = output_dir |
| 54 | 54 |
| 55 # We need a non-checkout-dependent place to put lock files, etc. We | 55 # We need a non-checkout-dependent place to put lock files, etc. We |
| 56 # don't use the Python default on the Mac because it defaults to a | 56 # don't use the Python default on the Mac because it defaults to a |
| 57 # randomly-generated directory under /var/folders and no one would ever | 57 # randomly-generated directory under /var/folders and no one would ever |
| 58 # look there. | 58 # look there. |
| 59 tmpdir = tempfile.gettempdir() | 59 tmpdir = tempfile.gettempdir() |
| 60 if self._platform.is_mac(): | 60 if self._platform.is_mac(): |
| 61 tmpdir = '/tmp' | 61 tmpdir = '/tmp' |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 276 except IOError as e: | 276 except IOError as e: |
| 277 if e.errno in (errno.EALREADY, errno.EADDRINUSE): | 277 if e.errno in (errno.EALREADY, errno.EADDRINUSE): |
| 278 raise ServerError('Port %d is already in use.' % port) | 278 raise ServerError('Port %d is already in use.' % port) |
| 279 elif self._platform.is_win() and e.errno in (errno.WSAEACCES,):
# pylint: disable=E1101 | 279 elif self._platform.is_win() and e.errno in (errno.WSAEACCES,):
# pylint: disable=E1101 |
| 280 raise ServerError('Port %d is already in use.' % port) | 280 raise ServerError('Port %d is already in use.' % port) |
| 281 else: | 281 else: |
| 282 raise | 282 raise |
| 283 finally: | 283 finally: |
| 284 s.close() | 284 s.close() |
| 285 _log.debug('all ports are available') | 285 _log.debug('all ports are available') |
| OLD | NEW |