I don't seem to be getting the correct exit code from subprocess.call on Windows.
import subprocess
exit_code = subprocess.call(['ant.bat', 'fail'])
print exit_code # prints 0
Doing the same thing on windows seems to return something other than 0
> echo %errorlevel%
0
> ant fail
> echo %errorlevel%
1
Shouldn't the values from both calls give the same value? Am I doing something wrong?
In the worst case, how do I check the value of %errorlevel% in my python script?
UPDATE:
I tried something like this to get the errorlevel value:
environment = os.environment.copy()
cmd = subprocess.Popen(['ant.bat', 'fail'], env = environment)
for key, value in environment.items():
print '%s = %s' % (key, value)
However I do not see errorlevel in that dictionary (os.getenv['errorlevel'] also fails).