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

Side by Side Diff: recipe_engine/remote_run.py

Issue 1997023002: recipe engine: add remote_run command (Closed) Base URL: https://github.com/luci/recipes-py.git@master
Patch Set: trybots Created 4 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/package.py ('k') | recipe_engine/unittests/fetch_test.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 # Copyright 2016 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
4
5 from __future__ import print_function
6
7 import contextlib
8 import logging
9 import os
10 import shutil
11 import subprocess
12 import sys
13 import tempfile
14
15 from recipe_engine import fetch
16 from recipe_engine import package
17
18
19 @contextlib.contextmanager
20 def ensure_workdir(args):
21 workdir_tempdir = False
22 if not args.workdir:
23 workdir_tempdir = True
24 args.workdir = tempfile.mkdtemp(prefix='recipe_engine_remote_run_')
25 logging.info('Created temporary workdir %s', args.workdir)
26
27 try:
28 yield
29 finally:
30 if workdir_tempdir:
31 shutil.rmtree(args.workdir, ignore_errors=True)
32
33
34 def main(args):
35 with ensure_workdir(args):
36 checkout_dir = os.path.join(args.workdir, 'checkout')
37 fetch.ensure_git_checkout(
38 args.repository, args.revision, checkout_dir, allow_fetch=True)
39 recipes_cfg = package.ProtoFile(
40 package.InfraRepoConfig().to_recipes_cfg(checkout_dir))
41 cmd = [
42 sys.executable,
43 os.path.join(
44 checkout_dir,
45 recipes_cfg.read().recipes_path,
46 'recipes.py'),
47 'run'
48 ] + args.run_args
49 logging.info('Running %r', cmd)
50 return subprocess.call(cmd)
OLDNEW
« no previous file with comments | « recipe_engine/package.py ('k') | recipe_engine/unittests/fetch_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698