[GRASS-user] using try/except with grass.mapcalc in a Python Script

Glynn Clements glynn at gclements.plus.com
Tue Mar 1 14:26:02 EST 2011


Jenny Turner wrote:

> I want to include grass.mapcalc function in try except but I'm not catching
> the errors. Has anyone used this for grass.mapcalc?

What sort of error are you expecting?

If you call set_raise_on_error(), a non-zero exit status should raise
a ScriptException instead of calling sys.exit() (note that sys.exit()
raises a SystemExit exception, which can be caught if desired).

Note that r.mapcalc will only return a non-zero exit status for
fundamental errors such as syntax errors in the expression or failure
to open a map. Calculation errors (e.g. division by zero or domain
errors) result in null values.

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


More information about the grass-user mailing list