OLD | NEW |
---|---|
(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 logging | |
8 import os | |
9 import shutil | |
10 import subprocess | |
11 import sys | |
12 import tempfile | |
13 | |
14 from recipe_engine import fetch | |
15 from recipe_engine import package | |
16 | |
17 | |
18 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.
| |
19 checkout_dir = os.path.join(args.workdir, 'checkout') | |
20 fetch.fetch_from_git(args.repository, args.revision, checkout_dir, | |
21 allow_fetch=True) | |
22 recipes_cfg = package.ProtoFile( | |
23 package.InfraRepoConfig().to_recipes_cfg(checkout_dir)) | |
24 cmd = [ | |
martiniss
2016/05/20 22:11:34
So, under the alternative logic, you would return
| |
25 sys.executable, | |
26 os.path.join(checkout_dir, recipes_cfg.read().recipes_path, 'recipes.py'), | |
27 'run' | |
28 ] + args.run_args | |
29 logging.info('Running %r', cmd) | |
30 return subprocess.call(cmd) | |
31 | |
32 | |
33 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
| |
34 workdir_tempdir = False | |
35 if not args.workdir: | |
36 workdir_tempdir = True | |
37 args.workdir = tempfile.mkdtemp(prefix='recipe_engine_remote_run_') | |
38 logging.info('Created temporary workdir %s', args.workdir) | |
39 | |
40 try: | |
41 return real_main(args) | |
42 finally: | |
43 if workdir_tempdir: | |
44 shutil.rmtree(args.workdir, ignore_errors=True) | |
OLD | NEW |