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

Side by Side Diff: recipes.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/unittests/run_test.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 result, including_default_value_fields=True)) 151 result, including_default_value_fields=True))
152 152
153 if result.json_result: 153 if result.json_result:
154 with stream_engine.make_step_stream('recipe result') as s: 154 with stream_engine.make_step_stream('recipe result') as s:
155 with s.new_log_stream('result') as l: 155 with s.new_log_stream('result') as l:
156 l.write_split(result.json_result) 156 l.write_split(result.json_result)
157 157
158 if result.HasField('failure'): 158 if result.HasField('failure'):
159 f = result.failure 159 f = result.failure
160 if f.HasField('exception'): 160 if f.HasField('exception'):
161 with stream_engine.make_step_stream('Uncaught Exception') as s: 161 with stream_engine.make_step_stream(
162 'Uncaught Exception in recipe engine') as s:
162 s.add_step_text(f.human_reason) 163 s.add_step_text(f.human_reason)
163 with s.new_log_stream('exception') as l: 164 with s.new_log_stream('exception') as l:
164 for line in f.exception.traceback: 165 for line in f.exception.traceback:
166 l.write_line(line)
167 elif f.HasField('recipe_exception'):
168 with stream_engine.make_step_stream('Uncaught Exception in recipe') as s:
169 s.add_step_text(f.human_reason)
170 with s.new_log_stream('exception') as l:
171 for line in f.exception.traceback:
165 l.write_line(line) 172 l.write_line(line)
166 # TODO(martiniss): Remove this code once calling code handles these states 173 # TODO(martiniss): Remove this code once calling code handles these states
167 elif f.HasField('timeout'): 174 elif f.HasField('timeout'):
168 with stream_engine.make_step_stream('Step Timed Out') as s: 175 with stream_engine.make_step_stream('Step Timed Out') as s:
169 with s.new_log_stream('timeout_s') as l: 176 with s.new_log_stream('timeout_s') as l:
170 l.write_line(f.timeout.timeout_s) 177 l.write_line(f.timeout.timeout_s)
171 elif f.HasField('step_data'): 178 elif f.HasField('step_data'):
172 with stream_engine.make_step_stream('Invalid Step Data Access') as s: 179 with stream_engine.make_step_stream('Invalid Step Data Access') as s:
173 with s.new_log_stream('step') as l: 180 with s.new_log_stream('step') as l:
174 l.write_line(f.step_data.step) 181 l.write_line(f.step_data.step)
(...skipping 587 matching lines...) Expand 10 before | Expand all | Expand 10 after
762 769
763 if not isinstance(ret, int): 770 if not isinstance(ret, int):
764 if ret is None: 771 if ret is None:
765 ret = 0 772 ret = 0
766 else: 773 else:
767 print >> sys.stderr, ret 774 print >> sys.stderr, ret
768 ret = 1 775 ret = 1
769 sys.stdout.flush() 776 sys.stdout.flush()
770 sys.stderr.flush() 777 sys.stderr.flush()
771 os._exit(ret) 778 os._exit(ret)
OLDNEW
« no previous file with comments | « recipe_engine/unittests/run_test.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698