Re: [libvirt-test-API][PATCH] Fix utils.exec_cmd output problem

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



----- Original Message -----
> Why to append standard error to standard output. It is not right in
> semantics.

I think test-api should replace all commands modules with utils.exec_cmd.
For commands modules, it merged stderr with stdout:

def getstatusoutput(cmd):
    """Return (status, output) of executing cmd in a shell."""
    import os
    pipe = os.popen('{ ' + cmd + '; } 2>&1', 'r')

So for compatible, utils.exec_cmd should do the same thing.

> In order to get the standard error if executing command failed,  the
> following change is enough:
> 
>       if out == None:
>           # Prevent splitlines() from barfing later on
>           out = ""
> +    if p.returncode:
> +        out = err
>       return (p.returncode, out.splitlines())
> 
> 
> Guannan
> 

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]