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

Side by Side Diff: recipe_engine/remote.py

Issue 2080343005: Add 'remote' command to replace 'remote_run' (Closed) Base URL: https://github.com/luci/recipes-py.git@master
Patch Set: Created 4 years, 6 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 | « no previous file | recipes.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
11 import subprocess 11 import subprocess
12 import sys 12 import sys
13 import tempfile 13 import tempfile
14 14
15 from recipe_engine import fetch 15 from recipe_engine import fetch
16 from recipe_engine import package 16 from recipe_engine import package
17 17
18 18
19 @contextlib.contextmanager 19 @contextlib.contextmanager
20 def ensure_workdir(args): 20 def ensure_workdir(args):
21 workdir_tempdir = False 21 workdir_tempdir = False
22 if not args.workdir: 22 if not args.workdir:
23 workdir_tempdir = True 23 workdir_tempdir = True
24 args.workdir = tempfile.mkdtemp(prefix='recipe_engine_remote_run_') 24 args.workdir = tempfile.mkdtemp(prefix='recipe_engine_remote_')
25 logging.info('Created temporary workdir %s', args.workdir) 25 logging.info('Created temporary workdir %s', args.workdir)
26 26
27 try: 27 try:
28 yield 28 yield
29 finally: 29 finally:
30 if workdir_tempdir: 30 if workdir_tempdir:
31 shutil.rmtree(args.workdir, ignore_errors=True) 31 shutil.rmtree(args.workdir, ignore_errors=True)
32 32
33 33
34 def main(args): 34 def main(args):
35 with ensure_workdir(args): 35 with ensure_workdir(args):
36 checkout_dir = os.path.join(args.workdir, 'checkout') 36 checkout_dir = os.path.join(args.workdir, 'checkout')
37 if args.use_gitiles: 37 if args.use_gitiles:
38 args.revision = args.revision or 'HEAD' 38 args.revision = args.revision or 'HEAD'
39 backend = fetch.GitilesBackend() 39 backend = fetch.GitilesBackend()
40 else: 40 else:
41 args.revision = args.revision or 'FETCH_HEAD' 41 args.revision = args.revision or 'FETCH_HEAD'
42 backend = fetch.GitBackend() 42 backend = fetch.GitBackend()
43 backend.checkout( 43 backend.checkout(
44 args.repository, args.revision, checkout_dir, allow_fetch=True) 44 args.repository, args.revision, checkout_dir, allow_fetch=True)
45 recipes_cfg = package.ProtoFile( 45 recipes_cfg = package.ProtoFile(
46 package.InfraRepoConfig().to_recipes_cfg(checkout_dir)) 46 package.InfraRepoConfig().to_recipes_cfg(checkout_dir))
47 cmd = [ 47 cmd = [
48 sys.executable, 48 sys.executable,
49 os.path.join( 49 os.path.join(
50 checkout_dir, 50 checkout_dir,
51 recipes_cfg.read().recipes_path, 51 recipes_cfg.read().recipes_path,
52 'recipes.py'), 52 'recipes.py'),
53 'run' 53 ] + args.remote_args
54 ] + args.run_args
55 logging.info('Running %r', cmd) 54 logging.info('Running %r', cmd)
56 return subprocess.call(cmd) 55 return subprocess.call(cmd)
OLDNEW
« no previous file with comments | « no previous file | recipes.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698