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 """Step is the primary API for running steps (external programs, scripts, | 5 """Step is the primary API for running steps (external programs, scripts, |
6 etc.).""" | 6 etc.).""" |
7 | 7 |
8 import contextlib | 8 import contextlib |
9 import copy | |
10 import types | 9 import types |
11 | 10 |
12 from recipe_engine import recipe_api | 11 from recipe_engine import recipe_api |
13 from recipe_engine.config_types import Path | 12 from recipe_engine.config_types import Path |
14 from recipe_engine.util import Placeholder | 13 from recipe_engine.util import Placeholder |
15 | 14 |
16 | 15 |
17 # Inherit from RecipeApiPlain because the only thing which is a step is | 16 # Inherit from RecipeApiPlain because the only thing which is a step is |
18 # run_from_dict() | 17 # run_from_dict() |
19 class StepApi(recipe_api.RecipeApiPlain): | 18 class StepApi(recipe_api.RecipeApiPlain): |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
203 return self.step_client.run_step(self.step_client.StepConfig( | 202 return self.step_client.run_step(self.step_client.StepConfig( |
204 name=full_name, | 203 name=full_name, |
205 base_name=full_name or name, | 204 base_name=full_name or name, |
206 cmd=cmd, | 205 cmd=cmd, |
207 cwd=cwd, | 206 cwd=cwd, |
208 env=self.m.context.env, | 207 env=self.m.context.env, |
209 env_prefixes=self.step_client.StepConfig.EnvPrefix( | 208 env_prefixes=self.step_client.StepConfig.EnvPrefix( |
210 prefixes=env_prefixes, | 209 prefixes=env_prefixes, |
211 pathsep=self.m.path.pathsep, | 210 pathsep=self.m.path.pathsep, |
212 ), | 211 ), |
| 212 luci_context=self.m.context.luci_context, |
213 allow_subannotations=bool(allow_subannotations), | 213 allow_subannotations=bool(allow_subannotations), |
214 trigger_specs=[self._make_trigger_spec(trig) | 214 trigger_specs=[self._make_trigger_spec(trig) |
215 for trig in (trigger_specs or ())], | 215 for trig in (trigger_specs or ())], |
216 timeout=timeout, | 216 timeout=timeout, |
217 infra_step=self.m.context.infra_step or bool(infra_step), | 217 infra_step=self.m.context.infra_step or bool(infra_step), |
218 stdout=stdout, | 218 stdout=stdout, |
219 stderr=stderr, | 219 stderr=stderr, |
220 stdin=stdin, | 220 stdin=stdin, |
221 ok_ret=ok_ret, | 221 ok_ret=ok_ret, |
222 step_test_data=step_test_data, | 222 step_test_data=step_test_data, |
223 nest_level=self.m.context.nest_level, | 223 nest_level=self.m.context.nest_level, |
224 )) | 224 )) |
225 | 225 |
226 def _make_trigger_spec(self, trig): | 226 def _make_trigger_spec(self, trig): |
227 buildbot_changes = trig.get('buildbot_changes') | 227 buildbot_changes = trig.get('buildbot_changes') |
228 assert isinstance(buildbot_changes, (types.NoneType, list)) | 228 assert isinstance(buildbot_changes, (types.NoneType, list)) |
229 | 229 |
230 critical = trig.get('critical') | 230 critical = trig.get('critical') |
231 return self.step_client.TriggerSpec( | 231 return self.step_client.TriggerSpec( |
232 bucket=trig.get('bucket'), | 232 bucket=trig.get('bucket'), |
233 builder_name=trig['builder_name'], | 233 builder_name=trig['builder_name'], |
234 properties=trig.get('properties'), | 234 properties=trig.get('properties'), |
235 buildbot_changes=buildbot_changes, | 235 buildbot_changes=buildbot_changes, |
236 tags=trig.get('tags'), | 236 tags=trig.get('tags'), |
237 critical=bool(critical) if critical is not None else (True), | 237 critical=bool(critical) if critical is not None else (True), |
238 ) | 238 ) |
OLD | NEW |