Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(917)

Side by Side Diff: recipe_engine/remote.py

Issue 2845923002: [recipes.py] use argparse to set command automatically. (Closed)
Patch Set: rebase Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « recipe_engine/refs.py ('k') | recipe_engine/run.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2016 The LUCI Authors. All rights reserved. 1 # Copyright 2016 The LUCI Authors. All rights reserved.
2 # Use of this source code is governed under the Apache License, Version 2.0 2 # Use of this source code is governed under the Apache License, Version 2.0
3 # that can be found in the LICENSE file. 3 # that can be found in the LICENSE file.
4 4
5 from __future__ import print_function 5 from __future__ import print_function
6 6
7 import contextlib 7 import contextlib
8 import logging 8 import logging
9 import os 9 import os
10 import shutil 10 import shutil
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 help='The working directory of repo checkout') 51 help='The working directory of repo checkout')
52 remote_p.add_argument( 52 remote_p.add_argument(
53 '--use-gitiles', action='store_true', 53 '--use-gitiles', action='store_true',
54 help='Use Gitiles-specific way to fetch repo (potentially cheaper for ' 54 help='Use Gitiles-specific way to fetch repo (potentially cheaper for '
55 'large repos)') 55 'large repos)')
56 remote_p.add_argument( 56 remote_p.add_argument(
57 'remote_args', nargs='*', 57 'remote_args', nargs='*',
58 help='Arguments to pass to fetched repo\'s recipes.py') 58 help='Arguments to pass to fetched repo\'s recipes.py')
59 59
60 remote_p.set_defaults( 60 remote_p.set_defaults(
61 command='remote',
62 bare_command=True, 61 bare_command=True,
63 func=main, 62 func=main,
64 ) 63 )
65 64
66 65
67 def main(_package_deps, args): 66 def main(_package_deps, args):
68 with ensure_workdir(args): 67 with ensure_workdir(args):
69 checkout_dir = os.path.join(args.workdir, 'checkout') 68 checkout_dir = os.path.join(args.workdir, 'checkout')
70 revision = args.revision or 'refs/heads/master' 69 revision = args.revision or 'refs/heads/master'
71 if args.use_gitiles: 70 if args.use_gitiles:
72 backend_class = fetch.GitilesBackend 71 backend_class = fetch.GitilesBackend
73 else: 72 else:
74 backend_class = fetch.GitBackend 73 backend_class = fetch.GitBackend
75 backend = backend_class(checkout_dir, args.repository, True) 74 backend = backend_class(checkout_dir, args.repository, True)
76 backend.checkout(revision) 75 backend.checkout(revision)
77 recipes_cfg = package_io.PackageFile( 76 recipes_cfg = package_io.PackageFile(
78 package.InfraRepoConfig().to_recipes_cfg(checkout_dir)) 77 package.InfraRepoConfig().to_recipes_cfg(checkout_dir))
79 cmd = [ 78 cmd = [
80 sys.executable, 79 sys.executable,
81 os.path.join( 80 os.path.join(
82 checkout_dir, 81 checkout_dir,
83 recipes_cfg.read().recipes_path, 82 recipes_cfg.read().recipes_path,
84 'recipes.py'), 83 'recipes.py'),
85 ] + args.remote_args 84 ] + args.remote_args
86 logging.info('Running %r', cmd) 85 logging.info('Running %r', cmd)
87 return subprocess.call(cmd) 86 return subprocess.call(cmd)
OLDNEW
« no previous file with comments | « recipe_engine/refs.py ('k') | recipe_engine/run.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698