| 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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 lint_test.main(universe_view, args.whitelist or []) | 57 lint_test.main(universe_view, args.whitelist or []) |
| 58 | 58 |
| 59 | 59 |
| 60 def handle_recipe_return(recipe_result, result_filename, stream_engine): | 60 def handle_recipe_return(recipe_result, result_filename, stream_engine): |
| 61 if 'recipe_result' in recipe_result.result: | 61 if 'recipe_result' in recipe_result.result: |
| 62 result_string = json.dumps( | 62 result_string = json.dumps( |
| 63 recipe_result.result['recipe_result'], indent=2) | 63 recipe_result.result['recipe_result'], indent=2) |
| 64 if result_filename: | 64 if result_filename: |
| 65 with open(result_filename, 'w') as f: | 65 with open(result_filename, 'w') as f: |
| 66 f.write(result_string) | 66 f.write(result_string) |
| 67 with stream_engine.new_step_stream('recipe result') as s: | 67 with stream_engine.make_step_stream('recipe result') as s: |
| 68 with s.new_log_stream('result') as l: | 68 with s.new_log_stream('result') as l: |
| 69 l.write_split(result_string) | 69 l.write_split(result_string) |
| 70 | 70 |
| 71 if 'traceback' in recipe_result.result: | 71 if 'traceback' in recipe_result.result: |
| 72 with stream_engine.new_step_stream('Uncaught Exception') as s: | 72 with stream_engine.make_step_stream('Uncaught Exception') as s: |
| 73 with s.new_log_stream('exception') as l: | 73 with s.new_log_stream('exception') as l: |
| 74 for line in recipe_result.result['traceback']: | 74 for line in recipe_result.result['traceback']: |
| 75 l.write_line(line) | 75 l.write_line(line) |
| 76 | 76 |
| 77 if 'reason' in recipe_result.result: | 77 if 'reason' in recipe_result.result: |
| 78 with stream_engine.new_step_stream('Failure reason') as s: | 78 with stream_engine.make_step_stream('Failure reason') as s: |
| 79 with s.new_log_stream('reason') as l: | 79 with s.new_log_stream('reason') as l: |
| 80 for line in recipe_result.result['reason'].splitlines(): | 80 for line in recipe_result.result['reason'].splitlines(): |
| 81 l.write_line(line) | 81 l.write_line(line) |
| 82 | 82 |
| 83 if 'status_code' in recipe_result.result: | 83 if 'status_code' in recipe_result.result: |
| 84 return recipe_result.result['status_code'] | 84 return recipe_result.result['status_code'] |
| 85 else: | 85 else: |
| 86 return 0 | 86 return 0 |
| 87 | 87 |
| 88 | 88 |
| (...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 567 ret = main() | 567 ret = main() |
| 568 if not isinstance(ret, int): | 568 if not isinstance(ret, int): |
| 569 if ret is None: | 569 if ret is None: |
| 570 ret = 0 | 570 ret = 0 |
| 571 else: | 571 else: |
| 572 print >> sys.stderr, ret | 572 print >> sys.stderr, ret |
| 573 ret = 1 | 573 ret = 1 |
| 574 sys.stdout.flush() | 574 sys.stdout.flush() |
| 575 sys.stderr.flush() | 575 sys.stderr.flush() |
| 576 os._exit(ret) | 576 os._exit(ret) |
| OLD | NEW |