| OLD | NEW |
| 1 # Copyright (c) 2009-2010 The Chromium OS Authors. All rights reserved. | 1 # Copyright (c) 2009-2010 The Chromium OS 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 optparse | 5 import optparse |
| 6 import os | 6 import os |
| 7 import sys | 7 import sys |
| 8 import web | 8 import web |
| 9 | 9 |
| 10 import autoupdate | 10 import autoupdate |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 parser.add_option('--client_prefix', dest='client_prefix', | 86 parser.add_option('--client_prefix', dest='client_prefix', |
| 87 help='Required prefix for client software version.', | 87 help='Required prefix for client software version.', |
| 88 default='MementoSoftwareUpdate') | 88 default='MementoSoftwareUpdate') |
| 89 parser.add_option('--factory_config', dest='factory_config', | 89 parser.add_option('--factory_config', dest='factory_config', |
| 90 help='Config file for serving images from factory floor.') | 90 help='Config file for serving images from factory floor.') |
| 91 parser.add_option('--image', dest='image', | 91 parser.add_option('--image', dest='image', |
| 92 help='Force update using this image.') | 92 help='Force update using this image.') |
| 93 parser.add_option('-t', action='store_true', dest='test_image') | 93 parser.add_option('-t', action='store_true', dest='test_image') |
| 94 parser.add_option('-u', '--urlbase', dest='urlbase', | 94 parser.add_option('-u', '--urlbase', dest='urlbase', |
| 95 help='base URL, other than devserver, for update images.') | 95 help='base URL, other than devserver, for update images.') |
| 96 parser.add_option('--use_cached', action="store_true", default=False, |
| 97 help='Prefer cached image regardless of timestamps.') |
| 96 parser.add_option('--validate_factory_config', action="store_true", | 98 parser.add_option('--validate_factory_config', action="store_true", |
| 97 dest='validate_factory_config', | 99 dest='validate_factory_config', |
| 98 help='Validate factory config file, then exit.') | 100 help='Validate factory config file, then exit.') |
| 99 # Clean up the args, due to httpserver's hardcoded use of sys.argv. | 101 # Clean up the args, due to httpserver's hardcoded use of sys.argv. |
| 100 options, sys.argv = parser.parse_args(sys.argv) | 102 options, sys.argv = parser.parse_args(sys.argv) |
| 101 | 103 |
| 102 root_dir = os.path.realpath('%s/../..' % | 104 root_dir = os.path.realpath('%s/../..' % |
| 103 os.path.dirname(os.path.abspath(sys.argv[0]))) | 105 os.path.dirname(os.path.abspath(sys.argv[0]))) |
| 104 | 106 |
| 105 serve_only = False | 107 serve_only = False |
| (...skipping 11 matching lines...) Expand all Loading... |
| 117 web.debug('Serving from %s' % static_dir) | 119 web.debug('Serving from %s' % static_dir) |
| 118 | 120 |
| 119 updater = autoupdate.Autoupdate( | 121 updater = autoupdate.Autoupdate( |
| 120 root_dir=root_dir, | 122 root_dir=root_dir, |
| 121 static_dir=static_dir, | 123 static_dir=static_dir, |
| 122 serve_only=serve_only, | 124 serve_only=serve_only, |
| 123 urlbase=options.urlbase, | 125 urlbase=options.urlbase, |
| 124 test_image=options.test_image, | 126 test_image=options.test_image, |
| 125 factory_config_path=options.factory_config, | 127 factory_config_path=options.factory_config, |
| 126 client_prefix=options.client_prefix, | 128 client_prefix=options.client_prefix, |
| 127 forced_image=options.image) | 129 forced_image=options.image, |
| 130 use_cached=options.use_cached) |
| 128 | 131 |
| 129 if options.factory_config: | 132 if options.factory_config: |
| 130 updater.ImportFactoryConfigFile(options.factory_config, | 133 updater.ImportFactoryConfigFile(options.factory_config, |
| 131 options.validate_factory_config) | 134 options.validate_factory_config) |
| 132 | 135 |
| 133 if not options.validate_factory_config: | 136 if not options.validate_factory_config: |
| 134 # We do not need to run the dev server for validating the factory config. | 137 # We do not need to run the dev server for validating the factory config. |
| 135 # TODO(nsanders): Write unit test to validate. | 138 # TODO(nsanders): Write unit test to validate. |
| 136 urls = ('/', 'index', | 139 urls = ('/', 'index', |
| 137 '/update', 'update', | 140 '/update', 'update', |
| 138 '/update/(.+)', 'update', | 141 '/update/(.+)', 'update', |
| 139 '/build', 'build') | 142 '/build', 'build') |
| 140 | 143 |
| 141 # Overrides the default WSGIServer routine -- see OverrideWSGIServer. | 144 # Overrides the default WSGIServer routine -- see OverrideWSGIServer. |
| 142 web.httpserver.WSGIServer = OverrideWSGIServer | 145 web.httpserver.WSGIServer = OverrideWSGIServer |
| 143 app = web.application(urls, globals(), autoreload=True) | 146 app = web.application(urls, globals(), autoreload=True) |
| 144 render = web.template.render('templates/') | 147 render = web.template.render('templates/') |
| 145 app.run() | 148 app.run() |
| OLD | NEW |