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

Side by Side Diff: recipe_engine/step_runner.py

Issue 2885293003: [step_runner] do not immediately bail when START_DIR is gone. (Closed)
Patch Set: whitespace 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 | recipes/engine_tests/missing_start_dir.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2016 The LUCI Authors. All rights reserved. 1 # Copyright 2016 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 calendar 5 import calendar
6 import collections 6 import collections
7 import contextlib 7 import contextlib
8 import datetime 8 import datetime
9 import itertools 9 import itertools
10 import json 10 import json
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 return getattr(value, '__name__', 'UNKNOWN_CALLABLE')+'(...)' 277 return getattr(value, '__name__', 'UNKNOWN_CALLABLE')+'(...)'
278 278
279 def _print_step(self, step_stream, step, env): 279 def _print_step(self, step_stream, step, env):
280 """Prints the step command and relevant metadata. 280 """Prints the step command and relevant metadata.
281 281
282 Intended to be similar to the information that Buildbot prints at the 282 Intended to be similar to the information that Buildbot prints at the
283 beginning of each non-annotator step. 283 beginning of each non-annotator step.
284 """ 284 """
285 def gen_step_prelude(): 285 def gen_step_prelude():
286 yield ' '.join(map(_shell_quote, step.config.cmd)) 286 yield ' '.join(map(_shell_quote, step.config.cmd))
287 yield 'in dir %s:' % (step.config.cwd or os.getcwd()) 287 cwd = step.config.cwd
288 if cwd is None:
289 try:
290 cwd = os.getcwd()
291 except OSError as ex:
292 cwd = '??? (ENGINE START_DIR IS MISSING: %r)' % (ex,)
293 elif not os.path.isdir(cwd):
294 cwd += ' (ENGINE START_DIR IS MISSING OR NOT A DIR)'
295 yield 'in dir %s:' % (cwd,)
288 for key, value in sorted(step.config._asdict().items()): 296 for key, value in sorted(step.config._asdict().items()):
289 if value is not None: 297 if value is not None:
290 yield ' %s: %s' % (key, self._render_step_value(value)) 298 yield ' %s: %s' % (key, self._render_step_value(value))
291 yield 'full environment:' 299 yield 'full environment:'
292 for key, value in sorted(env.items()): 300 for key, value in sorted(env.items()):
293 yield ' %s: %s' % (key, value) 301 yield ' %s: %s' % (key, value)
294 yield '' 302 yield ''
295 stream.output_iter(step_stream, gen_step_prelude()) 303 stream.output_iter(step_stream, gen_step_prelude())
296 304
297 def _run_cmd(self, cmd, timeout, handles, env, cwd): 305 def _run_cmd(self, cmd, timeout, handles, env, cwd):
(...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after
740 supplied command, and only uses the |env| kwarg for modifying the environment 748 supplied command, and only uses the |env| kwarg for modifying the environment
741 of the child process. 749 of the child process.
742 """ 750 """
743 saved_path = os.environ['PATH'] 751 saved_path = os.environ['PATH']
744 try: 752 try:
745 if path is not None: 753 if path is not None:
746 os.environ['PATH'] = path 754 os.environ['PATH'] = path
747 yield 755 yield
748 finally: 756 finally:
749 os.environ['PATH'] = saved_path 757 os.environ['PATH'] = saved_path
OLDNEW
« no previous file with comments | « no previous file | recipes/engine_tests/missing_start_dir.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698