Chromium Code Reviews| 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 reload(sys) | |
|
iannucci
2017/04/06 18:15:59
Comment:
# This is necessary to ensure that str l
Paweł Hajdan Jr.
2017/04/06 18:18:41
Done.
| |
| 22 sys.setdefaultencoding('UTF8') | |
| 23 | |
| 21 ROOT_DIR = os.path.dirname(os.path.abspath(__file__)) | 24 ROOT_DIR = os.path.dirname(os.path.abspath(__file__)) |
| 22 sys.path.insert(0, ROOT_DIR) | 25 sys.path.insert(0, ROOT_DIR) |
| 23 | 26 |
| 24 from recipe_engine import env | 27 from recipe_engine import env |
| 25 from recipe_engine import arguments_pb2 | 28 from recipe_engine import arguments_pb2 |
| 29 from recipe_engine import util as recipe_util | |
| 26 from google.protobuf import json_format as jsonpb | 30 from google.protobuf import json_format as jsonpb |
| 27 | 31 |
| 28 | 32 |
| 29 def get_package_config(args): | 33 def get_package_config(args): |
| 30 from recipe_engine import package | 34 from recipe_engine import package |
| 31 | 35 |
| 32 assert args.package, 'No recipe config (--package) given.' | 36 assert args.package, 'No recipe config (--package) given.' |
| 33 assert os.path.exists(args.package), ( | 37 assert os.path.exists(args.package), ( |
| 34 'Given recipes config file %s does not exist.' % args.package) | 38 'Given recipes config file %s does not exist.' % args.package) |
| 35 return ( | 39 return ( |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 225 properties = get_properties_from_json(args.properties) | 229 properties = get_properties_from_json(args.properties) |
| 226 elif args.properties_file: | 230 elif args.properties_file: |
| 227 properties = get_properties_from_file(args.properties_file) | 231 properties = get_properties_from_file(args.properties_file) |
| 228 elif op_properties is not None: | 232 elif op_properties is not None: |
| 229 properties = op_properties | 233 properties = op_properties |
| 230 else: | 234 else: |
| 231 properties = arg_properties | 235 properties = arg_properties |
| 232 | 236 |
| 233 properties['recipe'] = args.recipe | 237 properties['recipe'] = args.recipe |
| 234 | 238 |
| 239 properties = recipe_util.strip_unicode(properties) | |
| 240 | |
| 235 os.environ['PYTHONUNBUFFERED'] = '1' | 241 os.environ['PYTHONUNBUFFERED'] = '1' |
| 236 os.environ['PYTHONIOENCODING'] = 'UTF-8' | 242 os.environ['PYTHONIOENCODING'] = 'UTF-8' |
| 237 | 243 |
| 238 _, config_file = get_package_config(args) | 244 _, config_file = get_package_config(args) |
| 239 universe_view = loader.UniverseView( | 245 universe_view = loader.UniverseView( |
| 240 loader.RecipeUniverse( | 246 loader.RecipeUniverse( |
| 241 package_deps, config_file), package_deps.root_package) | 247 package_deps, config_file), package_deps.root_package) |
| 242 | 248 |
| 243 workdir = (args.workdir or | 249 workdir = (args.workdir or |
| 244 os.path.join(os.path.dirname(os.path.realpath(__file__)), 'workdir')) | 250 os.path.join(os.path.dirname(os.path.realpath(__file__)), 'workdir')) |
| (...skipping 517 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 762 | 768 |
| 763 if not isinstance(ret, int): | 769 if not isinstance(ret, int): |
| 764 if ret is None: | 770 if ret is None: |
| 765 ret = 0 | 771 ret = 0 |
| 766 else: | 772 else: |
| 767 print >> sys.stderr, ret | 773 print >> sys.stderr, ret |
| 768 ret = 1 | 774 ret = 1 |
| 769 sys.stdout.flush() | 775 sys.stdout.flush() |
| 770 sys.stderr.flush() | 776 sys.stderr.flush() |
| 771 os._exit(ret) | 777 os._exit(ret) |
| OLD | NEW |