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

Unified Diff: build/android/cmd_helper.py

Issue 10578032: Upstreaming android build tools (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed lint issues Created 8 years, 6 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 | « build/android/adb_logcat_printer.py ('k') | build/android/device_status_check.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: build/android/cmd_helper.py
diff --git a/build/android/cmd_helper.py b/build/android/cmd_helper.py
index 901cbe9aed76e110da5f2c06bc652fcda522fb00..ec9163a120192ea761b88984fbdeae0828a5e366 100644
--- a/build/android/cmd_helper.py
+++ b/build/android/cmd_helper.py
@@ -1,7 +1,11 @@
+#!/usr/bin/python
+#
# Copyright (c) 2011 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.
+"""A wrapper for subprocess to make calling shell commands easier."""
+
import logging
import subprocess
@@ -15,13 +19,16 @@ def RunCmd(args, cwd=None):
the string or the first item in the args sequence.
cwd: If not None, the subprocess's current directory will be changed to
|cwd| before it's executed.
+
+ Returns:
+ Return code from the command execution.
"""
logging.info(str(args) + ' ' + (cwd or ''))
p = subprocess.Popen(args=args, cwd=cwd)
return p.wait()
-def GetCmdOutput(args, cwd=None):
+def GetCmdOutput(args, cwd=None, shell=False):
"""Open a subprocess to execute a program and returns its output.
Args:
@@ -29,10 +36,15 @@ def GetCmdOutput(args, cwd=None):
the string or the first item in the args sequence.
cwd: If not None, the subprocess's current directory will be changed to
|cwd| before it's executed.
+ shell: Whether to execute args as a shell command.
+
+ Returns:
+ Captures and returns the command's stdout.
+ Prints the command's stderr to logger (which defaults to stdout).
"""
logging.info(str(args) + ' ' + (cwd or ''))
p = subprocess.Popen(args=args, cwd=cwd, stdout=subprocess.PIPE,
- stderr=subprocess.PIPE)
+ stderr=subprocess.PIPE, shell=shell)
stdout, stderr = p.communicate()
if stderr:
logging.critical(stderr)
« no previous file with comments | « build/android/adb_logcat_printer.py ('k') | build/android/device_status_check.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698