A job in Jenkins calls my python script, in which I want to call make to compile my UT codes, and raise sys.exit(1) if a compiling error like "make: *** [ ] Error 1" occurs.
I also need to print output in real time.
Here's my python script:
make_process = subprocess.Popen("make clean all;", shell=True, stdout=subprocess.PIPE, stderr=sys.stdout.fileno())
    while True:
        line = make_process.stdout.readline()
        if not line:break
        print line, #output to console in time
        sys.stdout.flush()
But how do I capture the make error and let this python script fail?
Note:
- make_process.wait() is 0 when make error happens.
- this answer doesn't work for me: Running shell command from Python and capturing the output
Update: It turned out to be a makefile issue. See the comments on the accepted answer. But for this python question, pentadecagon gave the right answer.
 
     
    