Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've created a program that runs externally from GRASS v6.4.1, using python 2.6. It imports an ESRI shapefile, and exports a seperate KML for every polygon in this vector file.

Polygons with islands produce a warning message using "v.out.ogr" saying that features without a category were skipped. Looking into this further, these "skipped" features (islands) are processed later. So the program does what it was designed to do, but I would like it so that this warning message is not printed in the terminal.

VERBOSITY setting were set to "0" using:

os.environ['GRASS_VERBOSE']='0' #runs modules silently

But this doesn't take care of warning messages. I found that there is a gisenv variable called DEBUG, can be set to "0" as well so that all warning messages are silenced too. Problem is, I can't seem to get the proper syntax for my GRASS-python script. I've tried:

grass.gisenv() ['set']='DEBUG=0'

Using this line of code atleast allows the program to run, but warning messages are still printed. Other options I've tried terminate the program.

Has anyone successfully set the DEBUG level to "0" in a GRASS-Python script?


share|improve this question
BTW: The question title should be changed. The question is not about debugging but to get user warnings to silence. /debug level to "0"/warnings silent/ – markusN Nov 14 '11 at 22:06

In C, a warning message can be suppressed by G_suppress_warnings().

I'll verify how to do that in GRASS-Python.

Update 1: you can suppress most stuff with:

grass.run_command('g.gisenv', set="DEBUG=0")

but DEBUG=0 will not suppress warnings. So for the GRASS GIS version you have there is only one way, to discard stderr. We'll make it more elegant, hopefully for version 6.4.3 and later.

Update 2: From today onwards, GRASS 7 supports your wish (see Changeset 51466):

GRASS_VERBOSE=-1 now discards error and warning messages

The source code is available from the GRASS GIS SVN source code repository or next Saturday as SVN snapshot.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.