OLD | NEW |
---|---|
(Empty) | |
1 # Copyright 2015 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 import os | |
6 import subprocess | |
7 import threading | |
ghost stip (do not use)
2015/10/15 20:02:54
remove unused import
| |
8 | |
9 from infra.tools.cros_pin.logger import LOGGER | |
10 | |
11 | |
12 def call(cmd, cwd=None, dry_run=False): | |
ghost stip (do not use)
2015/10/15 20:02:54
this whole function seems overkill. this is just t
dnj
2015/10/15 21:06:41
Well, execute stuff and:
1) Print output to STDERR
| |
13 LOGGER.info("Executing command %s (cwd=%s)", cmd, (cwd or os.getcwd())) | |
14 if dry_run: | |
15 LOGGER.info('Dry Run: Not actually executing.') | |
16 return (0, "") | |
17 proc = subprocess.Popen( | |
18 cmd, | |
19 stdout=subprocess.PIPE, | |
20 stderr=subprocess.STDOUT, | |
21 cwd=cwd) | |
22 | |
23 output = [] | |
24 for line in iter(proc.stdout.readline, b''): | |
25 LOGGER.debug('[%s]: %s', cmd[0], line.rstrip()) | |
26 output.append(line) | |
27 | |
28 proc.wait() | |
29 return proc.returncode, ''.join(output) | |
30 | |
31 | |
32 def check_call(cmd, **kwargs): | |
33 rv, stdout = call(cmd, **kwargs) | |
34 if rv != 0: | |
35 raise subprocess.CalledProcessError(rv, cmd, None) | |
36 return stdout | |
OLD | NEW |