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

Unified Diff: build/android/pylib/cmd_helper.py

Issue 693943003: Update from https://crrev.com/302630 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years, 1 month 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 | « build/android/pylib/base/base_test_runner.py ('k') | build/android/pylib/device/commands/BUILD.gn » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: build/android/pylib/cmd_helper.py
diff --git a/build/android/pylib/cmd_helper.py b/build/android/pylib/cmd_helper.py
index ab9105411c784b31a9d2e72e4b91648689035057..e3abab74ffda3087eb239cddd850bbb874383161 100644
--- a/build/android/pylib/cmd_helper.py
+++ b/build/android/pylib/cmd_helper.py
@@ -115,6 +115,16 @@ def GetCmdOutput(args, cwd=None, shell=False):
return output
+def _LogCommand(args, cwd=None):
+ if not isinstance(args, basestring):
+ args = ' '.join(SingleQuote(c) for c in args)
+ if cwd is None:
+ cwd = ''
+ else:
+ cwd = ':' + cwd
+ logging.info('[host]%s> %s', cwd, args)
+
+
def GetCmdStatusAndOutput(args, cwd=None, shell=False):
"""Executes a subprocess and returns its exit code and output.
@@ -129,19 +139,12 @@ def GetCmdStatusAndOutput(args, cwd=None, shell=False):
The 2-tuple (exit code, output).
"""
if isinstance(args, basestring):
- args_repr = args
if not shell:
raise Exception('string args must be run with shell=True')
elif shell:
raise Exception('array args must be run with shell=False')
- else:
- args_repr = ' '.join(map(SingleQuote, args))
- s = '[host]'
- if cwd:
- s += ':' + cwd
- s += '> ' + args_repr
- logging.info(s)
+ _LogCommand(args, cwd)
pipe = Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE,
shell=shell, cwd=cwd)
stdout, stderr = pipe.communicate()
@@ -177,6 +180,13 @@ def GetCmdStatusAndOutputWithTimeout(args, timeout, cwd=None, shell=False,
The 2-tuple (exit code, output).
"""
assert fcntl, 'fcntl module is required'
+ if isinstance(args, basestring):
+ if not shell:
+ raise Exception('string args must be run with shell=True')
+ elif shell:
+ raise Exception('array args must be run with shell=False')
+
+ _LogCommand(args, cwd)
process = Popen(args, cwd=cwd, shell=shell, stdout=subprocess.PIPE,
stderr=subprocess.STDOUT)
try:
« no previous file with comments | « build/android/pylib/base/base_test_runner.py ('k') | build/android/pylib/device/commands/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698