Chromium Code Reviews| 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 copy | 6 import copy |
| 7 import types | 7 import types |
| 8 | 8 |
| 9 from recipe_engine import recipe_api | 9 from recipe_engine import recipe_api |
| 10 from recipe_engine.config_types import Path | 10 from recipe_engine.config_types import Path |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 164 assert isinstance(cmd, (types.NoneType, list)) | 164 assert isinstance(cmd, (types.NoneType, list)) |
| 165 if cmd is not None: | 165 if cmd is not None: |
| 166 cmd = list(wrapper) + cmd | 166 cmd = list(wrapper) + cmd |
| 167 assert all(isinstance(x, (int, long, basestring, Path, Placeholder)) | 167 assert all(isinstance(x, (int, long, basestring, Path, Placeholder)) |
| 168 for x in cmd) | 168 for x in cmd) |
| 169 | 169 |
| 170 cwd = self.m.context.cwd | 170 cwd = self.m.context.cwd |
| 171 if cwd and cwd == self.m.path['start_dir']: | 171 if cwd and cwd == self.m.path['start_dir']: |
| 172 cwd = None | 172 cwd = None |
| 173 | 173 |
| 174 env = self.m.context.env | 174 with self.m.context(env_prefixes={'PATH': self._prefix_path}): |
| 175 if self._prefix_path: | 175 env_prefixes = self.m.context.env_prefixes |
| 176 ps = self.m.path.pathsep | |
| 177 prefix = ps.join(self._prefix_path) | |
| 178 suffix = env.get('PATH', '%(PATH)s') | |
| 179 env['PATH'] = '%s%s%s' % (prefix, ps, suffix) | |
| 180 | 176 |
| 181 if ok_ret in ('any', 'all'): | 177 if ok_ret in ('any', 'all'): |
| 182 ok_ret = range(-256, 256) | 178 ok_ret = range(-256, 256) |
| 183 | 179 |
| 184 return self.step_client.run_step(self.step_client.StepConfig( | 180 return self.step_client.run_step(self.step_client.StepConfig( |
| 185 name=full_name, | 181 name=full_name, |
| 186 base_name=full_name or name, | 182 base_name=full_name or name, |
| 187 cmd=cmd, | 183 cmd=cmd, |
| 188 cwd=cwd, | 184 cwd=cwd, |
| 189 env=env, | 185 env=self.m.context.env, |
| 186 env_prefixes=env_prefixes, | |
|
iannucci
2017/06/13 20:28:12
tuple(env_prefixen, pathsep)
dnj
2017/06/13 21:46:26
Done.
| |
| 187 pathsep=self.m.path.pathsep, | |
| 190 allow_subannotations=bool(allow_subannotations), | 188 allow_subannotations=bool(allow_subannotations), |
| 191 trigger_specs=[self._make_trigger_spec(trig) | 189 trigger_specs=[self._make_trigger_spec(trig) |
| 192 for trig in (trigger_specs or ())], | 190 for trig in (trigger_specs or ())], |
| 193 timeout=timeout, | 191 timeout=timeout, |
| 194 infra_step=self.m.context.infra_step or bool(infra_step), | 192 infra_step=self.m.context.infra_step or bool(infra_step), |
| 195 stdout=stdout, | 193 stdout=stdout, |
| 196 stderr=stderr, | 194 stderr=stderr, |
| 197 stdin=stdin, | 195 stdin=stdin, |
| 198 ok_ret=ok_ret, | 196 ok_ret=ok_ret, |
| 199 step_test_data=step_test_data, | 197 step_test_data=step_test_data, |
| 200 nest_level=self.m.context.nest_level, | 198 nest_level=self.m.context.nest_level, |
| 201 )) | 199 )) |
| 202 | 200 |
| 203 def _make_trigger_spec(self, trig): | 201 def _make_trigger_spec(self, trig): |
| 204 buildbot_changes = trig.get('buildbot_changes') | 202 buildbot_changes = trig.get('buildbot_changes') |
| 205 assert isinstance(buildbot_changes, (types.NoneType, list)) | 203 assert isinstance(buildbot_changes, (types.NoneType, list)) |
| 206 | 204 |
| 207 critical = trig.get('critical') | 205 critical = trig.get('critical') |
| 208 return self.step_client.TriggerSpec( | 206 return self.step_client.TriggerSpec( |
| 209 bucket=trig.get('bucket'), | 207 bucket=trig.get('bucket'), |
| 210 builder_name=trig['builder_name'], | 208 builder_name=trig['builder_name'], |
| 211 properties=trig.get('properties'), | 209 properties=trig.get('properties'), |
| 212 buildbot_changes=buildbot_changes, | 210 buildbot_changes=buildbot_changes, |
| 213 tags=trig.get('tags'), | 211 tags=trig.get('tags'), |
| 214 critical=bool(critical) if critical is not None else (True), | 212 critical=bool(critical) if critical is not None else (True), |
| 215 ) | 213 ) |
| OLD | NEW |