[GRASS-dev] Using --quiet flag in grass.run_command

Glynn Clements glynn at gclements.plus.com
Thu Oct 21 10:15:55 EDT 2010


Helena Herrera wrote:

> In some functions, for instance g.remove even after using quiet=True ther
> warnings are still beng printed. was tha expected?

--quiet suppresses messages; it doesn't suppress warnings.

> Regarding GDALWARP, I'm running this command:
> grass.debug("gdalwarp -t_srs %s -srcnodata %s -dstnodata %s -tr %s %s %s %s"
> % (proj_location, no_value, no_value, t_srx, t_sry, input, tempfile))
> can I use something in order to avoid all the printing that this does?

You can redirect stdout and/or stderr to the null device (/dev/null on
Unix, "nul" on Windows), e.g.:

	nullf = open(os.devnull, 'w')
	grass.run_comand(..., stdout = nullf, stderr = nullf)
	nullf.close()

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


More information about the grass-dev mailing list