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

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

 



  * subproc_flag should be global when used between functions
  * print error msg when exception happened

Signed-off-by: Wayne Sun <gsun@xxxxxxxxxx>
---
 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
 
-- 
1.7.1

--
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]