| 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 25 matching lines...) Expand all Loading... |
| 36 import time | 36 import time |
| 37 | 37 |
| 38 | 38 |
| 39 _log = logging.getLogger(__name__) | 39 _log = logging.getLogger(__name__) |
| 40 | 40 |
| 41 | 41 |
| 42 class ServerError(Exception): | 42 class ServerError(Exception): |
| 43 pass | 43 pass |
| 44 | 44 |
| 45 | 45 |
| 46 class HttpServerBase(object): | 46 class ServerBase(object): |
| 47 """A skeleton class for starting and stopping servers used by the layout tes
ts.""" | 47 """A skeleton class for starting and stopping servers used by the layout tes
ts.""" |
| 48 | 48 |
| 49 def __init__(self, port_obj, number_of_servers=None): | 49 def __init__(self, port_obj, number_of_servers=None): |
| 50 self._executive = port_obj._executive | 50 self._executive = port_obj._executive |
| 51 self._filesystem = port_obj._filesystem | 51 self._filesystem = port_obj._filesystem |
| 52 self._name = '<virtual>' | 52 self._name = '<virtual>' |
| 53 self._mappings = {} | 53 self._mappings = {} |
| 54 self._pid = None | 54 self._pid = None |
| 55 self._pid_file = None | 55 self._pid_file = None |
| 56 self._port_obj = port_obj | 56 self._port_obj = port_obj |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 s.bind(('localhost', port)) | 208 s.bind(('localhost', port)) |
| 209 except IOError, e: | 209 except IOError, e: |
| 210 if e.errno in (errno.EALREADY, errno.EADDRINUSE): | 210 if e.errno in (errno.EALREADY, errno.EADDRINUSE): |
| 211 raise ServerError('Port %d is already in use.' % port) | 211 raise ServerError('Port %d is already in use.' % port) |
| 212 elif sys.platform == 'win32' and e.errno in (errno.WSAEACCES,):
# pylint: disable=E1101 | 212 elif sys.platform == 'win32' and e.errno in (errno.WSAEACCES,):
# pylint: disable=E1101 |
| 213 raise ServerError('Port %d is already in use.' % port) | 213 raise ServerError('Port %d is already in use.' % port) |
| 214 else: | 214 else: |
| 215 raise | 215 raise |
| 216 finally: | 216 finally: |
| 217 s.close() | 217 s.close() |
| OLD | NEW |