[GRASS-user] Handling exceptions with Python
glynn at gclements.plus.com
Wed Oct 5 17:26:18 EDT 2011
> I am fairly new to both Python and Grass...
> I am trying to catch exceptions thrown up by GRASS using try/except but
> can't seem to get it working!
> For example
> grass.run_command('v.in.ogr', dsn=sLayer, output=sLayerName, quiet=True)
run_command doesn't raise an exception if the command fails (returns a
non-zero exit status). Some time ago, there was an attempt to do this,
but it was so badly implemented that it was reverted.
If you want to know whether the command failed, you need to check the
exit status which run_command returns.
Glynn Clements <glynn at gclements.plus.com>
More information about the grass-user