OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2013 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2013 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 """ | 6 """ |
7 Tool to perform checkouts in one easy command line! | 7 Tool to perform checkouts in one easy command line! |
8 | 8 |
9 Usage: | 9 Usage: |
10 fetch <recipe> [--property=value [--property2=value2 ...]] | 10 fetch <recipe> [--property=value [--property2=value2 ...]] |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 | 168 |
169 recipe = argv[1] | 169 recipe = argv[1] |
170 props = argv[2:] | 170 props = argv[2:] |
171 return recipe, props | 171 return recipe, props |
172 | 172 |
173 | 173 |
174 def run_recipe_fetch(recipe, props, aliased=False): | 174 def run_recipe_fetch(recipe, props, aliased=False): |
175 """Invoke a recipe's fetch method with the passed-through args | 175 """Invoke a recipe's fetch method with the passed-through args |
176 and return its json output as a python object.""" | 176 and return its json output as a python object.""" |
177 recipe_path = os.path.abspath(os.path.join(SCRIPT_PATH, 'recipes', recipe)) | 177 recipe_path = os.path.abspath(os.path.join(SCRIPT_PATH, 'recipes', recipe)) |
| 178 if not os.path.exists(recipe_path): |
| 179 print "Could not find a recipe for %s" % recipe |
| 180 sys.exit(1) |
| 181 |
178 cmd = [sys.executable, recipe_path + '.py', 'fetch'] + props | 182 cmd = [sys.executable, recipe_path + '.py', 'fetch'] + props |
179 result = subprocess.Popen(cmd, stdout=subprocess.PIPE).communicate()[0] | 183 result = subprocess.Popen(cmd, stdout=subprocess.PIPE).communicate()[0] |
| 184 |
180 spec = json.loads(result) | 185 spec = json.loads(result) |
181 if 'alias' in spec: | 186 if 'alias' in spec: |
182 assert not aliased | 187 assert not aliased |
183 return run_recipe_fetch( | 188 return run_recipe_fetch( |
184 spec['alias']['recipe'], spec['alias']['props'] + props, aliased=True) | 189 spec['alias']['recipe'], spec['alias']['props'] + props, aliased=True) |
185 cmd = [sys.executable, recipe_path + '.py', 'root'] | 190 cmd = [sys.executable, recipe_path + '.py', 'root'] |
186 result = subprocess.Popen(cmd, stdout=subprocess.PIPE).communicate()[0] | 191 result = subprocess.Popen(cmd, stdout=subprocess.PIPE).communicate()[0] |
187 root = json.loads(result) | 192 root = json.loads(result) |
188 return spec, root | 193 return spec, root |
189 | 194 |
(...skipping 22 matching lines...) Expand all Loading... |
212 | 217 |
213 | 218 |
214 def main(): | 219 def main(): |
215 recipe, props = handle_args(sys.argv) | 220 recipe, props = handle_args(sys.argv) |
216 spec, root = run_recipe_fetch(recipe, props) | 221 spec, root = run_recipe_fetch(recipe, props) |
217 return run(spec, root) | 222 return run(spec, root) |
218 | 223 |
219 | 224 |
220 if __name__ == '__main__': | 225 if __name__ == '__main__': |
221 sys.exit(main()) | 226 sys.exit(main()) |
OLD | NEW |