[Kimchi-devel] [PATCH] [Wok] Set returncode when run_command logging its output
Daniel Henrique Barboza
dhbarboza82 at gmail.com
Thu Jan 21 11:42:37 UTC 2016
Reviewed-by: Daniel Barboza <dhbarboza82 at gmail.com>
On 01/20/2016 11:10 PM, pvital at linux.vnet.ibm.com wrote:
> From: Paulo Vital <pvital at linux.vnet.ibm.com>
>
> Call proc.poll() to set and return the returncode attribute of the process that
> is logging its output into a file.
>
> Signed-off-by: Paulo Vital <pvital at linux.vnet.ibm.com>
> ---
> src/wok/utils.py | 8 +++++---
> 1 file changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/src/wok/utils.py b/src/wok/utils.py
> index 2527e77..dfcd978 100644
> --- a/src/wok/utils.py
> +++ b/src/wok/utils.py
> @@ -224,15 +224,17 @@ def run_command(cmd, timeout=None, silent=False, tee=None,
> tee_log(line, tee)
> out = ''.join(output)
> error = proc.stderr.read()
> + returncode = proc.poll()
> else:
> out, error = proc.communicate()
>
> if out:
> wok_log.debug("out:\n%s", out)
>
> - if proc.returncode != 0:
> + returncode = proc.returncode
> + if returncode != 0:
> msg = "rc: %s error: %s returned from cmd: %s" %\
> - (proc.returncode, error, ' '.join(cmd))
> + (returncode, error, ' '.join(cmd))
>
> if silent:
> wok_log.debug(msg)
> @@ -251,7 +253,7 @@ def run_command(cmd, timeout=None, silent=False, tee=None,
> msg_args = {'cmd': " ".join(cmd), 'seconds': str(timeout)}
> raise TimeoutExpired("WOKUTILS0002E", msg_args)
>
> - return out, error, proc.returncode
> + return out, error, returncode
> except TimeoutExpired:
> raise
> except OSError as e:
> --
> 2.5.0
>
> _______________________________________________
> Kimchi-devel mailing list
> Kimchi-devel at ovirt.org
> http://lists.ovirt.org/mailman/listinfo/kimchi-devel
More information about the Kimchi-devel
mailing list