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

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

Issue 13799010: [Android] Reduce test logging verbosity. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 8 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
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 import os 7 import os
8 import logging 8 import logging
9 import signal 9 import signal
10 import subprocess 10 import subprocess
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 Args: 60 Args:
61 args: A string or a sequence of program arguments. The program to execute is 61 args: A string or a sequence of program arguments. The program to execute is
62 the string or the first item in the args sequence. 62 the string or the first item in the args sequence.
63 cwd: If not None, the subprocess's current directory will be changed to 63 cwd: If not None, the subprocess's current directory will be changed to
64 |cwd| before it's executed. 64 |cwd| before it's executed.
65 shell: Whether to execute args as a shell command. 65 shell: Whether to execute args as a shell command.
66 66
67 Returns: 67 Returns:
68 The tuple (exit code, output). 68 The tuple (exit code, output).
69 """ 69 """
70 logging.info(str(args) + ' ' + (cwd or '')) 70 if isinstance(args, basestring):
71 args_repr = args
72 if not shell:
73 raise Exception('string args must be run with shell=True')
74 elif shell:
75 raise Exception('array args must be run with shell=False')
76 else:
77 args_repr = ' '.join(args)
Isaac (away) 2013/04/10 19:12:53 maybe use ' '.join(map(pipes.quote, args)) This w
frankf 2013/04/10 21:29:42 Done. Although the doc says it's deprecated.
78
79 s = '[host]'
80 if cwd:
81 s += ':' + cwd
82 s += '> ' + args_repr
83 logging.info(s)
Isaac (away) 2013/04/10 19:12:53 put this and the join behind a guard that checks l
craigdh 2013/04/10 20:39:49 I don't think the code complexity tradeoff is wort
frankf 2013/04/10 21:29:42 Agreed. On 2013/04/10 20:39:49, craigdh wrote:
71 tmpout = tempfile.TemporaryFile(bufsize=0) 84 tmpout = tempfile.TemporaryFile(bufsize=0)
72 tmperr = tempfile.TemporaryFile(bufsize=0) 85 tmperr = tempfile.TemporaryFile(bufsize=0)
73 exit_code = _Call(args, cwd=cwd, stdout=tmpout, stderr=tmperr, shell=shell) 86 exit_code = _Call(args, cwd=cwd, stdout=tmpout, stderr=tmperr, shell=shell)
74 tmperr.seek(0) 87 tmperr.seek(0)
75 stderr = tmperr.read() 88 stderr = tmperr.read()
76 tmperr.close() 89 tmperr.close()
77 if stderr: 90 if stderr:
78 logging.critical(stderr) 91 logging.critical(stderr)
79 tmpout.seek(0) 92 tmpout.seek(0)
80 stdout = tmpout.read() 93 stdout = tmpout.read()
81 tmpout.close() 94 tmpout.close()
82 logging.info(stdout[:4096]) # Truncate output longer than 4k. 95 logging.debug(stdout[:4096]) # Truncate output longer than 4k.
craigdh 2013/04/10 20:39:49 maybe append a note that the output was truncated
frankf 2013/04/10 21:29:42 Done.
83 return (exit_code, stdout) 96 return (exit_code, stdout)
84 97
85 98
86 class OutDirectory(object): 99 class OutDirectory(object):
87 _out_directory = os.path.join(constants.CHROME_DIR, 'out') 100 _out_directory = os.path.join(constants.CHROME_DIR, 'out')
88 @staticmethod 101 @staticmethod
89 def set(out_directory): 102 def set(out_directory):
90 OutDirectory._out_directory = out_directory 103 OutDirectory._out_directory = out_directory
91 @staticmethod 104 @staticmethod
92 def get(): 105 def get():
93 return OutDirectory._out_directory 106 return OutDirectory._out_directory
OLDNEW
« build/android/pylib/android_commands.py ('K') | « build/android/pylib/android_commands.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698