Wrapping an interactive command line application in a Python script
Does PExpect fits your needs?
Maybe you want something from Subprocess (MOTW).
I use code like this to make calls out to the shell:
from subprocess import Popen, PIPE
## shell out, prompt
def shell(args, input_=''):
''' uses subprocess pipes to call out to the shell.
args: args to the command
input: stdin
returns stdout, stderr
'''
p = Popen(args, stdin=PIPE, stdout=PIPE, stderr=PIPE)
stdout, stderr = p.communicate(input=input_)
return stdout, stderr