OLD | NEW |
---|---|
1 #!/usr/bin/python | 1 #!/usr/bin/python |
2 # Copyright (c) 2009 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2009 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 """Client-side script to send a try job to the try server. It communicates to | 5 """Client-side script to send a try job to the try server. It communicates to |
6 the try server by either writting to a svn repository or by directly connecting | 6 the try server by either writting to a svn repository or by directly connecting |
7 to the server by HTTP. | 7 to the server by HTTP. |
8 """ | 8 """ |
9 | 9 |
10 import datetime | 10 import datetime |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
194 values['patch'] = options.diff | 194 values['patch'] = options.diff |
195 | 195 |
196 url = 'http://%s:%s/send_try_patch' % (options.host, options.port) | 196 url = 'http://%s:%s/send_try_patch' % (options.host, options.port) |
197 proxies = None | 197 proxies = None |
198 if options.proxy: | 198 if options.proxy: |
199 if options.proxy.lower() == 'none': | 199 if options.proxy.lower() == 'none': |
200 # Effectively disable HTTP_PROXY or Internet settings proxy setup. | 200 # Effectively disable HTTP_PROXY or Internet settings proxy setup. |
201 proxies = {} | 201 proxies = {} |
202 else: | 202 else: |
203 proxies = {'http': options.proxy, 'https': options.proxy} | 203 proxies = {'http': options.proxy, 'https': options.proxy} |
204 | |
205 if options.dry_run: | |
206 # Last minute fake. | |
207 for (k,v) in values.iteritems(): | |
208 if k != 'patch': | |
209 print("%s=%s" % (k,v)) | |
210 print values['patch'] | |
211 return | |
212 | |
204 try: | 213 try: |
205 connection = urllib.urlopen(url, urllib.urlencode(values), proxies=proxies) | 214 connection = urllib.urlopen(url, urllib.urlencode(values), proxies=proxies) |
206 except IOError, e: | 215 except IOError, e: |
207 if (values.get('bot') and len(e.args) > 2 and | 216 if (values.get('bot') and len(e.args) > 2 and |
208 e.args[2] == 'got a bad status line'): | 217 e.args[2] == 'got a bad status line'): |
209 raise NoTryServerAccess('%s is unaccessible. Bad --bot argument?' % url) | 218 raise NoTryServerAccess('%s is unaccessible. Bad --bot argument?' % url) |
210 else: | 219 else: |
211 raise NoTryServerAccess('%s is unaccessible. Reason: %s' % (url, | 220 raise NoTryServerAccess('%s is unaccessible. Reason: %s' % (url, |
212 str(e.args))) | 221 str(e.args))) |
213 if not connection: | 222 if not connection: |
214 raise NoTryServerAccess('%s is unaccessible.' % url) | 223 raise NoTryServerAccess('%s is unaccessible.' % url) |
215 if connection.read() != 'OK': | 224 if connection.read() != 'OK': |
216 raise NoTryServerAccess('%s is unaccessible.' % url) | 225 raise NoTryServerAccess('%s is unaccessible.' % url) |
217 | 226 |
218 | 227 |
219 def _SendChangeSVN(options): | 228 def _SendChangeSVN(options): |
220 """Send a change to the try server by committing a diff file on a subversion | 229 """Send a change to the try server by committing a diff file on a subversion |
221 server.""" | 230 server.""" |
222 if not options.svn_repo: | 231 if not options.svn_repo: |
223 raise NoTryServerAccess('Please use the --svn_repo option to specify the' | 232 raise NoTryServerAccess('Please use the --svn_repo option to specify the' |
224 ' try server svn repository to connect to.') | 233 ' try server svn repository to connect to.') |
225 | 234 |
226 values = _ParseSendChangeOptions(options) | 235 values = _ParseSendChangeOptions(options) |
227 description = '' | 236 description = '' |
228 for (k,v) in values.iteritems(): | 237 for (k,v) in values.iteritems(): |
229 description += "%s=%s\n" % (k,v) | 238 description += "%s=%s\n" % (k,v) |
230 | 239 |
240 if options.dry_run: | |
241 # Last minute fake. | |
242 print str(descriptions) | |
243 print diff | |
244 return | |
245 | |
231 # Do an empty checkout. | 246 # Do an empty checkout. |
232 temp_dir = tempfile.mkdtemp() | 247 temp_dir = tempfile.mkdtemp() |
233 temp_file = tempfile.NamedTemporaryFile() | 248 temp_file = tempfile.NamedTemporaryFile() |
234 try: | 249 try: |
235 try: | 250 try: |
236 command = ['svn', 'checkout', '--depth', 'empty', '-q', | 251 command = ['svn', 'checkout', '--depth', 'empty', '-q', |
237 options.svn_repo, temp_dir] | 252 options.svn_repo, temp_dir] |
238 if options.email: | 253 if options.email: |
239 command.extend(['--username', options.email]) | 254 command.extend(['--username', options.email]) |
240 gclient_utils.CheckCall(command) | 255 gclient_utils.CheckCall(command) |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
330 help="Email address where to send the results. Use either " | 345 help="Email address where to send the results. Use either " |
331 "the TRYBOT_RESULTS_EMAIL_ADDRESS environment " | 346 "the TRYBOT_RESULTS_EMAIL_ADDRESS environment " |
332 "variable or EMAIL_ADDRESS to set the email address " | 347 "variable or EMAIL_ADDRESS to set the email address " |
333 "the try bots report results to [default: %default]") | 348 "the try bots report results to [default: %default]") |
334 group.add_option("-n", "--name", | 349 group.add_option("-n", "--name", |
335 help="Descriptive name of the try job") | 350 help="Descriptive name of the try job") |
336 group.add_option("--issue", type='int', | 351 group.add_option("--issue", type='int', |
337 help="Update rietveld issue try job status") | 352 help="Update rietveld issue try job status") |
338 group.add_option("--patchset", type='int', | 353 group.add_option("--patchset", type='int', |
339 help="Update rietveld issue try job status") | 354 help="Update rietveld issue try job status") |
355 group.add_option("--dry_run", action='store_true', | |
356 help="Just prints the diff and quits") | |
340 parser.add_option_group(group) | 357 parser.add_option_group(group) |
341 | 358 |
342 group = optparse.OptionGroup(parser, "Try job options") | 359 group = optparse.OptionGroup(parser, "Try job options") |
343 group.add_option("-b", "--bot", action="append", | 360 group.add_option("-b", "--bot", action="append", |
344 help="Only use specifics build slaves, ex: '--bot win' to " | 361 help="Only use specifics build slaves, ex: '--bot win' to " |
345 "run the try job only on the 'win' slave; see the try " | 362 "run the try job only on the 'win' slave; see the try " |
346 "server waterfall for the slave's name") | 363 "server waterfall for the slave's name") |
347 group.add_option("-r", "--revision", | 364 group.add_option("-r", "--revision", |
348 help="Revision to use for the try job; default: the " | 365 help="Revision to use for the try job; default: the " |
349 "revision will be determined by the try server; see " | 366 "revision will be determined by the try server; see " |
350 "its waterfall for more info") | 367 "its waterfall for more info") |
351 group.add_option("-c", "--clobber", action="store_true", | 368 group.add_option("-c", "--clobber", action="store_true", |
352 help="Force a clobber before building; e.g. don't do an " | 369 help="Force a clobber before building; e.g. don't do an " |
353 "incremental build") | 370 "incremental build") |
354 # TODO(maruel): help="Select a specific configuration, usually 'debug' or " | 371 # TODO(maruel): help="Select a specific configuration, usually 'debug' or " |
355 # "'release'" | 372 # "'release'" |
356 group.add_option("--target", help=optparse.SUPPRESS_HELP) | 373 group.add_option("--target", help=optparse.SUPPRESS_HELP) |
357 | 374 |
358 group.add_option("--project", | 375 group.add_option("--project", |
359 help="Override which project to use") | 376 help="Override which project to use. Projects are defined " |
377 "server-side to define what default bot set to use") | |
360 | 378 |
361 # Override the list of tests to run, use multiple times to list many tests | 379 # Override the list of tests to run, use multiple times to list many tests |
362 # (or comma separated) | 380 # (or comma separated) |
363 group.add_option("-t", "--tests", action="append", | 381 group.add_option("-t", "--tests", action="append", |
364 help=optparse.SUPPRESS_HELP) | 382 help=optparse.SUPPRESS_HELP) |
365 parser.add_option_group(group) | 383 parser.add_option_group(group) |
366 | 384 |
367 group = optparse.OptionGroup(parser, "Patch to run") | 385 group = optparse.OptionGroup(parser, "Patch to run") |
368 group.add_option("-f", "--file", default=file_list, dest="files", | 386 group.add_option("-f", "--file", default=file_list, dest="files", |
369 metavar="FILE", action="append", | 387 metavar="FILE", action="append", |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
466 options.name = 'Unnamed' | 484 options.name = 'Unnamed' |
467 print('Note: use --name NAME to change the try job name.') | 485 print('Note: use --name NAME to change the try job name.') |
468 if not options.email: | 486 if not options.email: |
469 print('Warning: TRYBOT_RESULTS_EMAIL_ADDRESS is not set. Try server ' | 487 print('Warning: TRYBOT_RESULTS_EMAIL_ADDRESS is not set. Try server ' |
470 'results might\ngo to: %s@google.com.\n' % options.user) | 488 'results might\ngo to: %s@google.com.\n' % options.user) |
471 else: | 489 else: |
472 print('Results will be emailed to: ' + options.email) | 490 print('Results will be emailed to: ' + options.email) |
473 | 491 |
474 # Send the patch. | 492 # Send the patch. |
475 options.send_patch(options) | 493 options.send_patch(options) |
476 print 'Patch \'%s\' sent to try server: %s' % (options.name, | 494 if not options.dry_run: |
bradn
2009/12/22 18:05:54
Might be worth moving this up into the http/svn ha
| |
477 ', '.join(options.bot)) | 495 print 'Patch \'%s\' sent to try server: %s' % (options.name, |
496 ', '.join(options.bot)) | |
478 except (InvalidScript, NoTryServerAccess), e: | 497 except (InvalidScript, NoTryServerAccess), e: |
479 if swallow_exception: | 498 if swallow_exception: |
480 return 1 | 499 return 1 |
481 print e | 500 print e |
482 return 1 | 501 return 1 |
483 return 0 | 502 return 0 |
484 | 503 |
485 | 504 |
486 if __name__ == "__main__": | 505 if __name__ == "__main__": |
487 sys.exit(TryChange(None, [], False)) | 506 sys.exit(TryChange(None, [], False)) |
OLD | NEW |