OLD | NEW |
---|---|
1 # Copyright 2013 The LUCI Authors. All rights reserved. | 1 # Copyright 2013 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 import contextlib | 5 import contextlib |
6 import datetime | 6 import datetime |
7 | 7 |
8 from recipe_engine import recipe_api | 8 from recipe_engine import recipe_api |
9 | 9 |
10 | 10 |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
70 new_step_text = result.json.output['step_text'] | 70 new_step_text = result.json.output['step_text'] |
71 api.step.active_result.presentation.step_text = new_step_text | 71 api.step.active_result.presentation.step_text = new_step_text |
72 """ | 72 """ |
73 return self.step_client.previous_step_result() | 73 return self.step_client.previous_step_result() |
74 | 74 |
75 @property | 75 @property |
76 def context(self): | 76 def context(self): |
77 """ See recipe_api.py for docs. """ | 77 """ See recipe_api.py for docs. """ |
78 return recipe_api.context | 78 return recipe_api.context |
79 | 79 |
80 def get_context(self): | |
81 return recipe_api._STEP_CONTEXT | |
iannucci
2017/01/31 22:12:51
this should return a copy of the step context (unl
iannucci
2017/01/31 22:14:49
This is also confusing with the previous property.
| |
82 | |
80 @contextlib.contextmanager | 83 @contextlib.contextmanager |
81 def nest(self, name): | 84 def nest(self, name): |
82 """Nest is the high-level interface to annotated hierarchical steps. | 85 """Nest is the high-level interface to annotated hierarchical steps. |
83 | 86 |
84 Calling | 87 Calling |
85 | 88 |
86 with api.step.nest(<name>): | 89 with api.step.nest(<name>): |
87 ... | 90 ... |
88 | 91 |
89 will generate a dummy step and implicitly create a new context (as | 92 will generate a dummy step and implicitly create a new context (as |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
165 | 168 |
166 if cmd is not None: | 169 if cmd is not None: |
167 command = list(wrapper) | 170 command = list(wrapper) |
168 command += cmd | 171 command += cmd |
169 kwargs['cmd'] = command | 172 kwargs['cmd'] = command |
170 | 173 |
171 kwargs['timeout'] = timeout | 174 kwargs['timeout'] = timeout |
172 kwargs['ok_ret'] = ok_ret | 175 kwargs['ok_ret'] = ok_ret |
173 | 176 |
174 # Obtain information from composite step parent. | 177 # Obtain information from composite step parent. |
175 compositor = recipe_api._STEP_CONTEXT | 178 compositor = self.get_context() |
176 | 179 |
177 # Calculate our full step name. If a step already has that name, add an | 180 # Calculate our full step name. If a step already has that name, add an |
178 # index to the end of it. | 181 # index to the end of it. |
179 # | 182 # |
180 # Note that another step could exist with that index already added to it | 183 # Note that another step could exist with that index already added to it |
181 # by the user. If this happens, we'll continue appending indexes until we | 184 # by the user. If this happens, we'll continue appending indexes until we |
182 # have a unique step name. | 185 # have a unique step name. |
183 while True: | 186 while True: |
184 full_name = compositor.get_with_context('name', name) | 187 full_name = compositor.get_with_context('name', name) |
185 if full_name not in self._seen_steps: | 188 if full_name not in self._seen_steps: |
(...skipping 14 matching lines...) Expand all Loading... | |
200 kwargs['base_name'] = name | 203 kwargs['base_name'] = name |
201 | 204 |
202 schema = self.make_config() | 205 schema = self.make_config() |
203 schema.set_val(kwargs) | 206 schema.set_val(kwargs) |
204 return self.run_from_dict(schema.as_jsonish()) | 207 return self.run_from_dict(schema.as_jsonish()) |
205 | 208 |
206 # TODO(martiniss) delete, and make generator_script use **kwargs on step() | 209 # TODO(martiniss) delete, and make generator_script use **kwargs on step() |
207 @recipe_api.composite_step | 210 @recipe_api.composite_step |
208 def run_from_dict(self, dct): | 211 def run_from_dict(self, dct): |
209 return self.step_client.run_step(dct) | 212 return self.step_client.run_step(dct) |
OLD | NEW |