[GRASS-user] Using a script as a GRASS addon

Stefan Blumentrath Stefan.Blumentrath at nina.no
Mon Aug 1 23:50:52 PDT 2022


Hei Bernado,

On Linux you make the script executable:
chmod ugo+x path_to/r.ls.func_connectivity.py

You can rename it to r.ls.func_connectivity if you want to get rid of the .py ending.

Furthermore, the script should be located in directory that is part of your PATH environment variable.
e.g. ~/.grass7/addons/scripts/

If the script has a proper shebang (#!/usr/bin/env python3) the python interpreter should be launched when you call the script.

On MS Windows things are a bit different and you need a -bat wrapper script…

Please also have a look at https://github.com/wenzeslaus/r.example.plus
Which is a great start for writing addons, and provides you with a make recipe to install things as usual addons…

Hope that helps,
Stefan


From: grass-user <grass-user-bounces at lists.osgeo.org> On Behalf Of Bernardo Santos via grass-user
Sent: mandag 1. august 2022 14:00
To: GRASS User List <grass-user at lists.osgeo.org>
Subject: [GRASS-user] Using a script as a GRASS addon

Dear all,

I have been following some forums and instructions from GRASS documentation to be able to write new GRASS addons - or what I call an addon, basically a python script that does what I want, and follow the same standards of published GRASS addons, with description of the addon and usage, parameters etc, followed be the script with procedures.

It seems to work, but I am not sure how I can test them as GRASS addons. Right now, to be able to run them I need to call python like this:

python r.ls.func_connectivity.py input=map1 output=map1_func_connect gap_crossing=60

Is there a way I can run that without needing to call python and to use the ".py" in the end of the script? Like a folder where I can place the files, or a way to build it as a formal GRASS addon. What I want is to be able to test it and use it (even if only locally for now) as

r.ls.func_connectivity input=map1 output=map1_func_connect gap_crossing=60

Is this documented somewhere?

Best wishes,
Bernardo

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/grass-user/attachments/20220802/81eca1ad/attachment.htm>


More information about the grass-user mailing list