[GRASS-dev] Catching an issue from external binary using grass Python Script

Glynn Clements glynn at gclements.plus.com
Fri Jul 29 14:59:23 EDT 2011


Jenny Turner wrote:

> *Is it possible to get above text ("This application ..." in a variable?*

If it's being written to stdout or stderr, you can capture those by
replacing subprocess.call() with:

	p = subprocess.Popen(<command>, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
	out, err = p.communicate()

out and err will be strings, containing the data written to stdout and
stderr respectively.

-- 
Glynn Clements <glynn at gclements.plus.com>


More information about the grass-dev mailing list