[GRASS-dev] How to get stop a script with an error in a function

Glynn Clements glynn at gclements.plus.com
Fri Oct 15 10:23:05 EDT 2010


António Rocha wrote:

> I have built a Py Script that is similar to r.in.aster, I mean, to 
> reproject/project a file and then import into grass.
> 
> The problem is when I select a non raster file. A get an error in 
> GDALWARP but the script continue.
> And then it calls r.in.gdal to import and then I get ERROR 4. What I 
> want is a way to "stop" the process (with grass_fatal) when I get ERROR 4.
> Is this possible? can anyone give me a tip? Some approach to get the 
> error. I have tried with try: except: but it didn't work out

Check the exit code from the command. Commands should use a non-zero
exit code if there was an error.

It would help to know exactly how the command is being run.

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


More information about the grass-dev mailing list