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

Side by Side Diff: recipe_modules/step/api.py

Issue 2875543002: [recipe_modules/step] do not set cwd if it is start_dir. (Closed)
Patch Set: fix take 2 Created 3 years, 7 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 | « no previous file | recipe_modules/step/example.py » ('j') | recipe_modules/step/example.py » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 7
8 from recipe_engine import recipe_api 8 from recipe_engine import recipe_api
9 9
10 10
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 ok_ret (tuple or set of ints, str): allowed return codes. Any unexpected 146 ok_ret (tuple or set of ints, str): allowed return codes. Any unexpected
147 return codes will cause an exception to be thrown. If you pass in the 147 return codes will cause an exception to be thrown. If you pass in the
148 value 'any' or 'all', the engine will allow any return code to be 148 value 'any' or 'all', the engine will allow any return code to be
149 returned. Defaults to {0} 149 returned. Defaults to {0}
150 infra_step: Whether or not this is an infrastructure step. Infrastructure 150 infra_step: Whether or not this is an infrastructure step. Infrastructure
151 steps will place the step in an EXCEPTION state and raise InfraFailure. 151 steps will place the step in an EXCEPTION state and raise InfraFailure.
152 wrapper: If supplied, a command to prepend to the executed step as a 152 wrapper: If supplied, a command to prepend to the executed step as a
153 command wrapper. 153 command wrapper.
154 timeout: If supplied, the recipe engine will kill the step after the 154 timeout: If supplied, the recipe engine will kill the step after the
155 specified number of seconds. 155 specified number of seconds.
156 cwd (str or None): absolute path to working directory for the command
157 allow_subannotations (bool): if True, lets the step emit its own 156 allow_subannotations (bool): if True, lets the step emit its own
158 annotations. NOTE: Enabling this can cause some buggy behavior. Please 157 annotations. NOTE: Enabling this can cause some buggy behavior. Please
159 strongly consider using step_result.presentation instead. If you have 158 strongly consider using step_result.presentation instead. If you have
160 questions, please contact infra-dev@chromium.org. 159 questions, please contact infra-dev@chromium.org.
161 trigger_specs: a list of trigger specifications 160 trigger_specs: a list of trigger specifications
162 stdout: Placeholder to put step stdout into. If used, stdout won't appear 161 stdout: Placeholder to put step stdout into. If used, stdout won't appear
163 in annotator's stdout (and |allow_subannotations| is ignored). 162 in annotator's stdout (and |allow_subannotations| is ignored).
164 stderr: Placeholder to put step stderr into. If used, stderr won't appear 163 stderr: Placeholder to put step stderr into. If used, stderr won't appear
165 in annotator's stderr. 164 in annotator's stderr.
166 stdin: Placeholder to read step stdin from. 165 stdin: Placeholder to read step stdin from.
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 while True: 207 while True:
209 full_name = self.combine_with_context('name', name) 208 full_name = self.combine_with_context('name', name)
210 if full_name not in self._seen_steps: 209 if full_name not in self._seen_steps:
211 break 210 break
212 211
213 step_count = self._step_names.setdefault(full_name, 1) + 1 212 step_count = self._step_names.setdefault(full_name, 1) + 1
214 self._step_names[full_name] = step_count 213 self._step_names[full_name] = step_count
215 name = "%s (%d)" % (name, step_count) 214 name = "%s (%d)" % (name, step_count)
216 self._seen_steps.add(full_name) 215 self._seen_steps.add(full_name)
217 216
218 if 'cwd' not in kwargs: 217 cwd = self.get_from_context('cwd')
219 kwargs['cwd'] = self.get_from_context('cwd') 218 if cwd is not None and cwd != self.m.path['start_dir']:
219 kwargs['cwd'] = cwd
220 kwargs['env'] = self.get_from_context('env', {}) 220 kwargs['env'] = self.get_from_context('env', {})
221 if self._prefix_path: 221 if self._prefix_path:
222 ps = self.m.path.pathsep 222 ps = self.m.path.pathsep
223 prefix = ps.join(self._prefix_path) 223 prefix = ps.join(self._prefix_path)
224 suffix = kwargs['env'].get('PATH', '%(PATH)s') 224 suffix = kwargs['env'].get('PATH', '%(PATH)s')
225 kwargs['env']['PATH'] = '%s%s%s' % (prefix, ps, suffix) 225 kwargs['env']['PATH'] = '%s%s%s' % (prefix, ps, suffix)
226 kwargs['infra_step'] = self.combine_with_context( 226 kwargs['infra_step'] = self.combine_with_context(
227 'infra_step', bool(infra_step)) 227 'infra_step', bool(infra_step))
228 kwargs['step_nest_level'] = self.combine_with_context('nest_level', 0) 228 kwargs['step_nest_level'] = self.combine_with_context('nest_level', 0)
229 kwargs['name'] = full_name 229 kwargs['name'] = full_name
230 kwargs['base_name'] = name 230 kwargs['base_name'] = name
231 231
232 schema = self.make_config() 232 schema = self.make_config()
233 schema.set_val(kwargs) 233 schema.set_val(kwargs)
234 return self.run_from_dict(schema.as_jsonish()) 234 return self.run_from_dict(schema.as_jsonish())
235 235
236 # TODO(martiniss) delete, and make generator_script use **kwargs on step() 236 # TODO(martiniss) delete, and make generator_script use **kwargs on step()
237 @recipe_api.composite_step 237 @recipe_api.composite_step
238 def run_from_dict(self, dct): 238 def run_from_dict(self, dct):
239 return self.step_client.run_step(dct) 239 return self.step_client.run_step(dct)
OLDNEW
« no previous file with comments | « no previous file | recipe_modules/step/example.py » ('j') | recipe_modules/step/example.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698