Chromium Code Reviews| Index: build/android/pylib/cmd_helper.py |
| diff --git a/build/android/pylib/cmd_helper.py b/build/android/pylib/cmd_helper.py |
| index dba399f8193f333ebcc94a880cb540ba83d90976..102a6021dead490536ac301341de1b035cb5652a 100644 |
| --- a/build/android/pylib/cmd_helper.py |
| +++ b/build/android/pylib/cmd_helper.py |
| @@ -4,14 +4,13 @@ |
| """A wrapper for subprocess to make calling shell commands easier.""" |
| -import os |
| import logging |
| import pipes |
| import signal |
| import subprocess |
| import tempfile |
| -import constants |
| +from utils import timeout_retry |
| def Popen(args, stdout=None, stderr=None, shell=None, cwd=None, env=None): |
| @@ -73,7 +72,7 @@ def GetCmdStatusAndOutput(args, cwd=None, shell=False): |
| shell: Whether to execute args as a shell command. |
| Returns: |
| - The tuple (exit code, output). |
| + The 2-tuple (exit code, output). |
| """ |
| if isinstance(args, basestring): |
| args_repr = args |
| @@ -104,3 +103,18 @@ def GetCmdStatusAndOutput(args, cwd=None, shell=False): |
| logging.debug('Truncated output:') |
| logging.debug(stdout[:4096]) |
| return (exit_code, stdout) |
| + |
| + |
| +def RunWithTimeoutAndRetries(args, timeout, retries): |
|
frankf
2013/11/14 23:26:05
Can we combline RunWithTimeoutAndRetries, GetCmdSt
craigdh
2013/11/15 00:26:30
While I completely agree this should be done, it's
frankf
2013/11/15 23:08:47
Can you at least match naming convention GetCmd...
craigdh
2013/11/15 23:41:57
Done.
|
| + """Executes a subprocess with a timeout and retries. |
| + |
| + Args: |
| + args: List of arguments to the program, the program to execute is the first |
| + element. |
| + timeout: the timeout in seconds. |
| + retries: the number of retries. |
| + |
| + Returns: |
| + The 2-tuple (exit code, output). |
| + """ |
| + return timeout_retry.Run(GetCmdStatusAndOutput, timeout, retries, [args]) |