| 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 platform |
| 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, os.path.join(ROOT_DIR, 'recipe_engine', 'third_party')) | 21 sys.path.insert(0, os.path.join(ROOT_DIR, 'recipe_engine', 'third_party')) |
| 21 sys.path.insert(0, ROOT_DIR) | 22 sys.path.insert(0, ROOT_DIR) |
| 22 | 23 |
| 23 def get_package_config(args): | 24 def get_package_config(args): |
| 24 from recipe_engine import package | 25 from recipe_engine import package |
| (...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 383 args = parser.parse_args() | 384 args = parser.parse_args() |
| 384 | 385 |
| 385 if args.use_bootstrap and not os.environ.pop('RECIPES_RUN_BOOTSTRAP', None): | 386 if args.use_bootstrap and not os.environ.pop('RECIPES_RUN_BOOTSTRAP', None): |
| 386 subprocess.check_call( | 387 subprocess.check_call( |
| 387 [sys.executable, 'bootstrap/bootstrap.py', '--deps-file', | 388 [sys.executable, 'bootstrap/bootstrap.py', '--deps-file', |
| 388 'bootstrap/deps.pyl', 'ENV'], | 389 'bootstrap/deps.pyl', 'ENV'], |
| 389 cwd=os.path.dirname(os.path.realpath(__file__))) | 390 cwd=os.path.dirname(os.path.realpath(__file__))) |
| 390 | 391 |
| 391 os.environ['RECIPES_RUN_BOOTSTRAP'] = '1' | 392 os.environ['RECIPES_RUN_BOOTSTRAP'] = '1' |
| 392 args = sys.argv | 393 args = sys.argv |
| 393 return subprocess.call( | 394 executable = ('python.exe' if sys.platform.lower() in ( |
| 394 [os.path.join( | 395 'win32', 'cygwin') else 'python') |
| 395 os.path.dirname(os.path.realpath(__file__)), 'ENV/bin/python'), | 396 return subprocess.call([os.path.join( |
| 396 os.path.join(ROOT_DIR, 'recipes.py')] + original_sys_argv[1:]) | 397 ROOT_DIR, 'ENV', 'bin', executable), |
| 398 os.path.join(ROOT_DIR, 'recipes.py')] + original_sys_argv[1:]) |
| 397 | 399 |
| 398 if args.verbose: | 400 if args.verbose: |
| 399 logging.getLogger().setLevel(logging.INFO) | 401 logging.getLogger().setLevel(logging.INFO) |
| 400 | 402 |
| 401 # Commands which do not require config_file, package_deps, and other objects | 403 # Commands which do not require config_file, package_deps, and other objects |
| 402 # initialized later. | 404 # initialized later. |
| 403 if args.command == 'remote': | 405 if args.command == 'remote': |
| 404 return remote(args) | 406 return remote(args) |
| 405 | 407 |
| 406 repo_root, config_file = get_package_config(args) | 408 repo_root, config_file = get_package_config(args) |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 462 ret = main() | 464 ret = main() |
| 463 if not isinstance(ret, int): | 465 if not isinstance(ret, int): |
| 464 if ret is None: | 466 if ret is None: |
| 465 ret = 0 | 467 ret = 0 |
| 466 else: | 468 else: |
| 467 print >> sys.stderr, ret | 469 print >> sys.stderr, ret |
| 468 ret = 1 | 470 ret = 1 |
| 469 sys.stdout.flush() | 471 sys.stdout.flush() |
| 470 sys.stderr.flush() | 472 sys.stderr.flush() |
| 471 os._exit(ret) | 473 os._exit(ret) |
| OLD | NEW |