Opened 3 years ago

Last modified 21 months 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

Description

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:

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)

Change History (4)

comment:1 Changed 3 years ago by martinl

Milestone: 7.2.17.2.2

comment:2 Changed 2 years ago by neteler

Milestone: 7.2.27.2.3

Ticket retargeted after milestone closed

comment:3 Changed 21 months ago by martinl

Milestone: 7.2.3

Ticket retargeted after milestone closed

comment:4 Changed 21 months ago by martinl

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