Sextante on Mac OS X: a working solution for running GRASS commands

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Sextante on Mac OS X: a working solution for running GRASS commands

gene
I could not use the Grass commands on Mac OS X. So I decided to analyze the Python scripts and the sextante log to understand why they did not work.
The log gave me the error
        "GRASS execution console output|/bin/sh: grass64: command not found"
and This problem is due to the line 249 of the script  GrassUtils.py
        command = "grass64 " + GrassUtils.grassMapsetFolder() + "/user"

GRASS GIS from William Kyngesburye (http://www.kyngchaos.com/) is an application bundle  on Mac OS X.
A bundle is a directory that allows related resources such as an application's executable and its libraries, graphics, help files, etc. to be grouped together, appearing as a single file to the user (GRASS-6.4.app). The Unix executables are in the bundle and not in /usr/bin like on Linux
The path on Mac OS X is :
/Applications/GRASS-6.4.app/Contents/MacOS/grass.sh

The solution is therefore to replace the line 249 of GrassUtils.py by
command = "/Applications/GRASS-6.4.app/Contents/MacOS/grass.sh " + GrassUtils.grassMapsetFolder() + "/user"

and everything works fine.

But I still have a little problem with the help, if I replace line 65 of the previous script:
         testfolders = ['/usr/share/doc/grass-doc/html']
by
         testfolders = ['/Applications/GRASS-6.4.app/Contents/MacOS/docs/html']

the result is
"Grass help folder is not correctly configured. Please configure it"
So I continue to search.

If this can help someone.


Reply | Threaded
Open this post in threaded view
|

Re: Sextante on Mac OS X: a working solution for running GRASS commands

gene
The Solution for the help files is finally very simple, just put

GRASS_HELP_FOLDER=/Applications/GRASS-6.4.app/Contents/MacOS/docs/html

in sextante_qgis.conf file
Reply | Threaded
Open this post in threaded view
|

Re: Sextante on Mac OS X: a working solution for running GRASS commands

gene
For a working solution for all OS, in GrassUtils.py (with GRASS 6.4.app):

def executeGrass(commands, progress):
        if SextanteUtils.isWindows():
            GrassUtils.createGrassScript(commands)
            command = ["cmd.exe", "/C ", GrassUtils.grassScriptFilename()]
        else:
            gisrc =  SextanteUtils.userFolder() + os.sep + "sextante.gisrc"
            os.putenv("GISRC", gisrc)
            os.putenv("GRASS_MESSAGE_FORMAT", "gui")
            os.putenv("GRASS_BATCH_JOB", GrassUtils.grassBatchJobFilename())
            GrassUtils.createGrassBatchJobFileFromGrassCommands(commands)
            os.chmod(GrassUtils.grassBatchJobFilename(), stat.S_IEXEC | stat.S_IREAD | stat.S_IWRITE)
            if SextanteUtils.isMac():          
                command = "/Applications/GRASS-6.4.app/Contents/MacOS/grass.sh " + GrassUtils.grassMapsetFolder() + "/user"
            else:
                command = "grass64 " + GrassUtils.grassMapsetFolder() + "/user"

        loglines = []
        loglines.append("GRASS execution console output")
        proc = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stdin=subprocess.PIPE,stderr=subprocess.STDOUT, universal_newlines=True).stdout
.....

submitted:http://hub.qgis.org/issues/6029