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') |
70 with s.new_log_stream('exception') as l: | 71 with s.new_log_stream('exception') as l: |
71 for line in recipe_result.result['traceback']: | 72 for line in recipe_result.result['traceback']: |
72 l.write_line(line) | 73 l.write_line(line) |
73 | 74 |
74 if 'reason' in recipe_result.result: | 75 if 'reason' in recipe_result.result: |
75 with stream_engine.new_step_stream('Failure reason') as s: | 76 with stream_engine.new_step_stream('Failure reason') as s: |
| 77 s.set_step_status('FAILURE') |
76 with s.new_log_stream('reason') as l: | 78 with s.new_log_stream('reason') as l: |
77 for line in recipe_result.result['reason'].splitlines(): | 79 for line in recipe_result.result['reason'].splitlines(): |
78 l.write_line(line) | 80 l.write_line(line) |
79 | 81 |
80 if 'status_code' in recipe_result.result: | 82 if 'status_code' in recipe_result.result: |
81 return recipe_result.result['status_code'] | 83 return recipe_result.result['status_code'] |
82 else: | 84 else: |
83 return 0 | 85 return 0 |
84 | 86 |
85 | 87 |
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
461 ret = main() | 463 ret = main() |
462 if not isinstance(ret, int): | 464 if not isinstance(ret, int): |
463 if ret is None: | 465 if ret is None: |
464 ret = 0 | 466 ret = 0 |
465 else: | 467 else: |
466 print >> sys.stderr, ret | 468 print >> sys.stderr, ret |
467 ret = 1 | 469 ret = 1 |
468 sys.stdout.flush() | 470 sys.stdout.flush() |
469 sys.stderr.flush() | 471 sys.stderr.flush() |
470 os._exit(ret) | 472 os._exit(ret) |
OLD | NEW |