Hello all:
I have a Django application that dispatches processing to a matlab script using exec. How can I capture the stdout and stderr of the script's execution?
Outside of Django, this works for a dumb matlab script called tt that just prints a message:
>>> import matlab.engine, StringIO
>>> eng = matlab.engine.start_matlab()
>>> out = StringIO.StringIO()
>>> err = StringIO.StringIO()
>>> exec('
eng.tt(25, stdout=out, stderr=err)')
>>> out.getvalue()
"This is a disp command.\n\nret =\n\n '25\n\n"
Inside a Django method, the exec seems to function properly, but the out and err variables remain empty. Where's my output? Did the logging system snatch it? I assume I'm missing something obvious here but any pointers would be welcome.
Thank you,
-Tom