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