From: Tony Mack Date: Tue, 22 Jan 2008 22:29:33 +0000 (+0000) Subject: remove output generated by 'set x' from stderr X-Git-Tag: 2008-02-11-last-vmware-support~113 X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=a072c43bd72437b82cace9f2d6f93ac76504622f;p=tests.git remove output generated by 'set x' from stderr --- diff --git a/qaapi/qa/utils.py b/qaapi/qa/utils.py index 971ff52..38132bf 100644 --- a/qaapi/qa/utils.py +++ b/qaapi/qa/utils.py @@ -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) +