I would like to launch an ncurses based application from python using subprocess module.
The ncurses based application is TABARI, an event extraction system. The result of event extraction is saved to a file. I would like to launch it from a python script, wait for it to terminate and then read the results file.
A code sample is shown bellow:
import subprocess
proc = subprocess.Popen('TABARI -a ' + file, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
print proc.communicate()
The result of this code when running the program is PyCharm is:
('', 'Error opening terminal: unknown.\n')
When I run the same code from a terminal initiated python interpreter (the same as is used within PyCharm), the output is:
('...lots of text...', '')
I tried several things, including using shell=False, setting the bufsize to -1, and investigating os.environ variables. One suspicious difference between the os.environ output from PyCharm and the terminal is the 'TERM' variable, which does not exist in PyCharm and equals 'xterm' in terminal.
I would appreciate any help.