| 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 |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 build.exposed = True | 104 build.exposed = True |
| 105 update.exposed = True | 105 update.exposed = True |
| 106 index.exposed = True | 106 index.exposed = True |
| 107 | 107 |
| 108 | 108 |
| 109 if __name__ == '__main__': | 109 if __name__ == '__main__': |
| 110 usage = 'usage: %prog [options]' | 110 usage = 'usage: %prog [options]' |
| 111 parser = optparse.OptionParser(usage) | 111 parser = optparse.OptionParser(usage) |
| 112 parser.add_option('--archive_dir', dest='archive_dir', | 112 parser.add_option('--archive_dir', dest='archive_dir', |
| 113 help='serve archived builds only.') | 113 help='serve archived builds only.') |
| 114 parser.add_option('--board', dest='board', |
| 115 help='When pre-generating update, board for latest image.') |
| 114 parser.add_option('--client_prefix', dest='client_prefix', | 116 parser.add_option('--client_prefix', dest='client_prefix', |
| 115 help='Required prefix for client software version.', | 117 help='Required prefix for client software version.', |
| 116 default='MementoSoftwareUpdate') | 118 default='MementoSoftwareUpdate') |
| 117 parser.add_option('--factory_config', dest='factory_config', | 119 parser.add_option('--factory_config', dest='factory_config', |
| 118 help='Config file for serving images from factory floor.') | 120 help='Config file for serving images from factory floor.') |
| 119 parser.add_option('--for_vm', dest='vm', default=False, action='store_true', | 121 parser.add_option('--for_vm', dest='vm', default=False, action='store_true', |
| 120 help='Update is for a vm image.') | 122 help='Update is for a vm image.') |
| 121 parser.add_option('--image', dest='image', | 123 parser.add_option('--image', dest='image', |
| 122 help='Force update using this image.') | 124 help='Force update using this image.') |
| 123 parser.add_option('-p', '--pregenerate_update', action='store_true', | 125 parser.add_option('-p', '--pregenerate_update', action='store_true', |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 static_dir=static_dir, | 159 static_dir=static_dir, |
| 158 serve_only=serve_only, | 160 serve_only=serve_only, |
| 159 urlbase=options.urlbase, | 161 urlbase=options.urlbase, |
| 160 test_image=options.test_image, | 162 test_image=options.test_image, |
| 161 factory_config_path=options.factory_config, | 163 factory_config_path=options.factory_config, |
| 162 client_prefix=options.client_prefix, | 164 client_prefix=options.client_prefix, |
| 163 forced_image=options.image, | 165 forced_image=options.image, |
| 164 use_cached=options.use_cached, | 166 use_cached=options.use_cached, |
| 165 port=options.port, | 167 port=options.port, |
| 166 src_image=options.src_image, | 168 src_image=options.src_image, |
| 167 vm = options.vm) | 169 vm=options.vm, |
| 170 board=options.board) |
| 168 | 171 |
| 169 # Sanity-check for use of validate_factory_config. | 172 # Sanity-check for use of validate_factory_config. |
| 170 if not options.factory_config and options.validate_factory_config: | 173 if not options.factory_config and options.validate_factory_config: |
| 171 parser.error('You need a factory_config to validate.') | 174 parser.error('You need a factory_config to validate.') |
| 172 | 175 |
| 173 if options.factory_config: | 176 if options.factory_config: |
| 174 updater.ImportFactoryConfigFile(options.factory_config, | 177 updater.ImportFactoryConfigFile(options.factory_config, |
| 175 options.validate_factory_config) | 178 options.validate_factory_config) |
| 176 # We don't run the dev server with this option. | 179 # We don't run the dev server with this option. |
| 177 if options.validate_factory_config: | 180 if options.validate_factory_config: |
| 178 sys.exit(0) | 181 sys.exit(0) |
| 179 elif options.pregenerate_update: | 182 elif options.pregenerate_update: |
| 180 updater.PreGenerateUpdate() | 183 if not updater.PreGenerateUpdate(): |
| 184 sys.exit(1) |
| 181 | 185 |
| 182 cherrypy.quickstart(DevServerRoot(), config=_GetConfig(options)) | 186 cherrypy.quickstart(DevServerRoot(), config=_GetConfig(options)) |
| OLD | NEW |