| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright 2015 The LUCI Authors. All rights reserved. | 2 # Copyright 2015 The LUCI Authors. All rights reserved. |
| 3 # Use of this source code is governed under the Apache License, Version 2.0 | 3 # Use of this source code is governed under the Apache License, Version 2.0 |
| 4 # that can be found in the LICENSE file. | 4 # that can be found in the LICENSE file. |
| 5 | 5 |
| 6 """Tool to interact with recipe repositories. | 6 """Tool to interact with recipe repositories. |
| 7 | 7 |
| 8 This tool operates on the nearest ancestor directory containing an | 8 This tool operates on the nearest ancestor directory containing an |
| 9 infra/config/recipes.cfg. | 9 infra/config/recipes.cfg. |
| 10 """ | 10 """ |
| 11 | 11 |
| 12 import argparse | 12 import argparse |
| 13 import collections |
| 13 import json | 14 import json |
| 14 import logging | 15 import logging |
| 15 import os | 16 import os |
| 16 import subprocess | 17 import subprocess |
| 17 import sys | 18 import sys |
| 18 | 19 |
| 19 ROOT_DIR = os.path.dirname(os.path.abspath(__file__)) | 20 ROOT_DIR = os.path.dirname(os.path.abspath(__file__)) |
| 20 sys.path.insert(0, ROOT_DIR) | 21 sys.path.insert(0, ROOT_DIR) |
| 21 | 22 |
| 22 from recipe_engine import env | 23 from recipe_engine import env |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 | 192 |
| 192 class ProjectOverrideAction(argparse.Action): | 193 class ProjectOverrideAction(argparse.Action): |
| 193 def __call__(self, parser, namespace, values, option_string=None): | 194 def __call__(self, parser, namespace, values, option_string=None): |
| 194 p = values.split('=', 2) | 195 p = values.split('=', 2) |
| 195 if len(p) != 2: | 196 if len(p) != 2: |
| 196 raise ValueError("Override must have the form: repo=path") | 197 raise ValueError("Override must have the form: repo=path") |
| 197 project_id, path = p | 198 project_id, path = p |
| 198 | 199 |
| 199 v = getattr(namespace, self.dest, None) | 200 v = getattr(namespace, self.dest, None) |
| 200 if v is None: | 201 if v is None: |
| 201 v = {} | 202 v = collections.OrderedDict() |
| 202 setattr(namespace, self.dest, v) | 203 setattr(namespace, self.dest, v) |
| 203 | 204 |
| 204 if v.get(project_id): | 205 if v.get(project_id): |
| 205 raise ValueError("An override is already defined for [%s] (%s)" % ( | 206 raise ValueError("An override is already defined for [%s] (%s)" % ( |
| 206 project_id, v[project_id])) | 207 project_id, v[project_id])) |
| 207 path = os.path.abspath(os.path.expanduser(path)) | 208 path = os.path.abspath(os.path.expanduser(path)) |
| 208 if not os.path.isdir(path): | 209 if not os.path.isdir(path): |
| 209 raise ValueError("Override path [%s] is not a directory" % (path,)) | 210 raise ValueError("Override path [%s] is not a directory" % (path,)) |
| 210 v[project_id] = path | 211 v[project_id] = path |
| 211 | 212 |
| (...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 567 ret = main() | 568 ret = main() |
| 568 if not isinstance(ret, int): | 569 if not isinstance(ret, int): |
| 569 if ret is None: | 570 if ret is None: |
| 570 ret = 0 | 571 ret = 0 |
| 571 else: | 572 else: |
| 572 print >> sys.stderr, ret | 573 print >> sys.stderr, ret |
| 573 ret = 1 | 574 ret = 1 |
| 574 sys.stdout.flush() | 575 sys.stdout.flush() |
| 575 sys.stderr.flush() | 576 sys.stderr.flush() |
| 576 os._exit(ret) | 577 os._exit(ret) |
| OLD | NEW |