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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « recipe_engine/package.py ('k') | recipe_engine/unittests/fetch_test.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: recipe_engine/remote_run.py
diff --git a/recipe_engine/remote_run.py b/recipe_engine/remote_run.py
new file mode 100644
index 0000000000000000000000000000000000000000..c5deaf5f0471ad86fca2f7956e85207c365e83e6
--- /dev/null
+++ b/recipe_engine/remote_run.py
@@ -0,0 +1,50 @@
+# Copyright 2016 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+from __future__ import print_function
+
+import contextlib
+import logging
+import os
+import shutil
+import subprocess
+import sys
+import tempfile
+
+from recipe_engine import fetch
+from recipe_engine import package
+
+
+@contextlib.contextmanager
+def ensure_workdir(args):
+ workdir_tempdir = False
+ if not args.workdir:
+ workdir_tempdir = True
+ args.workdir = tempfile.mkdtemp(prefix='recipe_engine_remote_run_')
+ logging.info('Created temporary workdir %s', args.workdir)
+
+ try:
+ yield
+ finally:
+ if workdir_tempdir:
+ shutil.rmtree(args.workdir, ignore_errors=True)
+
+
+def main(args):
+ with ensure_workdir(args):
+ checkout_dir = os.path.join(args.workdir, 'checkout')
+ fetch.ensure_git_checkout(
+ args.repository, args.revision, checkout_dir, allow_fetch=True)
+ recipes_cfg = package.ProtoFile(
+ package.InfraRepoConfig().to_recipes_cfg(checkout_dir))
+ cmd = [
+ sys.executable,
+ os.path.join(
+ checkout_dir,
+ recipes_cfg.read().recipes_path,
+ 'recipes.py'),
+ 'run'
+ ] + args.run_args
+ logging.info('Running %r', cmd)
+ return subprocess.call(cmd)
« 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