Re: [GRASS-user] grass 6.4 rc5 and python scripting
how/where do you set the variable? it needs to be set before GRASS begins. I have set the GRASS_ADDON_PATH variable in my ~/.bashrc, like this export GRASS_ADDON_PATH=/home/ricardo/gisProjectos/grassAddons in the gnome menu entry prefs do you have start in terminal ticked? Yep, it actually says Application in Terminal, and it is selected -- ___ ___ __ Ricardo Garcia Silva ___ grass-user mailing list grass-user@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/grass-user
[GRASS-user] grass 6.4 rc5 and python scripting
Hello list I compiled grass-6.4.0RC5 (downloaded a tarball from the main site). I'd like to learn about scripting grass with python. Following the first sample script at the GRASS Python scripting library (http://download.osgeo.org/grass/grass6_progman/pythonlib.html) I created a test file called teste.py, and placed it on the Desktop. When I try to run it inside a GRASS session I am geting the following error: GRASS 6.4.0RC5 (aeigT3):~/Desktop ./teste.py sh: teste.py: not found Traceback (most recent call last): File /usr/local/grass-6.4.0RC5/etc/wxpython/gui_modules/menuform.py, line 1931, in module GrassGUIApp( grassTask( sys.argv[1] ) ).MainLoop() File /usr/local/grass-6.4.0RC5/etc/wxpython/gui_modules/menuform.py, line 335, in __init__ xml.sax.parseString( getInterfaceDescription( grassModule ) , processTask( self ) ) File /usr/local/grass-6.4.0RC5/etc/wxpython/gui_modules/menuform.py, line 1748, in getInterfaceDescription raise IOError, _(Unable to fetch interface description for command '%s'.) % cmd IOError: Unable to fetch interface description for command 'teste.py'. The file contents are just a copy+paste from the online example. Can someone point me to the cause of the error? Thanks in advance -- ___ ___ __ Ricardo Garcia Silva ___ grass-user mailing list grass-user@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/grass-user
Re: [GRASS-user] grass 6.4 rc5 and python scripting
Hi, 2009/6/30 Ricardo Filipe Soares Garcia da ricardo.garcia.si...@gmail.com: Following the first sample script at the GRASS Python scripting library (http://download.osgeo.org/grass/grass6_progman/pythonlib.html) I created a test file called teste.py, and placed it on the Desktop. When I try to run it inside a GRASS session I am geting the following error: to launch wxGUI interface you need to copy teste.py to $GISBASE/scripts. Anyway CLI works in every case ./teste.py --help Martin -- Martin Landa landa.martin gmail.com * http://gama.fsv.cvut.cz/~landa ___ grass-user mailing list grass-user@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/grass-user
Re: [GRASS-user] grass 6.4 rc5 and python scripting
Thanks for your help Now I'll get on with the program! Hopefully I'll be able to build a script that can find the nearest hospital to an accident site on a vector network working ;) Cheers On Tue, Jun 30, 2009 at 2:51 PM, Martin Landalanda.mar...@gmail.com wrote: Hi, 2009/6/30 Ricardo Filipe Soares Garcia da ricardo.garcia.si...@gmail.com: Following the first sample script at the GRASS Python scripting library (http://download.osgeo.org/grass/grass6_progman/pythonlib.html) I created a test file called teste.py, and placed it on the Desktop. When I try to run it inside a GRASS session I am geting the following error: to launch wxGUI interface you need to copy teste.py to $GISBASE/scripts. Anyway CLI works in every case ./teste.py --help Martin -- Martin Landa landa.martin gmail.com * http://gama.fsv.cvut.cz/~landa -- ___ ___ __ Ricardo Garcia Silva ___ grass-user mailing list grass-user@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/grass-user
Re: [GRASS-user] grass 6.4 rc5 and python scripting
On 30/06/09 12:58, Ricardo Filipe Soares Garcia da wrote: Hello list I compiled grass-6.4.0RC5 (downloaded a tarball from the main site). I'd like to learn about scripting grass with python. Following the first sample script at the GRASS Python scripting library (http://download.osgeo.org/grass/grass6_progman/pythonlib.html) I created a test file called teste.py, and placed it on the Desktop. When I try to run it inside a GRASS session I am geting the following error: GRASS 6.4.0RC5 (aeigT3):~/Desktop ./teste.py sh: teste.py: not found Traceback (most recent call last): File /usr/local/grass-6.4.0RC5/etc/wxpython/gui_modules/menuform.py, line 1931, in module GrassGUIApp( grassTask( sys.argv[1] ) ).MainLoop() File /usr/local/grass-6.4.0RC5/etc/wxpython/gui_modules/menuform.py, line 335, in __init__ xml.sax.parseString( getInterfaceDescription( grassModule ) , processTask( self ) ) File /usr/local/grass-6.4.0RC5/etc/wxpython/gui_modules/menuform.py, line 1748, in getInterfaceDescription raise IOError, _(Unable to fetch interface description for command '%s'.) % cmd IOError: Unable to fetch interface description for command 'teste.py'. The file contents are just a copy+paste from the online example. Can someone point me to the cause of the error? In order for g.parser to work, the file teste.py needs to be in your PATH. So, you can do something like this: export PATH=$PATH:. ./teste.py Moritz ___ grass-user mailing list grass-user@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/grass-user
Re: [GRASS-user] grass 6.4 rc5 and python scripting
On Jun 30, 2009, at 7:10 AM, grass-user-requ...@lists.osgeo.org wrote: Date: Tue, 30 Jun 2009 15:58:01 +0200 From: Moritz Lennert mlenn...@club.worldonline.be Subject: Re: [GRASS-user] grass 6.4 rc5 and python scripting To: Ricardo Filipe Soares Garcia da ricardo.garcia.si...@gmail.com Cc: grass-user@lists.osgeo.org Message-ID: 4a4a19e9.6030...@club.worldonline.be Content-Type: text/plain; charset=UTF-8; format=flowed On 30/06/09 12:58, Ricardo Filipe Soares Garcia da wrote: Hello list I compiled grass-6.4.0RC5 (downloaded a tarball from the main site). I'd like to learn about scripting grass with python. Following the first sample script at the GRASS Python scripting library (http://download.osgeo.org/grass/grass6_progman/pythonlib.html ) I created a test file called teste.py, and placed it on the Desktop. When I try to run it inside a GRASS session I am geting the following error: GRASS 6.4.0RC5 (aeigT3):~/Desktop ./teste.py sh: teste.py: not found Traceback (most recent call last): File /usr/local/grass-6.4.0RC5/etc/wxpython/gui_modules/ menuform.py, line 1931, in module GrassGUIApp( grassTask( sys.argv[1] ) ).MainLoop() File /usr/local/grass-6.4.0RC5/etc/wxpython/gui_modules/ menuform.py, line 335, in __init__ xml.sax.parseString( getInterfaceDescription( grassModule ) , processTask( self ) ) File /usr/local/grass-6.4.0RC5/etc/wxpython/gui_modules/ menuform.py, line 1748, in getInterfaceDescription raise IOError, _(Unable to fetch interface description for command '%s'.) % cmd IOError: Unable to fetch interface description for command 'teste.py'. The file contents are just a copy+paste from the online example. Can someone point me to the cause of the error? In order for g.parser to work, the file teste.py needs to be in your PATH. So, you can do something like this: export PATH=$PATH:. ./teste.py Moritz There are at least 3 ways for a GRASS to recognize and run a custom script of any kind, including Python. 1. Put it into a folder/directory already recognized by GRASS by default, such as $GISBASE/scripts (noted by Martin) 2. Change your executables PATH list (noted above by Moritz). 3. Set the GRASS_ADDON_PATH variable in the .grassrc6 file (or its equivalent in GRASS 7). For example, I could add... GRASS_ADDON_PATH: /Users/Michael/Desktop;/Users/Michael/Documents ...and any script on my desktop or in my documents folder would be accessible to g.parser and GRASS. (Note: I'm not sure if ; or something else should be the separator between paths). This is very convenient for having a permanent folder outside the main GRASS distribution location where you can put any custom scripts. Michael ___ grass-user mailing list grass-user@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/grass-user
Re: [GRASS-user] grass 6.4 rc5 and python scripting
Glynn Clements wrote: In order for g.parser to work, the file teste.py needs to be in your PATH. This is actually a bug in G_parser() and G_gui(). menuform.py is being passed the base filename rather than the complete path. There isn't any other reason why the script needs to be in the path. I've fixed this in 7.x with r38126. However, menuform.py still tries to run the script using its basename. -- Glynn Clements gl...@gclements.plus.com ___ grass-user mailing list grass-user@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/grass-user
Re: [GRASS-user] grass 6.4 rc5 and python scripting
Michael Barton wrote: 3. Set the GRASS_ADDON_PATH variable in the .grassrc6 file (or its equivalent in GRASS 7). For example, I could add... GRASS_ADDON_PATH: /Users/Michael/Desktop;/Users/Michael/Documents ...and any script on my desktop or in my documents folder would be accessible to g.parser and GRASS. (Note: I'm not sure if ; or something else should be the separator between paths). This is very convenient for having a permanent folder outside the main GRASS distribution location where you can put any custom scripts. does that really work?? it should be an environment variable, not a g.gisenv GRASS variable. the path separator on UNIXes is ':', the path sep on MS Win is ';'. but those shouldn't be needed here (unless you want to define multiple addon dirs). Hamish ___ grass-user mailing list grass-user@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/grass-user
Re: [GRASS-user] grass 6.4 rc5 and python scripting
It really does work. It's pretty nice. I don't know how .grassrc6 handles separators--GRASS specific or OS specific. Michael __ C. Michael Barton, Professor of Anthropology Director of Graduate Studies, School of Human Evolution Social Change Director, Center for Social Dynamics Complexity Arizona State University Tempe, AZ 85287-2402 USA voice: 480-965-6262; fax: 480-965-7671 www: http://www.public.asu.edu/~cmbarton On Jun 30, 2009, at 9:31 AM, Hamish wrote: Michael Barton wrote: 3. Set the GRASS_ADDON_PATH variable in the .grassrc6 file (or its equivalent in GRASS 7). For example, I could add... GRASS_ADDON_PATH: /Users/Michael/Desktop;/Users/Michael/Documents ...and any script on my desktop or in my documents folder would be accessible to g.parser and GRASS. (Note: I'm not sure if ; or something else should be the separator between paths). This is very convenient for having a permanent folder outside the main GRASS distribution location where you can put any custom scripts. does that really work?? it should be an environment variable, not a g.gisenv GRASS variable. the path separator on UNIXes is ':', the path sep on MS Win is ';'. but those shouldn't be needed here (unless you want to define multiple addon dirs). Hamish ___ grass-user mailing list grass-user@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/grass-user
Re: [GRASS-user] grass 6.4 rc5 and python scripting
Hello all Thanks for your good advice. I decided to go with the option of EXPORTing the grass addon path and put my scripts there, which works ok, well... kind of. It happens that when I launch GRASS from the terminal, the GRASS_ADDON_PATH gets correctly added to the PATH and I can load my test script. However, if I start GRASS from the gnome menu (or gnome-do) the GRASS_ADDON_PATH gets ignored. Maybe theres some config file that I have to tweak? On Tue, Jun 30, 2009 at 5:54 PM, Michael Bartonmichael.bar...@asu.edu wrote: It really does work. It's pretty nice. I don't know how .grassrc6 handles separators--GRASS specific or OS specific. Michael __ C. Michael Barton, Professor of Anthropology Director of Graduate Studies, School of Human Evolution Social Change Director, Center for Social Dynamics Complexity Arizona State University Tempe, AZ 85287-2402 USA voice: 480-965-6262; fax: 480-965-7671 www: http://www.public.asu.edu/~cmbarton On Jun 30, 2009, at 9:31 AM, Hamish wrote: Michael Barton wrote: 3. Set the GRASS_ADDON_PATH variable in the .grassrc6 file (or its equivalent in GRASS 7). For example, I could add... GRASS_ADDON_PATH: /Users/Michael/Desktop;/Users/Michael/Documents ...and any script on my desktop or in my documents folder would be accessible to g.parser and GRASS. (Note: I'm not sure if ; or something else should be the separator between paths). This is very convenient for having a permanent folder outside the main GRASS distribution location where you can put any custom scripts. does that really work?? it should be an environment variable, not a g.gisenv GRASS variable. the path separator on UNIXes is ':', the path sep on MS Win is ';'. but those shouldn't be needed here (unless you want to define multiple addon dirs). Hamish ___ grass-user mailing list grass-user@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/grass-user -- ___ ___ __ Ricardo Garcia Silva ___ grass-user mailing list grass-user@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/grass-user
Re: [GRASS-user] grass 6.4 rc5 and python scripting
Ricardo Filipe Soares Garcia da wrote: Thanks for your good advice. I decided to go with the option of EXPORTing the grass addon path and put my scripts there, which works ok, well... kind of. It happens that when I launch GRASS from the terminal, the GRASS_ADDON_PATH gets correctly added to the PATH and I can load my test script. However, if I start GRASS from the gnome menu (or gnome-do) the GRASS_ADDON_PATH gets ignored. Maybe theres some config file that I have to tweak? how/where do you set the variable? it needs to be set before GRASS begins. in the gnome menu entry prefs do you have start in terminal ticked? Hamish ___ grass-user mailing list grass-user@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/grass-user