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..22f21feb46670ef6f20fed5a82f43b6de2adbd74 |
--- /dev/null |
+++ b/recipe_engine/remote_run.py |
@@ -0,0 +1,44 @@ |
+# 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 logging |
+import os |
+import shutil |
+import subprocess |
+import sys |
+import tempfile |
+ |
+from recipe_engine import fetch |
+from recipe_engine import package |
+ |
+ |
+def real_main(args): |
nodir
2016/05/20 23:03:49
a more elegant solution would be to use a context
Paweł Hajdan Jr.
2016/05/25 00:15:42
Good point, done.
|
+ checkout_dir = os.path.join(args.workdir, 'checkout') |
+ fetch.fetch_from_git(args.repository, args.revision, checkout_dir, |
+ allow_fetch=True) |
+ recipes_cfg = package.ProtoFile( |
+ package.InfraRepoConfig().to_recipes_cfg(checkout_dir)) |
+ cmd = [ |
martiniss
2016/05/20 22:11:34
So, under the alternative logic, you would return
|
+ 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) |
+ |
+ |
+def main(args): |
nodir
2016/05/20 23:03:49
document that args is result of parsing by remote_
Paweł Hajdan Jr.
2016/05/25 00:15:41
Whoa, does any other command do this? I'm not conv
|
+ 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: |
+ return real_main(args) |
+ finally: |
+ if workdir_tempdir: |
+ shutil.rmtree(args.workdir, ignore_errors=True) |