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

Side by Side Diff: build/android/cmd_helper.py

Issue 8356013: Upstream: Test scripts for Android (phase 1) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments Created 9 years, 2 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « build/android/android_commands.py ('k') | build/android/debug_info.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 #!/usr/bin/python
2 # Copyright (c) 2011 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file.
5
6
7 import logging
8 import subprocess
9
10
11 def RunCmd(args, cwd=None):
12 """Opens a subprocess to execute a program and returns its return value.
13
14 Args:
15 args: A string or a sequence of program arguments. The program to execute is
16 the string or the first item in the args sequence.
17 cwd: If not None, the subprocess's current directory will be changed to
18 |cwd| before it's executed.
19 """
20 logging.info(str(args) + ' ' + (cwd or ''))
21 p = subprocess.Popen(args=args, cwd=cwd)
22 return p.wait()
23
24
25 def GetCmdOutput(args, cwd=None):
26 """Open a subprocess to execute a program and returns its output.
27
28 Args:
29 args: A string or a sequence of program arguments. The program to execute is
30 the string or the first item in the args sequence.
31 cwd: If not None, the subprocess's current directory will be changed to
32 |cwd| before it's executed.
33 """
34 logging.info(str(args) + ' ' + (cwd or ''))
35 p = subprocess.Popen(args=args, cwd=cwd, stdout=subprocess.PIPE,
36 stderr=subprocess.PIPE)
37 stdout, stderr = p.communicate()
38 if stderr:
39 logging.critical(stderr)
40 logging.info(stdout[:4096]) # Truncate output longer than 4k.
41 return stdout
OLDNEW
« no previous file with comments | « build/android/android_commands.py ('k') | build/android/debug_info.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698