| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright 2015 The LUCI Authors. All rights reserved. | 2 # Copyright 2015 The LUCI Authors. All rights reserved. |
| 3 # Use of this source code is governed under the Apache License, Version 2.0 | 3 # Use of this source code is governed under the Apache License, Version 2.0 |
| 4 # that can be found in the LICENSE file. | 4 # that can be found in the LICENSE file. |
| 5 | 5 |
| 6 """Tool to interact with recipe repositories. | 6 """Tool to interact with recipe repositories. |
| 7 | 7 |
| 8 This tool operates on the nearest ancestor directory containing an | 8 This tool operates on the nearest ancestor directory containing an |
| 9 infra/config/recipes.cfg. | 9 infra/config/recipes.cfg. |
| 10 """ | 10 """ |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 recipe_result.result['recipe_result'], indent=2) | 60 recipe_result.result['recipe_result'], indent=2) |
| 61 if result_filename: | 61 if result_filename: |
| 62 with open(result_filename, 'w') as f: | 62 with open(result_filename, 'w') as f: |
| 63 f.write(result_string) | 63 f.write(result_string) |
| 64 with stream_engine.new_step_stream('recipe result') as s: | 64 with stream_engine.new_step_stream('recipe result') as s: |
| 65 with s.new_log_stream('result') as l: | 65 with s.new_log_stream('result') as l: |
| 66 l.write_split(result_string) | 66 l.write_split(result_string) |
| 67 | 67 |
| 68 if 'traceback' in recipe_result.result: | 68 if 'traceback' in recipe_result.result: |
| 69 with stream_engine.new_step_stream('Uncaught Exception') as s: | 69 with stream_engine.new_step_stream('Uncaught Exception') as s: |
| 70 s.set_step_status('EXCEPTION') | |
| 71 with s.new_log_stream('exception') as l: | 70 with s.new_log_stream('exception') as l: |
| 72 for line in recipe_result.result['traceback']: | 71 for line in recipe_result.result['traceback']: |
| 73 l.write_line(line) | 72 l.write_line(line) |
| 74 | 73 |
| 75 if 'reason' in recipe_result.result: | 74 if 'reason' in recipe_result.result: |
| 76 with stream_engine.new_step_stream('Failure reason') as s: | 75 with stream_engine.new_step_stream('Failure reason') as s: |
| 77 s.set_step_status('FAILURE') | |
| 78 with s.new_log_stream('reason') as l: | 76 with s.new_log_stream('reason') as l: |
| 79 for line in recipe_result.result['reason'].splitlines(): | 77 for line in recipe_result.result['reason'].splitlines(): |
| 80 l.write_line(line) | 78 l.write_line(line) |
| 81 | 79 |
| 82 if 'status_code' in recipe_result.result: | 80 if 'status_code' in recipe_result.result: |
| 83 return recipe_result.result['status_code'] | 81 return recipe_result.result['status_code'] |
| 84 else: | 82 else: |
| 85 return 0 | 83 return 0 |
| 86 | 84 |
| 87 | 85 |
| (...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 463 ret = main() | 461 ret = main() |
| 464 if not isinstance(ret, int): | 462 if not isinstance(ret, int): |
| 465 if ret is None: | 463 if ret is None: |
| 466 ret = 0 | 464 ret = 0 |
| 467 else: | 465 else: |
| 468 print >> sys.stderr, ret | 466 print >> sys.stderr, ret |
| 469 ret = 1 | 467 ret = 1 |
| 470 sys.stdout.flush() | 468 sys.stdout.flush() |
| 471 sys.stderr.flush() | 469 sys.stderr.flush() |
| 472 os._exit(ret) | 470 os._exit(ret) |
| OLD | NEW |