OLD | NEW |
1 # coding=utf8 | 1 # coding=utf8 |
2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2011 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 from __future__ import with_statement | 10 from __future__ import with_statement |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 # Create a temporary file to workaround python's deadlock. | 175 # Create a temporary file to workaround python's deadlock. |
176 # http://docs.python.org/library/subprocess.html#subprocess.Popen.wait | 176 # http://docs.python.org/library/subprocess.html#subprocess.Popen.wait |
177 # When the pipe fills up, it will deadlock this process. Using a real | 177 # When the pipe fills up, it will deadlock this process. Using a real |
178 # file works around that issue. | 178 # file works around that issue. |
179 kwargs[stream] = open(os.devnull, 'w') | 179 kwargs[stream] = open(os.devnull, 'w') |
180 | 180 |
181 fix('stdout') | 181 fix('stdout') |
182 fix('stderr') | 182 fix('stderr') |
183 | 183 |
184 self.start = time.time() | 184 self.start = time.time() |
185 | 185 # Silence pylint on MacOSX |
| 186 self.returncode = None |
186 try: | 187 try: |
187 super(Popen, self).__init__(args, **kwargs) | 188 super(Popen, self).__init__(args, **kwargs) |
188 except OSError, e: | 189 except OSError, e: |
189 if e.errno == errno.EAGAIN and sys.platform == 'cygwin': | 190 if e.errno == errno.EAGAIN and sys.platform == 'cygwin': |
190 # Convert fork() emulation failure into a CygwinRebaseError(). | 191 # Convert fork() emulation failure into a CygwinRebaseError(). |
191 raise CygwinRebaseError( | 192 raise CygwinRebaseError( |
192 e.errno, | 193 e.errno, |
193 args, | 194 args, |
194 kwargs.get('cwd'), | 195 kwargs.get('cwd'), |
195 None, | 196 None, |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
306 | 307 |
307 - Throws if return code is not 0. | 308 - Throws if return code is not 0. |
308 - Works even prior to python 2.7. | 309 - Works even prior to python 2.7. |
309 - Blocks stdin by default if not specified since no output will be visible. | 310 - Blocks stdin by default if not specified since no output will be visible. |
310 - As per doc, "The stdout argument is not allowed as it is used internally." | 311 - As per doc, "The stdout argument is not allowed as it is used internally." |
311 """ | 312 """ |
312 kwargs.setdefault('stdin', VOID) | 313 kwargs.setdefault('stdin', VOID) |
313 if 'stdout' in kwargs: | 314 if 'stdout' in kwargs: |
314 raise ValueError('stdout argument not allowed, it will be overridden.') | 315 raise ValueError('stdout argument not allowed, it will be overridden.') |
315 return check_call_out(args, stdout=PIPE, **kwargs)[0] | 316 return check_call_out(args, stdout=PIPE, **kwargs)[0] |
OLD | NEW |