1

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?

4 Answers 4

1

The return value of the poll() and wait() methods is the return code of the process. Check to see if it's non-zero.

Sign up to request clarification or add additional context in comments.

3 Comments

Is poll() and wait() build into python or make?
poll and wait are methods understood by subprocess.Popen objects. Click the links in Ignacio's answer for more.
Thanks for the tip! Didn't even realize it was a link!
0

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.

Comments

0
import os
if os.system("make"):
    print "True"
else:
    print "False"

2 Comments

Sorry. I don't think this works. I just tested it out with calling a dummy program that never exists and it never goes to the false statement
This script will print True if make returned any errors, and false if it exited cleanly.
0

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.