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 from __future__ import absolute_import | 5 from __future__ import absolute_import |
6 import contextlib | 6 import contextlib |
7 import collections | 7 import collections |
8 import copy | 8 import copy |
9 import keyword | 9 import keyword |
10 import re | 10 import re |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
77 def do_something(self): | 77 def do_something(self): |
78 self.step_client.whatever() | 78 self.step_client.whatever() |
79 | 79 |
80 Args: | 80 Args: |
81 name (str): the name of the recipe engine client to install. | 81 name (str): the name of the recipe engine client to install. |
82 """ | 82 """ |
83 return _UnresolvedRequirement('client', name) | 83 return _UnresolvedRequirement('client', name) |
84 | 84 |
85 | 85 |
86 class PropertiesClient(object): | 86 class PropertiesClient(object): |
87 """A recipe engine client representing the recipe engine properties.""" | 87 """A recipe engine client representing the recipe engine properties. |
88 | |
89 The retained properties are frozen, and can be safely passed around. | |
90 """ | |
88 | 91 |
89 IDENT = 'properties' | 92 IDENT = 'properties' |
90 | 93 |
91 def __init__(self, engine): | 94 def __init__(self, rt): |
92 self._engine = engine | 95 self._rt = rt |
93 | 96 |
94 def get_properties(self): | 97 @property |
95 return copy.deepcopy(self._engine.properties) | 98 def properties(self): |
99 """Returns (types.FrozenDict): Frozen properties.""" | |
100 return self._rt.properties | |
101 | |
102 def mutable_properties(self): | |
iannucci
2016/10/19 16:41:03
this seems really dangerous to me; we've never exp
dnj
2016/10/19 16:44:05
The mutable properties function returns a deepcopy
| |
103 """Returns (dict): Mutable original properties dict.""" | |
104 return self._rt.mutable_properties() | |
96 | 105 |
97 | 106 |
98 class StepClient(object): | 107 class StepClient(object): |
99 """A recipe engine client representing step running and introspection.""" | 108 """A recipe engine client representing step running and introspection.""" |
100 | 109 |
101 IDENT = 'step' | 110 IDENT = 'step' |
102 | 111 |
103 def __init__(self, engine): | 112 def __init__(self, engine): |
104 self._engine = engine | 113 self._engine = engine |
105 | 114 |
(...skipping 14 matching lines...) Expand all Loading... | |
120 | 129 |
121 Args: | 130 Args: |
122 step_dict (dict): A step dictionary to run. | 131 step_dict (dict): A step dictionary to run. |
123 | 132 |
124 Returns: | 133 Returns: |
125 A StepData object containing the result of running the step. | 134 A StepData object containing the result of running the step. |
126 """ | 135 """ |
127 return self._engine.run_step(StepConfig.create(**step_dict)) | 136 return self._engine.run_step(StepConfig.create(**step_dict)) |
128 | 137 |
129 | 138 |
139 class PlatformClient(object): | |
140 """A recipe engine client to expose a common view of the running platform.""" | |
141 | |
142 IDENT = 'platform' | |
143 | |
144 def __init__(self, plat): | |
145 self._plat = plat | |
146 | |
147 # Export normalization methods. | |
148 self.norm_plat = plat.norm_plat | |
149 self.norm_bits = plat.norm_bits | |
150 | |
151 # Export platform constants. | |
152 self.WIN = plat.WIN | |
153 self.LINUX = plat.LINUX | |
154 self.MAC = plat.MAC | |
155 | |
156 @property | |
157 def name(self): | |
158 return self._plat.name | |
159 | |
160 @property | |
161 def bits(self): | |
162 return self._plat.bits | |
163 | |
164 @property | |
165 def arch(self): | |
166 return self._plat.arch | |
167 | |
168 | |
130 class DependencyManagerClient(object): | 169 class DependencyManagerClient(object): |
131 """A recipe engine client representing the dependency manager.""" | 170 """A recipe engine client representing the dependency manager.""" |
132 | 171 |
133 IDENT = 'dependency_manager' | 172 IDENT = 'dependency_manager' |
134 | 173 |
135 def __init__(self, engine): | 174 def __init__(self, engine): |
136 self._engine = engine | 175 self._engine = engine |
137 | 176 |
138 def depend_on(self, recipe, properties, **kwargs): | 177 def depend_on(self, recipe, properties, **kwargs): |
139 return self._engine.depend_on(recipe, properties, **kwargs) | 178 return self._engine.depend_on(recipe, properties, **kwargs) |
(...skipping 788 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
928 """ | 967 """ |
929 Gets the BoundProperty version of this Property. Requires a name. | 968 Gets the BoundProperty version of this Property. Requires a name. |
930 """ | 969 """ |
931 return BoundProperty( | 970 return BoundProperty( |
932 self._default, self.help, self.kind, name, property_type, module, | 971 self._default, self.help, self.kind, name, property_type, module, |
933 self.param_name) | 972 self.param_name) |
934 | 973 |
935 class UndefinedPropertyException(TypeError): | 974 class UndefinedPropertyException(TypeError): |
936 pass | 975 pass |
937 | 976 |
OLD | NEW |