benschneider / PyGnuplot

Python interface to gnuplot
MIT License
45 stars 18 forks source link

PyGnuplot feature request: capture & return of stdout/stderr info #8

Open jrbrearley opened 7 years ago

jrbrearley commented 7 years ago

As part of debugging prior issues, I learned a trick to get gnuplot to basically send some info back to me at the end of a command set. This was done to diagnose the commands being tested. At the end of the command set, I would add the following:

cmd_cleanup = "show output; unset output"

The show output would give me the filename of where the png/jpeg file was going to be stored. The unset would tell gnuplot to flush the output and release file system locks on it. If I got a different message, that gave me a clue that the most recent command I had sent was malformed and needded work.

Anyway, PyGnuplot does not currently turn on stdout or stderr as part of the instantiation command.

You would need something like: proc = _Popen(['gnuplot', '-p'], shell=False, stdin=_PIPE, stdout=_PIPE, stderr=_PIPE) # persitant -p

and later on in .c method do: out,err = proc.communicate() ;# gives a tuple

Maybe .c method could return out,err? Also print them to the console?

ddipp commented 5 years ago

12