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

Nikos Alexandris nikos.alexandris at felis.uni-freiburg.de
Mon Mar 8 18:06:05 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 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:
> > 
> > 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?

Glynn Clements wrote:
> 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.

Actually the error insists and _only_ after I've used the above "PATH"
setting it went away... (?). 

The piece of info that I did not provide and makes perhaps the
difference is that I use grass64 as default (see below). I could
describe all of the details if wanted, but I guess you are probably busy
with more important stuff.

> 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.

Well, I've used your instructions in order to have grass64 set as
default (e.g.:

- in ~/.bashrc I have:

-- code ---
# ~/.bash_profile
if [ -f ~/.bash_profile ] ; then
    . ~/.bash_profile
fi
-- end of code ---

- in ~/.bash_profile I have (after your instructions, 2nd post, current
thread):

-- code ---
export GISBASE=/usr/local/grass-6.4.0svn
# and all of the of the other grass-Variables
[...]
export GRASS_VERSION="6.4.0svn"
[...]
-- end of code ---

Maybe this explains it better.

> 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.

I think I understand the concept and I adjusted it to my needs correctly
(don't see any errors and checking the paths I get what I expect to
see). I'll stick with this configuration as it's very flexible.

Nevertheless, whenever I'll _work_ on a project I'll prefer a
grass-session (to have a per-session history) or when I want to use
grass6_devel/grass70, again I'll use a session and source the strippath
function.

Thank you Glynn,
Nikos



More information about the grass-user mailing list