[GRASS-dev] Python scripts: trigger cleanup function at keyboard interrupt (CTRL-C)

Anna Petrášová kratochanna at gmail.com
Mon Oct 14 07:44:51 PDT 2019


This is used in many scripts and should work:
https://grasswiki.osgeo.org/wiki/GRASS_Python_Scripting_Library#Sophisticated_cleanup_procedure

On Mon, Oct 14, 2019 at 10:00 AM Markus Neteler <neteler at osgeo.org> wrote:

> Hi,
>
> in the GRASS GIS 6 shell scripts we used this code to clean up temp
> files upon CTRL-C signal:
>
> cleanup()
> {
>    g.message -v "Cleaning up ..."
>    cd "$MSET_DIR"
>    rm -rf "$TMP_DIR"
> }
> #### trap ctrl-c so that we can clean up tmp
> trap 'cleanup' 2 3 15
>
> If there anything similar we could add to the python scripts?
>
> thanks
> Markus
> _______________________________________________
> grass-dev mailing list
> grass-dev at lists.osgeo.org
> https://lists.osgeo.org/mailman/listinfo/grass-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/grass-dev/attachments/20191014/e6806d3c/attachment.html>


More information about the grass-dev mailing list