I think of another method.
I
thought that I could do this by piping the stdout from Ferret
into a string and searching the string for Notes; however, I'm
not able to catch the part of the output stream that has the
Notes in it using the following code:
def test_pyferret_read(nc_file):
oldout = sys.stdout
stdout_fd = sys.stdout.fileno()
out = StringIO.StringIO()
with open('output.txt', 'w') as f, stdout_redirected(f):
pyferret.start(quiet = True)
pyferret.run("use " + nc_file)
out = pyferret.showdata(brief = True)
I suspect that you need to catch stderr instead of stdout. I'm not sure about NOTES but at least errors go to stderr:
$ pyferret -nodisplay -script try.jnl > /dev/null
**TMAP ERR: non-existent or not on line
Searched $FER_DESCR and $FER_DATA for dsafdsz(.nc ,.cdf,.des,.agg)
set data dsafdsz
Command file, command group, or REPEAT execution aborted
Executed by script: *** GO try.jnl ***
$ pyferret -nodisplay -script try.jnl 2> /dev/null
$
( "2>" redirects stderr. "/dev/null" absorbs any input and discard it.)
Regards,
Ryo