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

Glynn Clements glynn at gclements.plus.com
Mon Mar 8 17:27:59 EST 2010

Nikos Alexandris 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:
> > 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:
> I get the following error:
> --%<---
> /geo/osgeo/src/grass6_devel/dist.x86_64-unknown-linux-gnu/etc/prompt.sh:
> 2: g.gisenv: not found

> So I did some modifications (see below). Sorry for the noob questions
> (and editing).

> --> here I added "unset IFS": wrong, right or not required?

Not required; the IFS setting is with a subshell, for this reason.

> > 	    )
> > 	}
> > 	
> > 	PATH=`strippath $PATH`
> I changed that to:
>          PATH="$GISBASE/bin:$GISBASE/scripts:`strippath $PATH`"

Wait until after $GISBASE has been set.

> > 	export GISBASE=$PWD/dist.i686-pc-linux-gnu
> -(a)-> changed the 2nd part to "dist.x86_64-unknown-linux-gnu"

Right; that would explain the "g.gisenv: not found" errors. These
scripts were constructed for personal use, so they reflect my system.

> -(b)-> I don't understand the logic behind "$PWD" here. From within a
> grass65 or grass70 session why need to re-define $GISBASE? It's already
> set.

The scripts exist to change the "active" version of GRASS. I set all
of the environment variables from a ~/.bashrc.grass file which is
sourced by my ~/.bash_profile file, so GRASS commands work everywhere. 
The environment variables are initially set to use 7.0-svn.

But each version of GRASS which I have checked out has a copy of the
scripts. "source"ing the script will cause that particular version of
GRASS to become "active", i.e. $GISBASE, $PATH, $LD_LIBRARY_PATH and
$PYTHONPATH will all refer to the copy of GRASS in $PWD/dist.i686-pc-linux-gnu.

Glynn Clements <glynn at gclements.plus.com>

More information about the grass-user mailing list