[GRASS-dev] G__getenv return different results from ctypes and from GRASS modules

Pietro peter.zamb at gmail.com
Thu May 30 06:29:44 PDT 2013


Hi all,

Nikos A. found a strange behaviour... that I'm not able to understand...

I'm in the North Carolina (PERMANENT):

{{{
In [1]: import grass.lib.gis as libgis  # import the ctypes

In [2]: !g.mapset -p  # look in which mapset we are
PERMANENT

In [3]: libgis.G__getenv('MAPSET')  # look in which mapset we are using ctypes
Out[3]: 'PERMANENT'

In [4]: !g.mapset user1   # change the mapset
Your shell continues to use the history for the old mapset
You can switch the history by commands:
history -w; history -r /data/gis/nc/user1/.bash_history;
HISTFILE=/data/gis/nc/user1/.bash_history

In [5]: !g.mapset -p  # look in which mapset we are
user1

In [6]: libgis.G__getenv('MAPSET')  # look in which mapset we are using ctypes
Out[6]: 'PERMANENT'

In [7]: !g.gisenv
MAPSET=user1
GISDBASE=/data/gis
LOCATION_NAME=nc
GUI=text
GISDBASEE=/data/gis

}}}

Why the ctypes version return 'PERMANENT' instead of 'user1'?

the flag "p" of the module g.mapset use exactly the same function.

http://trac.osgeo.org/grass/browser/grass/trunk/general/g.mapset/main.c#L103
http://trac.osgeo.org/grass/browser/grass/trunk/general/g.gisenv/main.c#L119

There is someone that is able to understand what is not working?
Any idea?

Best regards.

Pietro


More information about the grass-dev mailing list