| OLD | NEW |
| 1 #!/usr/bin/python | 1 #!/usr/bin/python |
| 2 | 2 |
| 3 # Copyright (c) 2009-2010 The Chromium OS Authors. All rights reserved. | 3 # Copyright (c) 2009-2010 The Chromium OS Authors. All rights reserved. |
| 4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
| 5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
| 6 | 6 |
| 7 """A CherryPy-based webserver to host images and build packages.""" | 7 """A CherryPy-based webserver to host images and build packages.""" |
| 8 | 8 |
| 9 import cherrypy | 9 import cherrypy |
| 10 import optparse | 10 import optparse |
| 11 import os | 11 import os |
| 12 import sys | 12 import sys |
| 13 | 13 |
| 14 import autoupdate | 14 import autoupdate |
| 15 | 15 |
| 16 # Sets up global to share between classes. | 16 # Sets up global to share between classes. |
| 17 global updater | 17 global updater |
| 18 updater = None | 18 updater = None |
| 19 | 19 |
| 20 def _GetConfig(options): | 20 def _GetConfig(options): |
| 21 """Returns the configuration for the devserver.""" | 21 """Returns the configuration for the devserver.""" |
| 22 base_config = { 'global': | 22 base_config = { 'global': |
| 23 { 'server.log_request_headers': True, | 23 { 'server.log_request_headers': True, |
| 24 'server.protocol_version': 'HTTP/1.1', | 24 'server.protocol_version': 'HTTP/1.1', |
| 25 'server.socket_host': '0.0.0.0', | 25 'server.socket_host': '0.0.0.0', |
| 26 'server.socket_port': int(options.port), | 26 'server.socket_port': int(options.port), |
| 27 'server.socket_timeout': 600, | 27 'server.socket_timeout': 6000, |
| 28 'response.timeout': 6000, |
| 28 'tools.staticdir.root': os.getcwd(), | 29 'tools.staticdir.root': os.getcwd(), |
| 29 }, | 30 }, |
| 30 '/update': | 31 '/update': |
| 31 { | 32 { |
| 32 # Gets rid of cherrypy parsing post file for args. | 33 # Gets rid of cherrypy parsing post file for args. |
| 33 'request.process_request_body': False, | 34 'request.process_request_body': False, |
| 34 }, | 35 }, |
| 35 # Sets up the static dir for file hosting. | 36 # Sets up the static dir for file hosting. |
| 36 '/static': | 37 '/static': |
| 37 { 'tools.staticdir.dir': 'static', | 38 { 'tools.staticdir.dir': 'static', |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 parser.error('You need a factory_config to validate.') | 157 parser.error('You need a factory_config to validate.') |
| 157 | 158 |
| 158 if options.factory_config: | 159 if options.factory_config: |
| 159 updater.ImportFactoryConfigFile(options.factory_config, | 160 updater.ImportFactoryConfigFile(options.factory_config, |
| 160 options.validate_factory_config) | 161 options.validate_factory_config) |
| 161 # We don't run the dev server with this option. | 162 # We don't run the dev server with this option. |
| 162 if options.validate_factory_config: | 163 if options.validate_factory_config: |
| 163 sys.exit(0) | 164 sys.exit(0) |
| 164 | 165 |
| 165 cherrypy.quickstart(DevServerRoot(), config=_GetConfig(options)) | 166 cherrypy.quickstart(DevServerRoot(), config=_GetConfig(options)) |
| OLD | NEW |