modified load() to load confg elements as dicts, not lists
[tests.git] / qaapi / qa / utils.py
index 52e359f..2ff395e 100644 (file)
@@ -1,17 +1,21 @@
 # $Id$
 import time
 import os
-import commands
+from commands import getstatusoutput
+from logger import logfile
 
 def header(message):
     now=time.strftime("%H:%M:%S", time.localtime())
-    print "*",now,'--',message
+    output = "*"+now+'--'+message      
+    print output
+    print >> logfile, output   
 
 
 def popen(command, fatal=True):
     (stdin, stdout, stderr) = os.popen3(command)
     output = stdout.readlines()
-    
+    print >> logfile, "+ "+command
+    print >> logfile, "".join(output).strip() 
     # filter output generated by set x
     remove_set_x = lambda line: not line.startswith("+")        
     errors = filter(remove_set_x, stderr.readlines())
@@ -21,7 +25,10 @@ def popen(command, fatal=True):
     return (output, errors)    
     
 def commands(command, fatal = True):
-    (status, output) = commands.getstatusoutput(command)
+    (status, output) = getstatusoutput(command)
+    print >> logfile, "+ "+command
+    print >> logfile, output.strip()           
     if fatal and not status == 0:
        raise Exception, "%(command)s Failed:\n%(output)s" % locals()
     return (status, output)                     
+