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

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

Issue 11312239: Modify the Android test running scripts so they can be used from WebKit (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 """A wrapper for subprocess to make calling shell commands easier.""" 5 """A wrapper for subprocess to make calling shell commands easier."""
6 6
7 7 import os
8 import logging 8 import logging
9 import subprocess 9 import subprocess
10 10
11 import constants
11 12
12 def RunCmd(args, cwd=None): 13 def RunCmd(args, cwd=None):
13 """Opens a subprocess to execute a program and returns its return value. 14 """Opens a subprocess to execute a program and returns its return value.
14 15
15 Args: 16 Args:
16 args: A string or a sequence of program arguments. The program to execute is 17 args: A string or a sequence of program arguments. The program to execute is
17 the string or the first item in the args sequence. 18 the string or the first item in the args sequence.
18 cwd: If not None, the subprocess's current directory will be changed to 19 cwd: If not None, the subprocess's current directory will be changed to
19 |cwd| before it's executed. 20 |cwd| before it's executed.
20 21
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 """ 59 """
59 logging.info(str(args) + ' ' + (cwd or '')) 60 logging.info(str(args) + ' ' + (cwd or ''))
60 p = subprocess.Popen(args=args, cwd=cwd, stdout=subprocess.PIPE, 61 p = subprocess.Popen(args=args, cwd=cwd, stdout=subprocess.PIPE,
61 stderr=subprocess.PIPE, shell=shell) 62 stderr=subprocess.PIPE, shell=shell)
62 stdout, stderr = p.communicate() 63 stdout, stderr = p.communicate()
63 exit_code = p.returncode 64 exit_code = p.returncode
64 if stderr: 65 if stderr:
65 logging.critical(stderr) 66 logging.critical(stderr)
66 logging.info(stdout[:4096]) # Truncate output longer than 4k. 67 logging.info(stdout[:4096]) # Truncate output longer than 4k.
67 return (exit_code, stdout) 68 return (exit_code, stdout)
69
70 def OutDirectory():
71 return os.environ.get('ANDROID_TEST_OUT_DIRECTORY', constants.CHROME_DIR)
bulach 2012/11/15 01:06:39 sorry, when I mentioned to use an environment vari
Peter Beverloo 2012/11/15 12:11:29 Seems good to me, thank you! Done. In general we'r
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698