OLD | NEW |
1 # Copyright 2015 The Chromium Authors. All rights reserved. | 1 # Copyright 2015 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 import atexit | 5 import atexit |
6 import datetime | 6 import datetime |
7 import email.utils | 7 import email.utils |
8 import errno | 8 import errno |
9 import gzip | 9 import gzip |
10 import hashlib | 10 import hashlib |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 assert mappings | 190 assert mappings |
191 handler_class = _GetHandlerClassForPath(mappings) | 191 handler_class = _GetHandlerClassForPath(mappings) |
192 | 192 |
193 try: | 193 try: |
194 httpd = _SilentTCPServer(('127.0.0.1', host_port), handler_class) | 194 httpd = _SilentTCPServer(('127.0.0.1', host_port), handler_class) |
195 atexit.register(httpd.shutdown) | 195 atexit.register(httpd.shutdown) |
196 | 196 |
197 http_thread = threading.Thread(target=httpd.serve_forever) | 197 http_thread = threading.Thread(target=httpd.serve_forever) |
198 http_thread.daemon = True | 198 http_thread.daemon = True |
199 http_thread.start() | 199 http_thread.start() |
200 print 'Started http://%s:%d to host %s.' % (httpd.server_address[0], | |
201 httpd.server_address[1], | |
202 str(mappings)) | |
203 return httpd.server_address | 200 return httpd.server_address |
204 except socket.error as v: | 201 except socket.error as v: |
205 error_code = v[0] | 202 error_code = v[0] |
206 print 'Failed to start http server for %s on port %d: %s.' % ( | 203 print 'Failed to start http server for %s on port %d: %s.' % ( |
207 str(mappings), host_port, os.strerror(error_code)) | 204 str(mappings), host_port, os.strerror(error_code)) |
208 if error_code == errno.EADDRINUSE: | 205 if error_code == errno.EADDRINUSE: |
209 print (' Run `fuser %d/tcp` to find out which process is using the port.' | 206 print (' Run `fuser %d/tcp` to find out which process is using the port.' |
210 % host_port) | 207 % host_port) |
211 print '---' | 208 print '---' |
212 raise | 209 raise |
OLD | NEW |