<div dir="ltr"><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Mar 23, 2016 at 11:57 AM, Markus Metz <span dir="ltr"><<a href="mailto:markus.metz.giswork@gmail.com" target="_blank">markus.metz.giswork@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><span class=""><br>
> Now this is treated as an error<br>
> (ERROR: Multiple regression failed"), which I guess is the equivalent of<br>
> grass.error() in a python script? Perhaps it would be possible to provide a<br>
> warning instead, and give an output that can be captured, like NA for the<br>
> coefficient estimates, instead of breaking of the function?<br>
<br>
</span>Instead of grass.run_command(), you can use<br>
<br>
ps = grass.start_command()<br>
returncode = ps.wait()<br>
<br>
returncode is zero if the module finished successfully, non-zero if an<br>
error occurred, easy to capture in a script.</blockquote></div><br><br></div><div class="gmail_extra">I don't know if the called module behavior is but or if it should be improved somehow. Anyway, the way to deal with subprocess failure when using GRASS Python API is to use try-except. You can also get run_command to behave the same as in 6.4 version of the API using errors parameter:<br><br>returncode = run_command('g.region', ..., errors='status')<br><br></div><div class="gmail_extra">Other possible values are raise, ignore and exit. raise is the default and it raises a CalledModuleError exception. Note that the exception is the default because that's how the errors are handled in Python and it works well also for read_command() which returns the module stdout by value. There are different *_command() functions to conveniently cover different cases. The most general is start_command() which is used similarly to the underlying Popen.<br><br></div><div class="gmail_extra">Vaclav<br></div></div>