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 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 # archive_dir is the directory where static/archive will point. | 168 # archive_dir is the directory where static/archive will point. |
169 # If this is an absolute path, all is fine. If someone calls this | 169 # If this is an absolute path, all is fine. If someone calls this |
170 # using a relative path, that is relative to src/platform/dev/. | 170 # using a relative path, that is relative to src/platform/dev/. |
171 # That use case is unmaintainable, but since applications use it | 171 # That use case is unmaintainable, but since applications use it |
172 # with =./static, instead of a boolean flag, we'll make this relative | 172 # with =./static, instead of a boolean flag, we'll make this relative |
173 # to devserver_dir to keep these unbroken. For now. | 173 # to devserver_dir to keep these unbroken. For now. |
174 archive_dir = options.archive_dir | 174 archive_dir = options.archive_dir |
175 if not os.path.isabs(archive_dir): | 175 if not os.path.isabs(archive_dir): |
176 archive_dir = os.path.realpath(os.path.join(devserver_dir,archive_dir)) | 176 archive_dir = os.path.realpath(os.path.join(devserver_dir,archive_dir)) |
177 _PrepareToServeUpdatesOnly(archive_dir, static_dir) | 177 _PrepareToServeUpdatesOnly(archive_dir, static_dir) |
| 178 static_dir = os.path.realpath(archive_dir) |
178 serve_only = True | 179 serve_only = True |
179 | 180 |
180 cache_dir = os.path.join(static_dir, 'cache') | 181 cache_dir = os.path.join(static_dir, 'cache') |
181 cherrypy.log('Using cache directory %s' % cache_dir, 'DEVSERVER') | 182 cherrypy.log('Using cache directory %s' % cache_dir, 'DEVSERVER') |
182 | 183 |
183 if os.path.exists(cache_dir): | 184 if os.path.exists(cache_dir): |
184 if options.clear_cache: | 185 if options.clear_cache: |
185 # Clear the cache and exit on error. | 186 # Clear the cache and exit on error. |
186 if os.system('rm -rf %s/*' % cache_dir) != 0: | 187 if os.system('rm -rf %s/*' % cache_dir) != 0: |
187 cherrypy.log('Failed to clear the cache with %s' % cmd, | 188 cherrypy.log('Failed to clear the cache with %s' % cmd, |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
232 # We don't run the dev server with this option. | 233 # We don't run the dev server with this option. |
233 if options.validate_factory_config: | 234 if options.validate_factory_config: |
234 sys.exit(0) | 235 sys.exit(0) |
235 elif options.pregenerate_update: | 236 elif options.pregenerate_update: |
236 if not updater.PreGenerateUpdate(): | 237 if not updater.PreGenerateUpdate(): |
237 sys.exit(1) | 238 sys.exit(1) |
238 | 239 |
239 # If the command line requested after setup, it's time to do it. | 240 # If the command line requested after setup, it's time to do it. |
240 if not options.exit: | 241 if not options.exit: |
241 cherrypy.quickstart(DevServerRoot(), config=_GetConfig(options)) | 242 cherrypy.quickstart(DevServerRoot(), config=_GetConfig(options)) |
OLD | NEW |