remove output generated by 'set x' from stderr
authorTony Mack <tmack@cs.princeton.edu>
Tue, 22 Jan 2008 22:29:33 +0000 (22:29 +0000)
committerTony Mack <tmack@cs.princeton.edu>
Tue, 22 Jan 2008 22:29:33 +0000 (22:29 +0000)
qaapi/qa/utils.py

index 971ff52..38132bf 100644 (file)
@@ -1,7 +1,21 @@
 # $Id$
 import time
+import os
 
-# how could this accept a list again ?
 def header(message):
     now=time.strftime("%H:%M:%S", time.localtime())
     print "*",now,'--',message
+
+
+def popen(command, fatal=True):
+    (stdin, stdout, stderr) = os.popen3(command)
+    output = stdout.readlines()
+    
+    # filter output generated by set x
+    remove_set_x = lambda line: not line.startswith("+")        
+    errors = filter(remove_set_x, stderr.readlines())
+    
+    if fatal and errors:
+       raise Exception, "\n".join(errors)      
+    return (output, errors)    
+