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 json | 13 import json |
14 import logging | 14 import logging |
15 import os | 15 import os |
16 import shutil | 16 import shutil |
17 import subprocess | 17 import subprocess |
18 import sys | 18 import sys |
19 import tempfile | 19 import tempfile |
20 | 20 |
21 ROOT_DIR = os.path.dirname(os.path.abspath(__file__)) | 21 ROOT_DIR = os.path.dirname(os.path.abspath(__file__)) |
22 sys.path.insert(0, ROOT_DIR) | 22 sys.path.insert(0, ROOT_DIR) |
23 | 23 |
24 from recipe_engine import env | 24 from recipe_engine import env |
25 from recipe_engine import arguments_pb2 | 25 from recipe_engine import arguments_pb2 |
26 from google.protobuf import json_format as jsonpb | 26 from google.protobuf import json_format as jsonpb |
27 from google.protobuf import text_format as textpb | 27 |
28 | 28 |
29 def get_package_config(args): | 29 def get_package_config(args): |
30 from recipe_engine import package | 30 from recipe_engine import package |
31 | 31 |
32 assert args.package, 'No recipe config (--package) given.' | 32 assert args.package, 'No recipe config (--package) given.' |
33 assert os.path.exists(args.package), ( | 33 assert os.path.exists(args.package), ( |
34 'Given recipes config file %s does not exist.' % args.package) | 34 'Given recipes config file %s does not exist.' % args.package) |
35 return ( | 35 return ( |
36 package.InfraRepoConfig().from_recipes_cfg(args.package), | 36 package.InfraRepoConfig().from_recipes_cfg(args.package), |
37 package.ProtoFile(args.package) | 37 package.ProtoFile(args.package) |
(...skipping 694 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
732 | 732 |
733 if not isinstance(ret, int): | 733 if not isinstance(ret, int): |
734 if ret is None: | 734 if ret is None: |
735 ret = 0 | 735 ret = 0 |
736 else: | 736 else: |
737 print >> sys.stderr, ret | 737 print >> sys.stderr, ret |
738 ret = 1 | 738 ret = 1 |
739 sys.stdout.flush() | 739 sys.stdout.flush() |
740 sys.stderr.flush() | 740 sys.stderr.flush() |
741 os._exit(ret) | 741 os._exit(ret) |
OLD | NEW |