Opened 8 years ago

Last modified 6 years ago

#3252 new defect

Provide an error message pointing out that session is not active

Reported by: wenzeslaus Owned by: grass-dev@…
Priority: normal Milestone: 7.2.4
Component: Startup Version: unspecified
Keywords: GRASS GIS environment variables, g.gisenv, G_getenv, G_getenv_nofatal, G_fatal_error, fatal error, LOCATION_NAME, session Cc:
CPU: Unspecified 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/", 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:

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

# 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)

Change History (4)

comment:1 by martinl, 7 years ago


comment:2 by neteler, 7 years ago


Ticket retargeted after milestone closed

comment:3 by martinl, 6 years ago

Milestone: 7.2.3

Ticket retargeted after milestone closed

comment:4 by martinl, 6 years ago

Milestone: 7.2.4
Note: See TracTickets for help on using tickets.