Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(495)

Side by Side Diff: src/platform/dev/devserver.py

Issue 1238003: Fix devserver's handling of static images. (Closed)
Patch Set: Fix minor issues with update zip file, etc. Created 10 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/platform/dev/autoupdate.py ('k') | src/platform/dev/update_test.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright (c) 2009 The Chromium OS Authors. All rights reserved. 1 # Copyright (c) 2009 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 autoupdate 5 import autoupdate
6 import buildutil 6 import buildutil
7 import optparse 7 import optparse
8 import os 8 import os
9 import SimpleHTTPServer 9 import SimpleHTTPServer
10 import web 10 import web
(...skipping 29 matching lines...) Expand all
40 emerge_command = 'emerge-%s %s' % (input.board, input.pkg) 40 emerge_command = 'emerge-%s %s' % (input.board, input.pkg)
41 err = os.system(emerge_command) 41 err = os.system(emerge_command)
42 if err != 0: 42 if err != 0:
43 raise Exception('failed to execute %s' % emerge_command) 43 raise Exception('failed to execute %s' % emerge_command)
44 44
45 if __name__ == '__main__': 45 if __name__ == '__main__':
46 usage = 'usage: %prog [options]' 46 usage = 'usage: %prog [options]'
47 parser = optparse.OptionParser(usage) 47 parser = optparse.OptionParser(usage)
48 parser.add_option('-a', '--archive_dir', dest='archive_dir', 48 parser.add_option('-a', '--archive_dir', dest='archive_dir',
49 help='serve archived builds only.') 49 help='serve archived builds only.')
50 parser.add_option("-t", action="store_true", dest="test_image") 50 parser.add_option('-t', action='store_true', dest='test_image')
51 parser.add_option('-u', '--urlbase', dest='urlbase',
52 help='base URL, other than devserver, for update images.')
51 options, args = parser.parse_args() 53 options, args = parser.parse_args()
52 # clean up the args, due to httpserver's hardcoded use of sys.argv 54 # clean up the args, due to httpserver's hardcoded use of sys.argv
53 if options.archive_dir: 55 if options.archive_dir:
54 sys.argv.remove('-a') 56 sys.argv.remove('-a')
55 sys.argv.remove(options.archive_dir) 57 sys.argv.remove(options.archive_dir)
56 if options.test_image: 58 if options.test_image:
57 sys.argv.remove('-t') 59 sys.argv.remove('-t')
58 60 if options.urlbase:
61 sys.argv.remove('-u')
62 sys.argv.remove(options.urlbase)
59 63
60 root_dir = os.path.realpath('%s/../..' % 64 root_dir = os.path.realpath('%s/../..' %
61 os.path.dirname(os.path.abspath(sys.argv[0]))) 65 os.path.dirname(os.path.abspath(sys.argv[0])))
62 if options.archive_dir: 66 if options.archive_dir:
63 static_dir = os.path.realpath(options.archive_dir) 67 static_dir = os.path.realpath(options.archive_dir)
64 assert os.path.exists(static_dir), '%s must exist.' % options.archive_dir 68 assert os.path.exists(static_dir), '%s must exist.' % options.archive_dir
65 web.debug('using archive dir: %s' % static_dir) 69 web.debug('using archive dir: %s' % static_dir)
66 else: 70 else:
67 static_dir = os.path.realpath('%s/static' % 71 static_dir = os.path.realpath('%s/static' %
68 os.path.dirname(os.path.abspath(sys.argv[0]))) 72 os.path.dirname(os.path.abspath(sys.argv[0])))
69 web.debug('dev root is %s' % root_dir) 73 web.debug('dev root is %s' % root_dir)
70 os.system('mkdir -p %s' % static_dir) 74 os.system('mkdir -p %s' % static_dir)
71 web.debug('Serving images from %s' % static_dir) 75 web.debug('Serving images from %s' % static_dir)
72 76
73 updater = autoupdate.Autoupdate(root_dir=root_dir, 77 updater = autoupdate.Autoupdate(root_dir=root_dir,
74 static_dir=static_dir, 78 static_dir=static_dir,
75 serve_only=options.archive_dir, 79 serve_only=options.archive_dir,
80 urlbase=options.urlbase,
76 test_image=options.test_image) 81 test_image=options.test_image)
77 urls = ('/', 'index', 82 urls = ('/', 'index',
78 '/update', 'update', 83 '/update', 'update',
79 '/update/(.+)', 'update', 84 '/update/(.+)', 'update',
80 '/webbuild', 'webbuild', 85 '/webbuild', 'webbuild',
81 '/build', 'build') 86 '/build', 'build')
82 87
83 app = web.application(urls, globals(), autoreload=True) 88 app = web.application(urls, globals(), autoreload=True)
84 render = web.template.render('templates/') 89 render = web.template.render('templates/')
85 app.run() 90 app.run()
OLDNEW
« no previous file with comments | « src/platform/dev/autoupdate.py ('k') | src/platform/dev/update_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698