<div dir="ltr"><br><br><div class="gmail_quote"><div dir="ltr">On Sat, Jul 21, 2018 at 9:10 AM Micha Silver <<a href="mailto:tsvibar@gmail.com">tsvibar@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div style="direction:ltr" bgcolor="#FFFFFF">
<br>
<br>
<div class="gmail-m_4239516177414762672moz-cite-prefix">On 07/20/2018 06:05 PM, Frank David
wrote:<br>
</div>
<blockquote type="cite">
<p><font size="-1">Hello dear grass users,</font></p>
<p><font size="-1">I'm writing python scripts and I wonder if is
there a better way to handle tmp file between several mapcalc,
For the moment I create a tmp raster file and once I don't
need anymore I remove with g.remove. If the script crash, the
tmp raster still exists. If another script run and use the
same tmp name, that could make conflict.</font></p>
<p><font size="-1">Is there a specific way the handle tmp raster
(or vector) file ?</font></p>
</blockquote>
<p><font size="-1">I guess the proper way to deal with this is to
first prepare a cleanup function. Then wrap your grass functions
in a try...except structure, and whenever you catch an error,
fire off the cleanup routine.</font></p></div></blockquote><div><br></div><div>Use atexit package, see for example cleanup routine in r.sun.daily module:</div><div><a href="https://trac.osgeo.org/grass/browser/grass-addons/grass7/raster/r.sun.daily/r.sun.daily.py#L612">https://trac.osgeo.org/grass/browser/grass-addons/grass7/raster/r.sun.daily/r.sun.daily.py#L612</a></div><div><br></div><div>and example on wiki:</div><div><br></div><div><a href="https://grasswiki.osgeo.org/wiki/GRASS_Python_Scripting_Library#Sophisticated_cleanup_procedure">https://grasswiki.osgeo.org/wiki/GRASS_Python_Scripting_Library#Sophisticated_cleanup_procedure</a><br></div><div><br></div><div><br></div><div>Anna </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div style="direction:ltr" bgcolor="#FFFFFF">
<p><font size="-1"></font><br>
</p>
<blockquote type="cite">
<p><font size="-1">Thank you<br>
Frank<br>
</font></p>
<br>
<fieldset class="gmail-m_4239516177414762672mimeAttachmentHeader"></fieldset>
<br>
<pre>_______________________________________________
grass-user mailing list
<a class="gmail-m_4239516177414762672moz-txt-link-abbreviated" href="mailto:grass-user@lists.osgeo.org" target="_blank">grass-user@lists.osgeo.org</a>
<a class="gmail-m_4239516177414762672moz-txt-link-freetext" href="https://lists.osgeo.org/mailman/listinfo/grass-user" target="_blank">https://lists.osgeo.org/mailman/listinfo/grass-user</a></pre>
</blockquote>
<br>
<pre class="gmail-m_4239516177414762672moz-signature" cols="72">--
Micha Silver
Ben Gurion Univ.
Sde Boker, Remote Sensing Lab
cell: +972-523-665918</pre>
</div>
_______________________________________________<br>
grass-user mailing list<br>
<a href="mailto:grass-user@lists.osgeo.org" target="_blank">grass-user@lists.osgeo.org</a><br>
<a href="https://lists.osgeo.org/mailman/listinfo/grass-user" rel="noreferrer" target="_blank">https://lists.osgeo.org/mailman/listinfo/grass-user</a></blockquote></div></div>