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

Side by Side Diff: recipe_engine/run.py

Issue 2798053003: introduce recipe_exception in result.proto (Closed)
Patch Set: Created 3 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 | « recipe_engine/result_pb2.py ('k') | recipe_engine/step_runner.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 2016 The LUCI Authors. All rights reserved. 1 # Copyright 2016 The LUCI Authors. All rights reserved.
2 # Use of this source code is governed under the Apache License, Version 2.0 2 # Use of this source code is governed under the Apache License, Version 2.0
3 # that can be found in the LICENSE file. 3 # that can be found in the LICENSE file.
4 4
5 """Entry point for fully-annotated builds. 5 """Entry point for fully-annotated builds.
6 6
7 This script is part of the effort to move all builds to annotator-based 7 This script is part of the effort to move all builds to annotator-based
8 systems. Any builder configured to use the AnnotatorFactory.BaseFactory() 8 systems. Any builder configured to use the AnnotatorFactory.BaseFactory()
9 found in scripts/master/factory/annotator_factory.py executes a single 9 found in scripts/master/factory/annotator_factory.py executes a single
10 AddAnnotatedScript step. That step (found in annotator_commands.py) calls 10 AddAnnotatedScript step. That step (found in annotator_commands.py) calls
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after
328 result.failure.human_reason = ex.message 328 result.failure.human_reason = ex.message
329 result.failure.step_data.step = f.name 329 result.failure.step_data.step = f.name
330 330
331 # Let the step runner run_context decide what to do. 331 # Let the step runner run_context decide what to do.
332 raise 332 raise
333 333
334 except subprocess42.TimeoutExpired as ex: 334 except subprocess42.TimeoutExpired as ex:
335 result.failure.human_reason = "Step time out: %r" % ex 335 result.failure.human_reason = "Step time out: %r" % ex
336 result.failure.timeout.timeout_s = ex.timeout 336 result.failure.timeout.timeout_s = ex.timeout
337 337
338 except loader.RecipeException as ex:
339 result.failure.human_reason = "Uncaught Exception: %r" % ex
340 result.failure.recipe_exception.traceback[:] = [
341 line.rstrip('\n')
342 for line in traceback.format_exception(
343 type(ex.inner_exception), ex.inner_exception, ex.traceback)
344 ]
345
346 # Let the step runner run_context decide what to do.
347 raise type(ex.inner_exception), ex.inner_exception, ex.traceback
348
338 except Exception as ex: 349 except Exception as ex:
339 result.failure.human_reason = "Uncaught Exception: %r" % ex 350 result.failure.human_reason = "Uncaught Exception: %r" % ex
340 result.failure.exception.traceback[:] = ( 351 result.failure.exception.traceback[:] = (
341 traceback.format_exc().splitlines()) 352 traceback.format_exc().splitlines())
342 353
343 # Let the step runner run_context decide what to do. 354 # Let the step runner run_context decide what to do.
344 raise 355 raise
345 356
346 return result 357 return result
347 358
(...skipping 22 matching lines...) Expand all
370 "status_code": -1 381 "status_code": -1
371 } 382 }
372 383
373 raise 384 raise
374 except subprocess42.TimeoutExpired as ex: 385 except subprocess42.TimeoutExpired as ex:
375 result = { 386 result = {
376 "reason": "Step time out: %r" % ex, 387 "reason": "Step time out: %r" % ex,
377 "traceback": traceback.format_exc().splitlines(), 388 "traceback": traceback.format_exc().splitlines(),
378 "status_code": -1 389 "status_code": -1
379 } 390 }
391 except loader.RecipeException as ex:
392 result = {
393 "reason": "Uncaught Exception: %r" % ex.inner_exception,
394 "traceback": [
395 line.rstrip('\n')
396 for line in traceback.format_exception(
397 type(ex.inner_exception), ex.inner_exception, ex.traceback)
398 ],
399 "status_code": -1
400 }
401 assert all('\n' not in line for line in result["traceback"])
402 raise type(ex.inner_exception), ex.inner_exception, ex.traceback
380 except Exception as ex: 403 except Exception as ex:
381 result = { 404 result = {
382 "reason": "Uncaught Exception: %r" % ex, 405 "reason": "Uncaught Exception: %r" % ex,
383 "traceback": traceback.format_exc().splitlines(), 406 "traceback": traceback.format_exc().splitlines(),
384 "status_code": -1 407 "status_code": -1
385 } 408 }
386
387 raise 409 raise
388 410
389 result['name'] = '$result' 411 result['name'] = '$result'
390 return RecipeResult(result) 412 return RecipeResult(result)
391 413
392 def depend_on(self, recipe, properties, distributor=None): 414 def depend_on(self, recipe, properties, distributor=None):
393 return self.depend_on_multi( 415 return self.depend_on_multi(
394 ((recipe, properties),), distributor=distributor)[0] 416 ((recipe, properties),), distributor=distributor)[0]
395 417
396 def depend_on_multi(self, dependencies, distributor=None): 418 def depend_on_multi(self, dependencies, distributor=None):
(...skipping 18 matching lines...) Expand all
415 results.append( 437 results.append(
416 loader._invoke_with_properties( 438 loader._invoke_with_properties(
417 run_recipe, properties, recipe_script.PROPERTIES, 439 run_recipe, properties, recipe_script.PROPERTIES,
418 properties.keys())) 440 properties.keys()))
419 except TypeError as e: 441 except TypeError as e:
420 raise TypeError( 442 raise TypeError(
421 "Got %r while trying to call recipe %s with properties %r" % ( 443 "Got %r while trying to call recipe %s with properties %r" % (
422 e, recipe, properties)) 444 e, recipe, properties))
423 445
424 return results 446 return results
OLDNEW
« no previous file with comments | « recipe_engine/result_pb2.py ('k') | recipe_engine/step_runner.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698