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

Side by Side Diff: scripts/run_cmd.py

Issue 196133010: MOAR debugging: Print stdout,stderr line by line (Closed) Base URL: https://skia.googlesource.com/buildbot.git@master
Patch Set: Created 6 years, 9 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright (c) 2014 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2014 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 6
7 """Run a command and report its results in machine-readable format.""" 7 """Run a command and report its results in machine-readable format."""
8 8
9 9
10 import collections 10 import collections
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 178
179 179
180 def _get_result(popen): 180 def _get_result(popen):
181 """Get the results from a running process. Blocks until the process completes. 181 """Get the results from a running process. Blocks until the process completes.
182 182
183 Args: 183 Args:
184 popen: subprocess.Popen instance. 184 popen: subprocess.Popen instance.
185 Returns: 185 Returns:
186 A dictionary with stdout, stderr, and returncode as keys. 186 A dictionary with stdout, stderr, and returncode as keys.
187 """ 187 """
188 print popen.stdout.read() 188 for fd in (popen.stdout, popen.stderr):
189 print popen.stderr.read() 189 for line in iter(fd.readline, ''):
190 print line
190 stdout, stderr = popen.communicate() 191 stdout, stderr = popen.communicate()
191 return CommandResults.make(stdout=stdout, 192 return CommandResults.make(stdout=stdout,
192 stderr=stderr, 193 stderr=stderr,
193 returncode=popen.returncode) 194 returncode=popen.returncode)
194 195
195 196
196 def run(cmd): 197 def run(cmd):
197 """Run the command, block until it completes, and return a results dictionary. 198 """Run the command, block until it completes, and return a results dictionary.
198 199
199 Args: 200 Args:
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 setattr(options, cmd, args) 353 setattr(options, cmd, args)
353 except IndexError: 354 except IndexError:
354 parser.print_usage() 355 parser.print_usage()
355 sys.exit(1) 356 sys.exit(1)
356 return options 357 return options
357 358
358 359
359 if '__main__' == __name__: 360 if '__main__' == __name__:
360 parsed_args = parse_args() 361 parsed_args = parse_args()
361 run(parsed_args.cmd).print_results(pretty=parsed_args.pretty) 362 run(parsed_args.cmd).print_results(pretty=parsed_args.pretty)
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698