[GRASS-user] can I access mapset outside of grass, by using python?

Nikos Alexandris nikos.alexandris at felis.uni-freiburg.de
Sun Mar 7 22:19:28 EST 2010


Apologies for a second post with the code. Just to make it easier to
read/ understand what I've changed.


Νίκος Αλεξανδρής wrote:
> > Is there a way to lock-out all other versions of grass-modules from 
> > being detectable when I am already inside a grass70 session?

Glynn Clements wrote:
> The grassXY scripts prepend the GRASS directories to PATH,
> LD_LIBRARY_PATH, etc. They won't remove any entries which are already
> there.
> 
> I only use the grassXY scripts if I actually need to test the startup
> process. To switch versions, I use the following script:
> 
> 	strippath()
> 	{
> 	    (
> 	    oldpath="$1"
> 	    newpath=
> 	    IFS=:
> 	    for dir in $oldpath ; do
> 		case "${dir}" in
> 		*grass*)
> 			;;
> 		*)
> 			newpath="$newpath:$dir"
> 			;;
> 		esac
> 	    done
> 	    echo "${newpath#:}"
> 	    )
> 	}
> 	
> 	PATH=`strippath $PATH`
> 	
> 	export GISBASE=$PWD/dist.i686-pc-linux-gnu
> 	export PATH="$GISBASE/bin:$GISBASE/scripts:$PATH"
> 	export LD_LIBRARY_PATH="$GISBASE/lib"
> 	export PYTHONPATH="$GISBASE/etc/python"
> 
> Note: the above script needs to be "source"d; executing it won't work.


-- slightly modified code --

strippath()
{
    (
    oldpath="$1"
    newpath=
    IFS=:
    for dir in $oldpath ; do
        case "${dir}" in
        *grass*)
                ;;
        *)
                newpath="$newpath:$dir"
                ;;
        esac
    done
    echo "${newpath#:}"
    )
    unset IFS
}

export PATH="$GISBASE/bin:$GISBASE/scripts:`strippath $PATH`"
export LD_LIBRARY_PATH="$GISBASE/lib"
export PYTHONPATH="$GISBASE/etc/python"

-- end of slightly modified code --

Nikos



More information about the grass-user mailing list