| OLD | NEW |
| 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 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 | 172 |
| 173 return EmptyOpenStep() | 173 return EmptyOpenStep() |
| 174 | 174 |
| 175 try: | 175 try: |
| 176 rendered_step = render_step( | 176 rendered_step = render_step( |
| 177 step_config, recipe_test_api.DisabledTestData() | 177 step_config, recipe_test_api.DisabledTestData() |
| 178 ) | 178 ) |
| 179 step_config = None # Make sure we use rendered step config. | 179 step_config = None # Make sure we use rendered step config. |
| 180 except: | 180 except: |
| 181 with self.stream_engine.make_step_stream('Placeholder Exception') as s: | 181 with self.stream_engine.make_step_stream('Placeholder Exception') as s: |
| 182 s.set_step_status('EXCEPTION') |
| 182 with s.new_log_stream('exception') as l: | 183 with s.new_log_stream('exception') as l: |
| 183 l.write_split(traceback.format_exc()) | 184 l.write_split(traceback.format_exc()) |
| 184 raise | 185 raise |
| 185 | 186 |
| 186 step_env = _merge_envs(os.environ, (rendered_step.config.env or {})) | 187 step_env = _merge_envs(os.environ, (rendered_step.config.env or {})) |
| 187 # Now that the step's environment is all sorted, evaluate PATH on windows | 188 # Now that the step's environment is all sorted, evaluate PATH on windows |
| 188 # to find the actual intended executable. | 189 # to find the actual intended executable. |
| 189 rendered_step = _hunt_path(rendered_step, step_env) | 190 rendered_step = _hunt_path(rendered_step, step_env) |
| 190 self._print_step(step_stream, rendered_step, step_env) | 191 self._print_step(step_stream, rendered_step, step_env) |
| 191 | 192 |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 417 | 418 |
| 418 def open_step(self, step_config): | 419 def open_step(self, step_config): |
| 419 try: | 420 try: |
| 420 test_data_fn = step_config.step_test_data or recipe_test_api.StepTestData | 421 test_data_fn = step_config.step_test_data or recipe_test_api.StepTestData |
| 421 step_test = self._test_data.pop_step_test_data(step_config.name, | 422 step_test = self._test_data.pop_step_test_data(step_config.name, |
| 422 test_data_fn) | 423 test_data_fn) |
| 423 rendered_step = render_step(step_config, step_test) | 424 rendered_step = render_step(step_config, step_test) |
| 424 step_config = None # Make sure we use rendered step config. | 425 step_config = None # Make sure we use rendered step config. |
| 425 except: | 426 except: |
| 426 with self.stream_engine.make_step_stream('Placeholder Exception') as s: | 427 with self.stream_engine.make_step_stream('Placeholder Exception') as s: |
| 428 s.set_step_status('EXCEPTION') |
| 427 with s.new_log_stream('exception') as l: | 429 with s.new_log_stream('exception') as l: |
| 428 l.write_split(traceback.format_exc()) | 430 l.write_split(traceback.format_exc()) |
| 429 raise | 431 raise |
| 430 | 432 |
| 431 # Layer the simulation step on top of the given stream engine. | 433 # Layer the simulation step on top of the given stream engine. |
| 432 step_stream = self._stream_engine.new_step_stream(rendered_step.config) | 434 step_stream = self._stream_engine.new_step_stream(rendered_step.config) |
| 433 | 435 |
| 434 class ReturnOpenStep(OpenStep): | 436 class ReturnOpenStep(OpenStep): |
| 435 def run(inner): | 437 def run(inner): |
| 436 timeout = rendered_step.config.timeout | 438 timeout = rendered_step.config.timeout |
| (...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 738 supplied command, and only uses the |env| kwarg for modifying the environment | 740 supplied command, and only uses the |env| kwarg for modifying the environment |
| 739 of the child process. | 741 of the child process. |
| 740 """ | 742 """ |
| 741 saved_path = os.environ['PATH'] | 743 saved_path = os.environ['PATH'] |
| 742 try: | 744 try: |
| 743 if path is not None: | 745 if path is not None: |
| 744 os.environ['PATH'] = path | 746 os.environ['PATH'] = path |
| 745 yield | 747 yield |
| 746 finally: | 748 finally: |
| 747 os.environ['PATH'] = saved_path | 749 os.environ['PATH'] = saved_path |
| OLD | NEW |