[GRASS-dev] [GRASS-SVN] r62717 - grass/trunk/gui/wxpython/rlisetup
wenzeslaus at gmail.com
Thu Nov 13 07:26:36 PST 2014
On Thu, Nov 13, 2014 at 5:21 AM, <svn_grass at osgeo.org> wrote:
> + grass.run_command('g.region', rast=origrast)
> + grass.run_command('g.region', vect=tmp_vect)
> + grass.run_command('g.region', align=origrast)
I'm not sure in which context you are calling this but unless it is clear
from the user interface that region will change and user expects that, you
should read the following.
If you are calling processes which needs different region, you must use
`env` parameter and do region override just for subprocesses in order not
to change the region of the whole GRASS session.
The API for temporary region which is in grass.script.core works just for
scripts which change the environment for themselves and their subprocesses
but not for rest of GRASS. However, if you use the API in GUI, you change
the environment for the whole GUI (process) which is not what you want.
This means that you need to keep "environment" dictionary in your class(es)
and pass it to all subprocesses you call.
There is no API for this yet. Anna recently created a function which can be
used for that.
def get_environment(tmp_regions, **kwargs):
"""Returns environment for running modules.
All modules for which region is important should
pass this environment into run_command or similar.
List of regions is used to keep track of created files
and should be used to remove these files later.
:param tmp_regions: a list of temporary regions
:param kwargs: arguments for g.region
:return: environment as a dictionary
name = str(uuid.uuid4())[:8]
gcore.run_command('g.region', flags='u', save=name, **kwargs)
env = os.environ.copy()
env['WIND_OVERRIDE'] = name
env['GRASS_VERBOSE'] = '0'
env['GRASS_MESSAGE_FORMAT'] = 'standard'
if 'GRASS_REGION' in env:
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the grass-dev