| 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 22 matching lines...) Expand all Loading... |
| 33 | 33 |
| 34 class CalledProcessError(subprocess.CalledProcessError): | 34 class CalledProcessError(subprocess.CalledProcessError): |
| 35 """Augment the standard exception with more data.""" | 35 """Augment the standard exception with more data.""" |
| 36 def __init__(self, returncode, cmd, cwd, stdout, stderr): | 36 def __init__(self, returncode, cmd, cwd, stdout, stderr): |
| 37 super(CalledProcessError, self).__init__(returncode, cmd, output=stdout) | 37 super(CalledProcessError, self).__init__(returncode, cmd, output=stdout) |
| 38 self.stdout = self.output # for backward compatibility. | 38 self.stdout = self.output # for backward compatibility. |
| 39 self.stderr = stderr | 39 self.stderr = stderr |
| 40 self.cwd = cwd | 40 self.cwd = cwd |
| 41 | 41 |
| 42 def __str__(self): | 42 def __str__(self): |
| 43 out = 'Command %s returned non-zero exit status %s' % ( | 43 out = 'Command %r returned non-zero exit status %s' % ( |
| 44 ' '.join(self.cmd), self.returncode) | 44 ' '.join(self.cmd), self.returncode) |
| 45 if self.cwd: | 45 if self.cwd: |
| 46 out += ' in ' + self.cwd | 46 out += ' in ' + self.cwd |
| 47 return '\n'.join(filter(None, (out, self.stdout, self.stderr))) | 47 return '\n'.join(filter(None, (out, self.stdout, self.stderr))) |
| 48 | 48 |
| 49 | 49 |
| 50 class CygwinRebaseError(CalledProcessError): | 50 class CygwinRebaseError(CalledProcessError): |
| 51 """Occurs when cygwin's fork() emulation fails due to rebased dll.""" | 51 """Occurs when cygwin's fork() emulation fails due to rebased dll.""" |
| 52 | 52 |
| 53 | 53 |
| (...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 506 | 506 |
| 507 - Throws if return code is not 0. | 507 - Throws if return code is not 0. |
| 508 - Works even prior to python 2.7. | 508 - Works even prior to python 2.7. |
| 509 - Blocks stdin by default if not specified since no output will be visible. | 509 - Blocks stdin by default if not specified since no output will be visible. |
| 510 - As per doc, "The stdout argument is not allowed as it is used internally." | 510 - As per doc, "The stdout argument is not allowed as it is used internally." |
| 511 """ | 511 """ |
| 512 kwargs.setdefault('stdin', VOID) | 512 kwargs.setdefault('stdin', VOID) |
| 513 if 'stdout' in kwargs: | 513 if 'stdout' in kwargs: |
| 514 raise ValueError('stdout argument not allowed, it would be overridden.') | 514 raise ValueError('stdout argument not allowed, it would be overridden.') |
| 515 return check_call_out(args, stdout=PIPE, **kwargs)[0] | 515 return check_call_out(args, stdout=PIPE, **kwargs)[0] |
| OLD | NEW |