From: <sv...@ww...> - 2007-04-10 06:23:22
|
Author: mkrose Date: 2007-04-09 23:23:14 -0700 (Mon, 09 Apr 2007) New Revision: 2076 Modified: trunk/csp/tools/build/buildlog.py Log: Fix the new buildlog hook to (a) not suppress stdout/stderr from commands and (b) correctly return the command status. Browse at: https://www.zerobar.net/viewcvs/viewcvs.cgi?view=rev&rev=2076 Modified: trunk/csp/tools/build/buildlog.py =================================================================== --- trunk/csp/tools/build/buildlog.py 2007-04-09 08:02:21 UTC (rev 2075) +++ trunk/csp/tools/build/buildlog.py 2007-04-10 06:23:14 UTC (rev 2076) @@ -34,15 +34,26 @@ _SPAWN = None +class _Tee: + """Generalized "T" for writing to multiple file objects.""" + def __init__(self, *out): + self._out = out + def write(self, data): + for out in self._out: + out.write(data) + + def _MakeLogHook(pspawn, log): """ Return a spawn function suitable for env['SPAWN']. The function logs the command string and then calls pspawn to execute the command, which writes stdout and stderr to the log. """ + stdout = _Tee(log, sys.stdout) + stderr = _Tee(log, sys.stderr) def _spawn_wrapper(sh, escape, cmd, cargs, env): Log(' '.join(cargs)) - pspawn(sh, escape, cmd, cargs, env, log, log) + return pspawn(sh, escape, cmd, cargs, env, stdout, stderr) return _spawn_wrapper |