| 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 from recipe_engine import recipe_api | 5 from recipe_engine import recipe_api |
| 6 | 6 |
| 7 class GeneratorScriptApi(recipe_api.RecipeApi): | 7 class GeneratorScriptApi(recipe_api.RecipeApi): |
| 8 def __call__(self, path_to_script, *args, **kwargs): | 8 def __call__(self, path_to_script, *args, **kwargs): |
| 9 """Run a script and generate the steps emitted by that script. | 9 """Run a script and generate the steps emitted by that script. |
| 10 | 10 |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 step['env'] = new_env | 83 step['env'] = new_env |
| 84 outputs_json = step.pop('outputs_presentation_json', False) | 84 outputs_json = step.pop('outputs_presentation_json', False) |
| 85 if outputs_json: | 85 if outputs_json: |
| 86 # This step has requested a JSON file which the binary that | 86 # This step has requested a JSON file which the binary that |
| 87 # it invokes can write to, so provide it with one. | 87 # it invokes can write to, so provide it with one. |
| 88 step['cmd'].extend(['--presentation-json', self.m.json.output(False)]) | 88 step['cmd'].extend(['--presentation-json', self.m.json.output(False)]) |
| 89 | 89 |
| 90 #TODO(martiniss) change this to use a regular step call | 90 #TODO(martiniss) change this to use a regular step call |
| 91 step['ok_ret'] = set(step.pop('ok_ret', {0})) | 91 step['ok_ret'] = set(step.pop('ok_ret', {0})) |
| 92 step['infra_step'] = bool(step.pop('infra_step', False)) | 92 step['infra_step'] = bool(step.pop('infra_step', False)) |
| 93 step['step_nest_level'] = int(step.pop('step_nest_level', 0)) | 93 step['step_nest_level'] = step.pop('step_nest_level', 0) |
| 94 | 94 |
| 95 if step.pop('always_run', False) or not failed_steps: | 95 if step.pop('always_run', False) or not failed_steps: |
| 96 try: | 96 try: |
| 97 self.m.step.run_from_dict(step) | 97 self.m.step.run_from_dict(step) |
| 98 except self.m.step.StepFailure: | 98 except self.m.step.StepFailure: |
| 99 failed_steps.append(step['name']) | 99 failed_steps.append(step['name']) |
| 100 finally: | 100 finally: |
| 101 step_result = self.m.step.active_result | 101 step_result = self.m.step.active_result |
| 102 if outputs_json: | 102 if outputs_json: |
| 103 p = step_result.presentation | 103 p = step_result.presentation |
| 104 j = step_result.json.output | 104 j = step_result.json.output |
| 105 | 105 |
| 106 if j: | 106 if j: |
| 107 p.logs.update(j.get('logs', {})) | 107 p.logs.update(j.get('logs', {})) |
| 108 p.links.update(j.get('links', {})) | 108 p.links.update(j.get('links', {})) |
| 109 p.step_summary_text = j.get('step_summary_text', '') | 109 p.step_summary_text = j.get('step_summary_text', '') |
| 110 p.step_text = j.get('step_text', '') | 110 p.step_text = j.get('step_text', '') |
| 111 p.properties.update(j.get('properties', {})) | 111 p.properties.update(j.get('properties', {})) |
| 112 | 112 |
| 113 if failed_steps: | 113 if failed_steps: |
| 114 raise self.m.step.StepFailure( | 114 raise self.m.step.StepFailure( |
| 115 "the following steps in %s failed: %s" % | 115 "the following steps in %s failed: %s" % |
| 116 (step_name, failed_steps)) | 116 (step_name, failed_steps)) |
| OLD | NEW |