<div dir="ltr"><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Jul 6, 2015 at 7:56 PM, Glynn Clements <span dir="ltr"><<a href="mailto:glynn@gclements.plus.com" target="_blank">glynn@gclements.plus.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="">> > > is there some reason for GRASS parser not checking if the input map exists?<br>
> > > It checks if the output map exists and if it it does it ends execution with<br>
> > > an error.<br>
> ><br>
> > If an input map (or file) doesn't exist, you'll get an error when the<br>
> > module tries to open it.<br>
><br>
> If I understand correctly, this applies only for C modules not Python or<br>
> Bash modules, right?<br>
<br>
</span>For scripts which use g.parser for argument parsing, if G_parser()<br>
fails g.parser itself fails, which in turn causes the script to fail.<br>
<br>
Python scripts should normally terminate on an exception if a spawned<br>
command fails, whereas shell scripts normally ignore the status of any<br>
spanwed commands.</blockquote></div><br></div><div class="gmail_extra">For Python this is ensured by checking <span class="">"@ARGS_PARSED@"</span><span class=""></span> in g.parser output in grass.script.core.parse() [1]. For Bash I have no idea how it is/was done (e.g. in version 6).<br><br></div><div class="gmail_extra">However, my problem is that in C if you have an input map, you don't have to check that whether it exists. While in Python you have to check if it exists otherwise the first module (subprocess) you call with it will unexpectedly fail. I hit this issue when I was trying to write documentation for writing scripts and I wanted to do it the right way (as opposed to hopping that some random script I pick in the source code follows well the undocumented API).<br><br>The question now is if we want to fix the inconsistency in between writing C and Python (and error reporting with overwrite). Or if we say that the current state is good enough as long as it is documented and there is some convenient function to check existence of a map. I don't think I exhausted all options, so if somebody has an idea or is willing to implement something, that would be great.<br><br></div><div class="gmail_extra">Vaclav<br></div><div class="gmail_extra"><br>[1] <a href="https://trac.osgeo.org/grass/browser/grass/trunk/lib/python/script/core.py#L712">https://trac.osgeo.org/grass/browser/grass/trunk/lib/python/script/core.py#L712</a><br></div></div>