How can I call an external program with a python script and retrieve the output and return code?
Check out the subprocess module here: http://docs.python.org/library/subprocess.html#module-subprocess. It should get what you need done.