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