| OLD | NEW |
| 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 # 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 |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 """A wrapper for subprocess to make calling shell commands easier.""" | 5 """A wrapper for subprocess to make calling shell commands easier.""" |
| 6 | 6 |
| 7 import logging | 7 import logging |
| 8 import pipes | 8 import pipes |
| 9 import signal | 9 import signal |
| 10 import subprocess | 10 import subprocess |
| 11 import tempfile | 11 import tempfile |
| 12 | 12 |
| 13 from pylib.utils import timeout_retry | 13 from utils import timeout_retry |
| 14 | 14 |
| 15 | 15 |
| 16 def Popen(args, stdout=None, stderr=None, shell=None, cwd=None, env=None): | 16 def Popen(args, stdout=None, stderr=None, shell=None, cwd=None, env=None): |
| 17 return subprocess.Popen( | 17 return subprocess.Popen( |
| 18 args=args, cwd=cwd, stdout=stdout, stderr=stderr, | 18 args=args, cwd=cwd, stdout=stdout, stderr=stderr, |
| 19 shell=shell, close_fds=True, env=env, | 19 shell=shell, close_fds=True, env=env, |
| 20 preexec_fn=lambda: signal.signal(signal.SIGPIPE, signal.SIG_DFL)) | 20 preexec_fn=lambda: signal.signal(signal.SIGPIPE, signal.SIG_DFL)) |
| 21 | 21 |
| 22 | 22 |
| 23 def Call(args, stdout=None, stderr=None, shell=None, cwd=None, env=None): | 23 def Call(args, stdout=None, stderr=None, shell=None, cwd=None, env=None): |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 Args: | 111 Args: |
| 112 args: List of arguments to the program, the program to execute is the first | 112 args: List of arguments to the program, the program to execute is the first |
| 113 element. | 113 element. |
| 114 timeout: the timeout in seconds. | 114 timeout: the timeout in seconds. |
| 115 retries: the number of retries. | 115 retries: the number of retries. |
| 116 | 116 |
| 117 Returns: | 117 Returns: |
| 118 The 2-tuple (exit code, output). | 118 The 2-tuple (exit code, output). |
| 119 """ | 119 """ |
| 120 return timeout_retry.Run(GetCmdStatusAndOutput, timeout, retries, [args]) | 120 return timeout_retry.Run(GetCmdStatusAndOutput, timeout, retries, [args]) |
| OLD | NEW |