| 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 | 6 |
| 7 from recipe_engine import recipe_api | 7 from recipe_engine import recipe_api |
| 8 | 8 |
| 9 | 9 |
| 10 # Inherit from RecipeApiPlain because the only thing which is a step is | 10 # Inherit from RecipeApiPlain because the only thing which is a step is |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 command += cmd | 130 command += cmd |
| 131 kwargs['cmd'] = command | 131 kwargs['cmd'] = command |
| 132 | 132 |
| 133 kwargs['timeout'] = timeout | 133 kwargs['timeout'] = timeout |
| 134 kwargs['ok_ret'] = ok_ret | 134 kwargs['ok_ret'] = ok_ret |
| 135 kwargs['infra_step'] = bool(infra_step) | 135 kwargs['infra_step'] = bool(infra_step) |
| 136 | 136 |
| 137 # Obtain information from composite step parent. | 137 # Obtain information from composite step parent. |
| 138 compositor = recipe_api._STEP_CONTEXT | 138 compositor = recipe_api._STEP_CONTEXT |
| 139 name = compositor.get_with_context('name', name) | 139 name = compositor.get_with_context('name', name) |
| 140 if 'cwd' not in kwargs: |
| 141 kwargs['cwd'] = compositor.get('cwd') |
| 140 kwargs['env'] = compositor.get_with_context('env', kwargs.get('env', {})) | 142 kwargs['env'] = compositor.get_with_context('env', kwargs.get('env', {})) |
| 141 kwargs['step_nest_level'] = compositor.get_with_context('nest_level', 0) | 143 kwargs['step_nest_level'] = compositor.get_with_context('nest_level', 0) |
| 142 | 144 |
| 143 # Disambiguate repeated names | 145 # Disambiguate repeated names |
| 144 step_count = self._step_names.setdefault(name, 0) + 1 | 146 step_count = self._step_names.setdefault(name, 0) + 1 |
| 145 self._step_names[name] = step_count | 147 self._step_names[name] = step_count |
| 146 if step_count > 1: | 148 if step_count > 1: |
| 147 name = "%s (%d)" % (name, step_count) | 149 name = "%s (%d)" % (name, step_count) |
| 148 kwargs['name'] = name | 150 kwargs['name'] = name |
| 149 | 151 |
| 150 schema = self.make_config() | 152 schema = self.make_config() |
| 151 schema.set_val(kwargs) | 153 schema.set_val(kwargs) |
| 152 return self.run_from_dict(self._engine.create_step(schema)) | 154 return self.run_from_dict(self._engine.create_step(schema)) |
| 153 | 155 |
| 154 # TODO(martiniss) delete, and make generator_script use **kwargs on step() | 156 # TODO(martiniss) delete, and make generator_script use **kwargs on step() |
| 155 @recipe_api.composite_step | 157 @recipe_api.composite_step |
| 156 def run_from_dict(self, dct): | 158 def run_from_dict(self, dct): |
| 157 return self._engine.run_step(dct) | 159 return self._engine.run_step(dct) |
| OLD | NEW |