| Index: Tools/Scripts/webkitpy/layout_tests/servers/pywebsocket.py
|
| diff --git a/Tools/Scripts/webkitpy/layout_tests/servers/pywebsocket.py b/Tools/Scripts/webkitpy/layout_tests/servers/pywebsocket.py
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..b4b74ebb661dab2bb903d0cf4e033c91dafa911f
|
| --- /dev/null
|
| +++ b/Tools/Scripts/webkitpy/layout_tests/servers/pywebsocket.py
|
| @@ -0,0 +1,90 @@
|
| +# Copyright (C) 2011 Google Inc. All rights reserved.
|
| +#
|
| +# Redistribution and use in source and binary forms, with or without
|
| +# modification, are permitted provided that the following conditions are
|
| +# met:
|
| +#
|
| +# * Redistributions of source code must retain the above copyright
|
| +# notice, this list of conditions and the following disclaimer.
|
| +# * Redistributions in binary form must reproduce the above
|
| +# copyright notice, this list of conditions and the following disclaimer
|
| +# in the documentation and/or other materials provided with the
|
| +# distribution.
|
| +# * Neither the name of Google Inc. nor the names of its
|
| +# contributors may be used to endorse or promote products derived from
|
| +# this software without specific prior written permission.
|
| +#
|
| +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
| +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
| +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
| +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
| +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
| +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
| +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
| +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
| +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
| +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
| +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
| +
|
| +"""A class to help start/stop the PyWebSocket server as used by the layout tests."""
|
| +
|
| +import logging
|
| +import os
|
| +import sys
|
| +import time
|
| +
|
| +from webkitpy.layout_tests.servers import server_base
|
| +
|
| +_log = logging.getLogger(__name__)
|
| +
|
| +
|
| +_WS_LOG_PREFIX = 'pywebsocket.ws.log-'
|
| +
|
| +_DEFAULT_WS_PORT = 8880
|
| +
|
| +
|
| +class PyWebSocket(server_base.ServerBase):
|
| +
|
| + def __init__(self, port_obj, output_dir):
|
| + super(PyWebSocket, self).__init__(port_obj, output_dir)
|
| + self._name = 'pywebsocket'
|
| + self._log_prefixes = (_WS_LOG_PREFIX,)
|
| +
|
| + self._port = _DEFAULT_WS_PORT
|
| + self._mappings = [{'port': self._port}]
|
| +
|
| + self._pid_file = self._filesystem.join(self._runtime_path, '%s.pid' % self._name)
|
| +
|
| + self._layout_tests = self._port_obj.layout_tests_dir()
|
| + self._web_socket_tests = self._filesystem.join(self._layout_tests, 'http', 'tests', 'websocket')
|
| +
|
| + def _prepare_config(self):
|
| + time_str = time.strftime('%d%b%Y-%H%M%S')
|
| + log_file_name = _WS_LOG_PREFIX + time_str
|
| + error_log = self._filesystem.join(self._output_dir, log_file_name + "-err.txt")
|
| +
|
| + from webkitpy.thirdparty import mod_pywebsocket
|
| + pywebsocket_base = self._port_obj.path_from_webkit_base('Tools', 'Scripts', 'webkitpy', 'thirdparty')
|
| + pywebsocket_script = self._filesystem.join(pywebsocket_base, 'mod_pywebsocket', 'standalone.py')
|
| + start_cmd = [
|
| + sys.executable, '-u', pywebsocket_script,
|
| + '--server-host', 'localhost',
|
| + '--port', str(self._port),
|
| + '--document-root', self._web_socket_tests,
|
| + '--scan-dir', self._web_socket_tests,
|
| + '--cgi-paths', '/',
|
| + '--log-file', error_log,
|
| + ]
|
| +
|
| + handler_map_file = self._filesystem.join(self._web_socket_tests, 'handler_map.txt')
|
| + if self._filesystem.exists(handler_map_file):
|
| + _log.debug('Using handler_map_file: %s' % handler_map_file)
|
| + start_cmd.append('--websock-handlers-map-file')
|
| + start_cmd.append(handler_map_file)
|
| + else:
|
| + _log.warning('No handler_map_file found')
|
| +
|
| + self._start_cmd = start_cmd
|
| + server_name = self._filesystem.basename(pywebsocket_script)
|
| + self._env = self._port_obj.setup_environ_for_server(server_name)
|
| + self._env['PYTHONPATH'] = (pywebsocket_base + os.path.pathsep + self._env.get('PYTHONPATH', ''))
|
|
|