| OLD | NEW |
| 1 #!/usr/bin/python | |
| 2 # | |
| 3 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 4 # 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 |
| 5 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 6 | 4 |
| 7 """A wrapper for subprocess to make calling shell commands easier.""" | 5 """A wrapper for subprocess to make calling shell commands easier.""" |
| 8 | 6 |
| 9 | 7 |
| 10 import logging | 8 import logging |
| 11 import subprocess | 9 import subprocess |
| 12 | 10 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 43 Prints the command's stderr to logger (which defaults to stdout). | 41 Prints the command's stderr to logger (which defaults to stdout). |
| 44 """ | 42 """ |
| 45 logging.info(str(args) + ' ' + (cwd or '')) | 43 logging.info(str(args) + ' ' + (cwd or '')) |
| 46 p = subprocess.Popen(args=args, cwd=cwd, stdout=subprocess.PIPE, | 44 p = subprocess.Popen(args=args, cwd=cwd, stdout=subprocess.PIPE, |
| 47 stderr=subprocess.PIPE, shell=shell) | 45 stderr=subprocess.PIPE, shell=shell) |
| 48 stdout, stderr = p.communicate() | 46 stdout, stderr = p.communicate() |
| 49 if stderr: | 47 if stderr: |
| 50 logging.critical(stderr) | 48 logging.critical(stderr) |
| 51 logging.info(stdout[:4096]) # Truncate output longer than 4k. | 49 logging.info(stdout[:4096]) # Truncate output longer than 4k. |
| 52 return stdout | 50 return stdout |
| OLD | NEW |