[libvirt] [test-API][PATCH 1/2] Fix the undefined local variable problem in remote_exec

Guannan Ren gren at redhat.com
Wed Aug 1 07:07:46 UTC 2012


On 07/31/2012 04:23 PM, Wayne Sun wrote:
>    * subproc_flag should be global when used between functions
>    * print error msg when exception happened
>
> Signed-off-by: Wayne Sun <gsun at redhat.com>
> ---
>   utils/utils.py |    5 +++++
>   1 files changed, 5 insertions(+), 0 deletions(-)
>
> diff --git a/utils/utils.py b/utils/utils.py
> index 455e9cf..be87cdc 100644
> --- a/utils/utils.py
> +++ b/utils/utils.py
> @@ -32,6 +32,8 @@ import subprocess
>   from xml.dom import minidom
>   from urlparse import urlparse
>   
> +subproc_flag = 0
> +
>   def get_hypervisor():
>       if commands.getoutput("lsmod | grep kvm"):
>           return 'kvm'
> @@ -439,10 +441,12 @@ def support_virt(self):
>           return True
>   
>   def subproc(a, b):
> +    global subproc_flag
>       subproc_flag = 1
>   
>   def remote_exec(hostname, username, password, cmd):
>       """Remote execution on specified host"""
> +    global subproc_flag
>       pid, fd = pty.fork()
>       if pid == 0:
>           try:
> @@ -479,6 +483,7 @@ def remote_exec(hostname, username, password, cmd):
>               subproc_flag = 0
>               return ret
>           except Exception, e:
> +            print e
>               subproc_flag = 0
>               return -1
>   

    ACK.

    Guannan




More information about the libvir-list mailing list