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

Side by Side Diff: devserver.py

Issue 5611004: Add support for --proxy_port. (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/dev-util.git@master
Patch Set: Created 10 years 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 | Annotate | Revision Log
« no previous file with comments | « autoupdate_unittest.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 parser.add_option('--for_vm', dest='vm', default=False, action='store_true', 128 parser.add_option('--for_vm', dest='vm', default=False, action='store_true',
129 help='Update is for a vm image.') 129 help='Update is for a vm image.')
130 parser.add_option('--image', dest='image', 130 parser.add_option('--image', dest='image',
131 help='Force update using this image.') 131 help='Force update using this image.')
132 parser.add_option('-p', '--pregenerate_update', action='store_true', 132 parser.add_option('-p', '--pregenerate_update', action='store_true',
133 default=False, help='Pre-generate update payload.') 133 default=False, help='Pre-generate update payload.')
134 parser.add_option('--payload', dest='payload', 134 parser.add_option('--payload', dest='payload',
135 help='Use update payload from specified directory.') 135 help='Use update payload from specified directory.')
136 parser.add_option('--port', default=8080, 136 parser.add_option('--port', default=8080,
137 help='Port for the dev server to use.') 137 help='Port for the dev server to use.')
138 parser.add_option('--proxy_port', default=None,
139 help='Port to have the client connect to (testing support)')
138 parser.add_option('--src_image', default='', 140 parser.add_option('--src_image', default='',
139 help='Image on remote machine for generating delta update.') 141 help='Image on remote machine for generating delta update.')
140 parser.add_option('-t', action='store_true', dest='test_image') 142 parser.add_option('-t', action='store_true', dest='test_image')
141 parser.add_option('-u', '--urlbase', dest='urlbase', 143 parser.add_option('-u', '--urlbase', dest='urlbase',
142 help='base URL, other than devserver, for update images.') 144 help='base URL, other than devserver, for update images.')
143 parser.add_option('--validate_factory_config', action="store_true", 145 parser.add_option('--validate_factory_config', action="store_true",
144 dest='validate_factory_config', 146 dest='validate_factory_config',
145 help='Validate factory config file, then exit.') 147 help='Validate factory config file, then exit.')
146 parser.set_usage(parser.format_help()) 148 parser.set_usage(parser.format_help())
147 (options, _) = parser.parse_args() 149 (options, _) = parser.parse_args()
(...skipping 15 matching lines...) Expand all
163 165
164 if options.clear_cache: 166 if options.clear_cache:
165 # Clear the cache and exit on error 167 # Clear the cache and exit on error
166 if os.system('sudo rm -rf %s' % cache_dir) != 0: 168 if os.system('sudo rm -rf %s' % cache_dir) != 0:
167 cherrypy.log('Failed to clear the cache with %s' % cmd, 169 cherrypy.log('Failed to clear the cache with %s' % cmd,
168 'DEVSERVER') 170 'DEVSERVER')
169 sys.exit(1) 171 sys.exit(1)
170 172
171 if os.path.exists(cache_dir): 173 if os.path.exists(cache_dir):
172 # Clear all but the last N cached updates 174 # Clear all but the last N cached updates
173 cmd = ('cd %s; ls -1tr | head --lines=-%d | xargs rm -rf' % 175 cmd = ('cd %s; ls -tr | head --lines=-%d | xargs rm -rf' %
174 (cache_dir, CACHED_ENTRIES)) 176 (cache_dir, CACHED_ENTRIES))
175 if os.system(cmd) != 0: 177 if os.system(cmd) != 0:
176 cherrypy.log('Failed to clean up old delta cache files with %s' % cmd, 178 cherrypy.log('Failed to clean up old delta cache files with %s' % cmd,
177 'DEVSERVER') 179 'DEVSERVER')
178 sys.exit(1) 180 sys.exit(1)
179 181
180 cherrypy.log('Source root is %s' % root_dir, 'DEVSERVER') 182 cherrypy.log('Source root is %s' % root_dir, 'DEVSERVER')
181 cherrypy.log('Serving from %s' % static_dir, 'DEVSERVER') 183 cherrypy.log('Serving from %s' % static_dir, 'DEVSERVER')
182 184
183 updater = autoupdate.Autoupdate( 185 updater = autoupdate.Autoupdate(
184 root_dir=root_dir, 186 root_dir=root_dir,
185 static_dir=static_dir, 187 static_dir=static_dir,
186 serve_only=serve_only, 188 serve_only=serve_only,
187 urlbase=options.urlbase, 189 urlbase=options.urlbase,
188 test_image=options.test_image, 190 test_image=options.test_image,
189 factory_config_path=options.factory_config, 191 factory_config_path=options.factory_config,
190 client_prefix=options.client_prefix, 192 client_prefix=options.client_prefix,
191 forced_image=options.image, 193 forced_image=options.image,
192 forced_payload=options.payload, 194 forced_payload=options.payload,
193 port=options.port, 195 port=options.port,
196 proxy_port=options.proxy_port,
194 src_image=options.src_image, 197 src_image=options.src_image,
195 vm=options.vm, 198 vm=options.vm,
196 board=options.board) 199 board=options.board)
197 200
198 # Sanity-check for use of validate_factory_config. 201 # Sanity-check for use of validate_factory_config.
199 if not options.factory_config and options.validate_factory_config: 202 if not options.factory_config and options.validate_factory_config:
200 parser.error('You need a factory_config to validate.') 203 parser.error('You need a factory_config to validate.')
201 204
202 if options.factory_config: 205 if options.factory_config:
203 updater.ImportFactoryConfigFile(options.factory_config, 206 updater.ImportFactoryConfigFile(options.factory_config,
204 options.validate_factory_config) 207 options.validate_factory_config)
205 # We don't run the dev server with this option. 208 # We don't run the dev server with this option.
206 if options.validate_factory_config: 209 if options.validate_factory_config:
207 sys.exit(0) 210 sys.exit(0)
208 elif options.pregenerate_update: 211 elif options.pregenerate_update:
209 if not updater.PreGenerateUpdate(): 212 if not updater.PreGenerateUpdate():
210 sys.exit(1) 213 sys.exit(1)
211 214
212 # If the command line requested after setup, it's time to do it. 215 # If the command line requested after setup, it's time to do it.
213 if not options.exit: 216 if not options.exit:
214 cherrypy.quickstart(DevServerRoot(), config=_GetConfig(options)) 217 cherrypy.quickstart(DevServerRoot(), config=_GetConfig(options))
OLDNEW
« no previous file with comments | « autoupdate_unittest.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698