1

I know we can call like this:

os.system("ant compile")

But how to know whether the ant task is successful or not?

And is there another way to invoke ant task?

1

3 Answers 3

1

Can you modify ant to return a success code and capture that in python in it's return?

http://www.dotkam.com/2008/10/24/getting-return-code-from-ant-in-shell/

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

2 Comments

it's a good and helpful article, but I want to get the return code from ant in python script instead of SHELL
Return it to the Shell, then take that into python : pydanny.blogspot.com/2007/11/…
1
import subprocess
p1 = subprocess.Popen('ant compile', stdin = subprocess.PIPE, stdout = subprocess.PIPE, stderr = subprocess.PIPE)
print p1.stdout.read(-1)
print p1.stdin.read(-1)
print p1.stderr.read(-1)

Try using subprocess to get the output/error.....

Comments

1

os.system returns a return code. So you can just capture it and check it.

rc = os.system("ant compile")
if rc != 0: 
   print "Error on ant compile"
   sys.exit(1)

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.