OLD | NEW |
1 # Copyright 2013 The Chromium Authors. All rights reserved. | 1 # Copyright 2013 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 from slave import recipe_api | 5 from slave import recipe_api |
6 from slave import recipe_util | 6 from slave import recipe_util |
7 | 7 |
8 # Inherit from RecipeApiPlain because the only thing which is a step is | 8 # Inherit from RecipeApiPlain because the only thing which is a step is |
9 # run_from_dict() | 9 # run_from_dict() |
10 class StepApi(recipe_api.RecipeApiPlain): | 10 class StepApi(recipe_api.RecipeApiPlain): |
11 def __init__(self, **kwargs): | |
12 super(StepApi, self).__init__(**kwargs) | |
13 self._step_names = {} | |
14 | |
15 EXCEPTION = 'EXCEPTION' | 11 EXCEPTION = 'EXCEPTION' |
16 FAILURE = 'FAILURE' | 12 FAILURE = 'FAILURE' |
17 SUCCESS = 'SUCCESS' | 13 SUCCESS = 'SUCCESS' |
18 WARNING = 'WARNING' | 14 WARNING = 'WARNING' |
19 | 15 |
20 @property | 16 @property |
21 def StepFailure(self): | 17 def StepFailure(self): |
22 """ See recipe_api.py for docs. """ | 18 """ See recipe_api.py for docs. """ |
23 return recipe_api.StepFailure | 19 return recipe_api.StepFailure |
24 | 20 |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 assert 'shell' not in kwargs | 84 assert 'shell' not in kwargs |
89 assert isinstance(cmd, list) | 85 assert isinstance(cmd, list) |
90 if not ok_ret: | 86 if not ok_ret: |
91 ok_ret = {0} | 87 ok_ret = {0} |
92 if ok_ret in ('any', 'all'): | 88 if ok_ret in ('any', 'all'): |
93 ok_ret = set(range(-256, 256)) | 89 ok_ret = set(range(-256, 256)) |
94 | 90 |
95 command = list(wrapper) | 91 command = list(wrapper) |
96 command += cmd | 92 command += cmd |
97 | 93 |
98 step_count = self._step_names.setdefault(name, 0) + 1 | |
99 self._step_names[name] = step_count | |
100 if step_count > 1: | |
101 name = "%s (%d)" % (name, step_count) | |
102 | |
103 kwargs.update({'name': name, 'cmd': command}) | 94 kwargs.update({'name': name, 'cmd': command}) |
104 kwargs['ok_ret'] = ok_ret | 95 kwargs['ok_ret'] = ok_ret |
105 kwargs['infra_step'] = bool(infra_step) | 96 kwargs['infra_step'] = bool(infra_step) |
106 | 97 |
107 schema = self.make_config() | 98 schema = self.make_config() |
108 schema.set_val(kwargs) | 99 schema.set_val(kwargs) |
109 return self.run_from_dict(self._engine.create_step(schema)) | 100 return self.run_from_dict(self._engine.create_step(schema)) |
110 | 101 |
111 # TODO(martiniss) delete, and make generator_script use **kwargs on step() | 102 # TODO(martiniss) delete, and make generator_script use **kwargs on step() |
112 @recipe_api.composite_step | 103 @recipe_api.composite_step |
113 def run_from_dict(self, dct): | 104 def run_from_dict(self, dct): |
114 return self._engine.run_step(dct) | 105 return self._engine.run_step(dct) |
OLD | NEW |