| OLD | NEW |
| 1 # coding=utf8 | 1 # coding=utf8 |
| 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 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 """Collection of subprocess wrapper functions. | 5 """Collection of subprocess wrapper functions. |
| 6 | 6 |
| 7 In theory you shouldn't need anything else in subprocess, or this module failed. | 7 In theory you shouldn't need anything else in subprocess, or this module failed. |
| 8 """ | 8 """ |
| 9 | 9 |
| 10 import cStringIO | 10 import cStringIO |
| (...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 348 # When the pipe fills up, it would deadlock this process. | 348 # When the pipe fills up, it would deadlock this process. |
| 349 if self.stdout and not self.stdout_cb and not self.stdout_is_void: | 349 if self.stdout and not self.stdout_cb and not self.stdout_is_void: |
| 350 stdout = [] | 350 stdout = [] |
| 351 self.stdout_cb = stdout.append | 351 self.stdout_cb = stdout.append |
| 352 if self.stderr and not self.stderr_cb and not self.stderr_is_void: | 352 if self.stderr and not self.stderr_cb and not self.stderr_is_void: |
| 353 stderr = [] | 353 stderr = [] |
| 354 self.stderr_cb = stderr.append | 354 self.stderr_cb = stderr.append |
| 355 self._tee_threads(input) | 355 self._tee_threads(input) |
| 356 if stdout is not None: | 356 if stdout is not None: |
| 357 stdout = ''.join(stdout) | 357 stdout = ''.join(stdout) |
| 358 stderr = None | |
| 359 if stderr is not None: | 358 if stderr is not None: |
| 360 stderr = ''.join(stderr) | 359 stderr = ''.join(stderr) |
| 361 return (stdout, stderr) | 360 return (stdout, stderr) |
| 362 | 361 |
| 363 | 362 |
| 364 def communicate(args, timeout=None, **kwargs): | 363 def communicate(args, timeout=None, **kwargs): |
| 365 """Wraps subprocess.Popen().communicate() and add timeout support. | 364 """Wraps subprocess.Popen().communicate() and add timeout support. |
| 366 | 365 |
| 367 Returns ((stdout, stderr), returncode). | 366 Returns ((stdout, stderr), returncode). |
| 368 | 367 |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 440 | 439 |
| 441 - Throws if return code is not 0. | 440 - Throws if return code is not 0. |
| 442 - Works even prior to python 2.7. | 441 - Works even prior to python 2.7. |
| 443 - Blocks stdin by default if not specified since no output will be visible. | 442 - Blocks stdin by default if not specified since no output will be visible. |
| 444 - As per doc, "The stdout argument is not allowed as it is used internally." | 443 - As per doc, "The stdout argument is not allowed as it is used internally." |
| 445 """ | 444 """ |
| 446 kwargs.setdefault('stdin', VOID) | 445 kwargs.setdefault('stdin', VOID) |
| 447 if 'stdout' in kwargs: | 446 if 'stdout' in kwargs: |
| 448 raise ValueError('stdout argument not allowed, it will be overridden.') | 447 raise ValueError('stdout argument not allowed, it will be overridden.') |
| 449 return check_call_out(args, stdout=PIPE, **kwargs)[0] | 448 return check_call_out(args, stdout=PIPE, **kwargs)[0] |
| OLD | NEW |