Reputation:
I have a python script that invokes the following command:
# make
After make, it also invokes three other programs. Is there a standard way of telling whether the make command was successful or not? Right now, if make is successful or unsuccessful, the program still continues to run. I want to raise an error that the make was not possible.
Can anyone give me direction with this?
Upvotes: 1
Views: 615
Reputation: 2634
Use subprocess.check_call()
. That way you don't have to check the return code yourself - an Exception will be thrown if the return code was non-zero.
Upvotes: 0
Reputation: 1394
import os
if os.system("make"):
print "True"
else:
print "False"
Upvotes: 0
Reputation: 60649
Look at the exit code of make. If you are using the python module commands
, then you can get the status code easily. 0 means success, non-zero means some problem.
Upvotes: 0
Reputation: 798456
The return value of the poll()
and wait()
methods is the return code of the process. Check to see if it's non-zero.
Upvotes: 1