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 <[email protected]> On Behalf Of Bernardo 
Santos via grass-user
Sent: mandag 1. august 2022 14:00
To: GRASS User List <[email protected]>
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

_______________________________________________
grass-user mailing list
[email protected]
https://lists.osgeo.org/mailman/listinfo/grass-user

Reply via email to