expected non-zero return values when spawning subprocesses

Hi there, I'm using distutils.spawn.spawn() to run subprocesses during my build commands. It now happens that one of those subprocesses will return a non-zero value that doesn't strictly correspond to an error, and thus I'd like to catch it from within my python code. It appears spawn() itself will raise a message containing a stringified version of the exit code, but not the exit code itself. This seems to imply that, in order to discriminate on the exit value, I have to catch DistutilsExecError, and then parse the string. This seems rather unelegant. Is there some better way ? Could the exception be modified to contain the original code (as an integral value) ? Thanks, Stefan

At 08:41 PM 1/20/2006 -0500, Stefan Seefeld wrote:
Hi there,
I'm using distutils.spawn.spawn() to run subprocesses during my build commands. It now happens that one of those subprocesses will return a non-zero value that doesn't strictly correspond to an error, and thus I'd like to catch it from within my python code.
It appears spawn() itself will raise a message containing a stringified version of the exit code, but not the exit code itself. This seems to imply that, in order to discriminate on the exit value, I have to catch DistutilsExecError, and then parse the string. This seems rather unelegant. Is there some better way ? Could the exception be modified to contain the original code (as an integral value) ?
The answer to both questions is "probably not". The distutils haven't been under active development for some time now. You could perhaps try and submit a patch via the Python Sourceforge patch tracker; perhaps that might get a more authoritative response one way or the other.
participants (2)
-
Phillip J. Eby
-
Stefan Seefeld