--- commands.py.ORIG 2006-06-30 12:19:40.000000000 -0600 +++ commands.py 2006-07-05 09:15:29.000000000 -0600 @@ -47,16 +47,28 @@ # Ditto but preserving the exit status. # Returns a pair (sts, output) # + def getstatusoutput(cmd): - """Return (status, output) of executing cmd in a shell.""" + import os - pipe = os.popen('{ ' + cmd + '; } 2>&1', 'r') - text = pipe.read() - sts = pipe.close() + + try: + myCB = cb + except: + myCB = None + + text = '' + + (stdin,stdout) = os.popen2( '{ ' + cmd + '; } 2>&1', 'r') + for line in stdout: + if myCB != None: + myCB(line) + text += line + sts = stdout.close() + if sts is None: sts = 0 if text[-1:] == '\n': text = text[:-1] - return sts, text - + return sts,text # Make command argument from directory and pathname (prefix space, add quotes). #