| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright (c) 2009 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2009 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 """A class to help start/stop the PyWebSocket server used by layout tests.""" | 6 """A class to help start/stop the PyWebSocket server used by layout tests.""" |
| 7 | 7 |
| 8 | 8 |
| 9 import logging | 9 import logging |
| 10 import optparse | 10 import optparse |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 | 38 |
| 39 | 39 |
| 40 class PyWebSocketNotStarted(Exception): | 40 class PyWebSocketNotStarted(Exception): |
| 41 pass | 41 pass |
| 42 | 42 |
| 43 | 43 |
| 44 class PyWebSocket(http_server.Lighttpd): | 44 class PyWebSocket(http_server.Lighttpd): |
| 45 def __init__(self, output_dir, port=_DEFAULT_WS_PORT, | 45 def __init__(self, output_dir, port=_DEFAULT_WS_PORT, |
| 46 use_tls=False, | 46 use_tls=False, |
| 47 private_key=http_server.Lighttpd._pem_file, | 47 private_key=http_server.Lighttpd._pem_file, |
| 48 certificate=http_server.Lighttpd._pem_file): | 48 certificate=http_server.Lighttpd._pem_file, |
| 49 register_cygwin=None): |
| 49 """Args: | 50 """Args: |
| 50 output_dir: the absolute path to the layout test result directory | 51 output_dir: the absolute path to the layout test result directory |
| 51 """ | 52 """ |
| 53 http_server.Lighttpd.__init__(self, output_dir, port=port, |
| 54 register_cygwin=register_cygwin) |
| 52 self._output_dir = output_dir | 55 self._output_dir = output_dir |
| 53 self._process = None | 56 self._process = None |
| 54 self._port = port | 57 self._port = port |
| 55 self._use_tls = use_tls | 58 self._use_tls = use_tls |
| 56 self._private_key = private_key | 59 self._private_key = private_key |
| 57 self._certificate = certificate | 60 self._certificate = certificate |
| 58 if self._port: | 61 if self._port: |
| 59 self._port = int(self._port) | 62 self._port = int(self._port) |
| 60 if self._use_tls: | 63 if self._use_tls: |
| 61 self._server_name = 'PyWebSocket(Secure)' | 64 self._server_name = 'PyWebSocket(Secure)' |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 # manually. | 159 # manually. |
| 157 option_parser = optparse.OptionParser() | 160 option_parser = optparse.OptionParser() |
| 158 option_parser.add_option('-p', '--port', dest='port', | 161 option_parser.add_option('-p', '--port', dest='port', |
| 159 default=None, help='Port to listen on') | 162 default=None, help='Port to listen on') |
| 160 option_parser.add_option('-t', '--tls', dest='use_tls', action='store_true', | 163 option_parser.add_option('-t', '--tls', dest='use_tls', action='store_true', |
| 161 default=False, help='use TLS (wss://)') | 164 default=False, help='use TLS (wss://)') |
| 162 option_parser.add_option('-k', '--private_key', dest='private_key', | 165 option_parser.add_option('-k', '--private_key', dest='private_key', |
| 163 default='', help='TLS private key file.') | 166 default='', help='TLS private key file.') |
| 164 option_parser.add_option('-c', '--certificate', dest='certificate', | 167 option_parser.add_option('-c', '--certificate', dest='certificate', |
| 165 default='', help='TLS certificate file.') | 168 default='', help='TLS certificate file.') |
| 169 option_parser.add_option('--register_cygwin', action="store_true", |
| 170 dest="register_cygwin", |
| 171 help='Register Cygwin paths (on Win try bots)') |
| 166 options, args = option_parser.parse_args() | 172 options, args = option_parser.parse_args() |
| 167 | 173 |
| 168 if not options.port: | 174 if not options.port: |
| 169 if options.use_tls: | 175 if options.use_tls: |
| 170 options.port = _DEFAULT_WSS_PORT | 176 options.port = _DEFAULT_WSS_PORT |
| 171 else: | 177 else: |
| 172 options.port = _DEFAULT_WS_PORT | 178 options.port = _DEFAULT_WS_PORT |
| 173 | 179 |
| 174 kwds = {'port':options.port, | 180 kwds = {'port':options.port, |
| 175 'use_tls':options.use_tls} | 181 'use_tls':options.use_tls} |
| 176 if options.private_key: | 182 if options.private_key: |
| 177 kwds['private_key'] = options.private_key | 183 kwds['private_key'] = options.private_key |
| 178 if options.certificate: | 184 if options.certificate: |
| 179 kwds['certificate'] = options.certificate | 185 kwds['certificate'] = options.certificate |
| 186 kwds['register_cygwin'] = options.register_cygwin |
| 180 | 187 |
| 181 pywebsocket = PyWebSocket(tempfile.gettempdir(), **kwds) | 188 pywebsocket = PyWebSocket(tempfile.gettempdir(), **kwds) |
| 182 pywebsocket.Start() | 189 pywebsocket.Start() |
| OLD | NEW |