[GRASS-dev] [GRASS GIS] #3252: Provide an error message pointing out that session is not active
GRASS GIS
trac at osgeo.org
Wed Jan 11 07:27:15 PST 2017
#3252: Provide an error message pointing out that session is not active
-------------------------------------------------+-------------------------
Reporter: wenzeslaus | Owner: grass-dev@…
Type: defect | Status: new
Priority: normal | Milestone: 7.2.1
Component: Startup | Version: unspecified
Keywords: GRASS GIS environment variables, | CPU: Unspecified
g.gisenv, G_getenv, G_getenv_nofatal, |
G_fatal_error, fatal error, LOCATION_NAME, |
session |
Platform: Unspecified |
-------------------------------------------------+-------------------------
When you run
{{{
grass73 ~/grassdata/nc_spm_08_grass7/user1 --exec d.mon wx0
}}}
it gives
{{{
ERROR: Variable 'LOCATION_NAME' not set
}}}
it also prints
{{{
Traceback (most recent call last):
File "/home/vpetras/dev/grass/gcc_trunk/dist.x86_64-pc-linux-
gnu/gui/wxpython/mapdisp/main.py", line 608, in <module>
fd = open(pidFile, 'w')
IOError: [Errno 2] No such file or directory:
'/home/vpetras/grassdata/nc_spm_08_grass7/user1/.tmp/lemur/MONITORS/wx0/pid'
}}}
but what it is trying to say is that there is not running in an active
GRASS GIS session (session ended but d.mon wx0 runs in the background).
Similar situation can be created in Python using:
{{{
#!python
import os
import sys
import subprocess
# create GRASS GIS runtime environment
gisbase = subprocess.check_output(["grass", "--config", "path"]).strip()
os.environ['GISBASE'] = gisbase
sys.path.append(os.path.join(gisbase, "etc", "python"))
# do GRASS GIS imports
import grass.script as gs
import grass.script.setup as gsetup
# set GRASS GIS session data
rcfile = gsetup.init(gisbase, "/home/vpetras/grassdata",
"nc_spm_08_grass7", "user1")
# run module
gs.parse_command('g.region', region="swwake_30m", flags='pg')
# end the GRASS session
os.remove(rcfile)
# run module again
gs.parse_command('g.region', region="swwake_30m", flags='pg')
}}}
The error is again (possibly with traceback):
{{{
ERROR: Variable 'LOCATION_NAME' not set
}}}
But it should be one of those (or any other you think is better):
{{{
ERROR: No GRASS GIS session is not active: Variable 'LOCATION_NAME' not
set
ERROR: Variable 'LOCATION_NAME' not set. Are you in GRASS GIS session?
ERROR: Variable 'LOCATION_NAME' not set. Are you running GRASS GIS
session?
ERROR: Not running in a GRASS GIS session (variable 'LOCATION_NAME' not
set)
}}}
--
Ticket URL: <https://trac.osgeo.org/grass/ticket/3252>
GRASS GIS <https://grass.osgeo.org>
More information about the grass-dev
mailing list