From dfa7c024cf56927eb7153e88444ebe1f3cf42d31 Mon Sep 17 00:00:00 2001 From: Samir Aguiar Date: Fri, 14 Dec 2018 16:24:16 -0200 Subject: [PATCH] Add timeout support to run_cmd When calling shell commands on a VM we have a default timeout of 60 seconds (in the session functions designed to run remote commands). However, some arnied_wrapper functions such as `wait_for_run` (which calls `arnied_helper --wait-for-program-timeout`) require a larger timeout, so we need to be able to overwrite the default. --- src/arnied_wrapper.py | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/arnied_wrapper.py b/src/arnied_wrapper.py index a97242e..d871bb5 100644 --- a/src/arnied_wrapper.py +++ b/src/arnied_wrapper.py @@ -76,7 +76,7 @@ class ConfigError(Exception): pass -def run_cmd(cmd="", ignore_errors=False, vm=None): +def run_cmd(cmd="", ignore_errors=False, vm=None, timeout=60): """ Universal command run wrapper. @@ -84,12 +84,13 @@ def run_cmd(cmd="", ignore_errors=False, vm=None): :param bool ignore_errors: whether not to raise error on command failure :param vm: vm to run on if running on a guest instead of the host :type vm: VM object or None + :param int timeout: amount of seconds to wait for the program to run :returns: command result output :rtype: str :raises: :py:class:`OSError` if command failed and cannot be ignored """ if vm is not None: - status, stdout = vm.session.cmd_status_output(cmd) + status, stdout = vm.session.cmd_status_output(cmd, timeout=timeout) stdout = stdout.encode() stderr = b"" if status != 0: -- 1.7.1