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 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 | 111 |
112 if __name__ == '__main__': | 112 if __name__ == '__main__': |
113 usage = 'usage: %prog [options]' | 113 usage = 'usage: %prog [options]' |
114 parser = optparse.OptionParser(usage) | 114 parser = optparse.OptionParser(usage) |
115 parser.add_option('--archive_dir', dest='archive_dir', | 115 parser.add_option('--archive_dir', dest='archive_dir', |
116 help='serve archived builds only.') | 116 help='serve archived builds only.') |
117 parser.add_option('--board', dest='board', | 117 parser.add_option('--board', dest='board', |
118 help='When pre-generating update, board for latest image.') | 118 help='When pre-generating update, board for latest image.') |
119 parser.add_option('--clear_cache', action='store_true', default=False, | 119 parser.add_option('--clear_cache', action='store_true', default=False, |
120 help='Clear out all cached udpates and exit') | 120 help='Clear out all cached udpates and exit') |
121 parser.add_option('--client_prefix', dest='client_prefix', | 121 parser.add_option('--client_prefix', dest='client_prefix_deprecated', |
122 help='Required prefix for client software version.', | 122 help='No longer used. It is still here so we don\'t break ' |
123 default='MementoSoftwareUpdate') | 123 'scripts that used it.', default='') |
124 parser.add_option('--data_dir', dest='data_dir', | 124 parser.add_option('--data_dir', dest='data_dir', |
125 help='Writable directory where static lives', | 125 help='Writable directory where static lives', |
126 default=os.path.dirname(os.path.abspath(sys.argv[0]))) | 126 default=os.path.dirname(os.path.abspath(sys.argv[0]))) |
127 parser.add_option('--exit', action='store_true', default=False, | 127 parser.add_option('--exit', action='store_true', default=False, |
128 help='Don\'t start the server (still pregenerate or clear' | 128 help='Don\'t start the server (still pregenerate or clear' |
129 'cache).') | 129 'cache).') |
130 parser.add_option('--factory_config', dest='factory_config', | 130 parser.add_option('--factory_config', dest='factory_config', |
131 help='Config file for serving images from factory floor.') | 131 help='Config file for serving images from factory floor.') |
132 parser.add_option('--for_vm', dest='vm', default=False, action='store_true', | 132 parser.add_option('--for_vm', dest='vm', default=False, action='store_true', |
133 help='Update is for a vm image.') | 133 help='Update is for a vm image.') |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 # Clear all but the last N cached updates | 193 # Clear all but the last N cached updates |
194 cmd = ('cd %s; ls -tr | head --lines=-%d | xargs rm -rf' % | 194 cmd = ('cd %s; ls -tr | head --lines=-%d | xargs rm -rf' % |
195 (cache_dir, CACHED_ENTRIES)) | 195 (cache_dir, CACHED_ENTRIES)) |
196 if os.system(cmd) != 0: | 196 if os.system(cmd) != 0: |
197 cherrypy.log('Failed to clean up old delta cache files with %s' % cmd, | 197 cherrypy.log('Failed to clean up old delta cache files with %s' % cmd, |
198 'DEVSERVER') | 198 'DEVSERVER') |
199 sys.exit(1) | 199 sys.exit(1) |
200 else: | 200 else: |
201 os.makedirs(cache_dir) | 201 os.makedirs(cache_dir) |
202 | 202 |
| 203 if options.client_prefix_deprecated: |
| 204 cherrypy.log('The --client_prefix argument is DEPRECATED, ' |
| 205 'and is no longer needed.', 'DEVSERVER') |
| 206 |
203 cherrypy.log('Data dir is %s' % options.data_dir, 'DEVSERVER') | 207 cherrypy.log('Data dir is %s' % options.data_dir, 'DEVSERVER') |
204 cherrypy.log('Source root is %s' % root_dir, 'DEVSERVER') | 208 cherrypy.log('Source root is %s' % root_dir, 'DEVSERVER') |
205 cherrypy.log('Serving from %s' % static_dir, 'DEVSERVER') | 209 cherrypy.log('Serving from %s' % static_dir, 'DEVSERVER') |
206 | 210 |
207 updater = autoupdate.Autoupdate( | 211 updater = autoupdate.Autoupdate( |
208 root_dir=root_dir, | 212 root_dir=root_dir, |
209 static_dir=static_dir, | 213 static_dir=static_dir, |
210 serve_only=serve_only, | 214 serve_only=serve_only, |
211 urlbase=options.urlbase, | 215 urlbase=options.urlbase, |
212 test_image=options.test_image, | 216 test_image=options.test_image, |
213 factory_config_path=options.factory_config, | 217 factory_config_path=options.factory_config, |
214 client_prefix=options.client_prefix, | |
215 forced_image=options.image, | 218 forced_image=options.image, |
216 forced_payload=options.payload, | 219 forced_payload=options.payload, |
217 port=options.port, | 220 port=options.port, |
218 proxy_port=options.proxy_port, | 221 proxy_port=options.proxy_port, |
219 src_image=options.src_image, | 222 src_image=options.src_image, |
220 vm=options.vm, | 223 vm=options.vm, |
221 board=options.board, | 224 board=options.board, |
222 copy_to_static_root=not options.exit, | 225 copy_to_static_root=not options.exit, |
223 private_key=options.private_key, | 226 private_key=options.private_key, |
224 ) | 227 ) |
225 | 228 |
226 # Sanity-check for use of validate_factory_config. | 229 # Sanity-check for use of validate_factory_config. |
227 if not options.factory_config and options.validate_factory_config: | 230 if not options.factory_config and options.validate_factory_config: |
228 parser.error('You need a factory_config to validate.') | 231 parser.error('You need a factory_config to validate.') |
229 | 232 |
230 if options.factory_config: | 233 if options.factory_config: |
231 updater.ImportFactoryConfigFile(options.factory_config, | 234 updater.ImportFactoryConfigFile(options.factory_config, |
232 options.validate_factory_config) | 235 options.validate_factory_config) |
233 # We don't run the dev server with this option. | 236 # We don't run the dev server with this option. |
234 if options.validate_factory_config: | 237 if options.validate_factory_config: |
235 sys.exit(0) | 238 sys.exit(0) |
236 elif options.pregenerate_update: | 239 elif options.pregenerate_update: |
237 if not updater.PreGenerateUpdate(): | 240 if not updater.PreGenerateUpdate(): |
238 sys.exit(1) | 241 sys.exit(1) |
239 | 242 |
240 # If the command line requested after setup, it's time to do it. | 243 # If the command line requested after setup, it's time to do it. |
241 if not options.exit: | 244 if not options.exit: |
242 cherrypy.quickstart(DevServerRoot(), config=_GetConfig(options)) | 245 cherrypy.quickstart(DevServerRoot(), config=_GetConfig(options)) |
OLD | NEW |