Skip to content

Comments

grass.script: Pass env to debug_level#5920

Merged
wenzeslaus merged 2 commits intoOSGeo:mainfrom
wenzeslaus:pass-env-to-debug_level
Jun 20, 2025
Merged

grass.script: Pass env to debug_level#5920
wenzeslaus merged 2 commits intoOSGeo:mainfrom
wenzeslaus:pass-env-to-debug_level

Conversation

@wenzeslaus
Copy link
Member

To get a debug level Python code calls debug_level function which in turn needs to call g.gisenv because the debug level is stored in GRASS gisenv variable (and not as a system environment variable). For call to g.gisenv, one needs to have a session (GISRC) set up, so env is needed when it is only a local one (and not os.environ).

Experimentally, this also removes the monkeypatch fixture from the recently added test for g.list which, without the monkeypatch, failed on Windows with GISRC missing from g.gisenv indicating that os.environ was set up with the runtime (PATH etc.), but didn't have an active session (GISRC etc.). This should pass the correct local environment through env all the way to g.gisenv. (Additionally, the fixture scope is changed to module, so that it is created only once.)

To get a debug level Python code calls debug_level function which in turn needs to call g.gisenv because the debug level is stored in GRASS gisenv variable (and not as a system environment variable). For call to g.gisenv, one needs to have a session (GISRC) set up, so env is needed when it is only a local one (and not os.environ).

Experimentally, this also removes the monkeypatch fixture from the recently added test for g.list which, without the monkeypatch, failed on Windows with GISRC missing from g.gisenv indicating that os.environ was set up with the runtime (PATH etc.), but didn't have an active session (GISRC etc.). This should pass the correct local environment through env all the way to g.gisenv. (Additionally, the fixture scope is changed to module, so that it is created only once.)
@echoix
Copy link
Member

echoix commented Jun 20, 2025

Looks promising

Copy link
Member

@echoix echoix left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Little typos

Co-authored-by: Edouard Choinière <[email protected]>
@wenzeslaus
Copy link
Member Author

The g.list test without monkeypatch runs, so I'm keeping the change there. Let's merge this.

@wenzeslaus wenzeslaus enabled auto-merge (squash) June 20, 2025 19:42
@echoix
Copy link
Member

echoix commented Jun 20, 2025

The g.list test without monkeypatch runs, so I'm keeping the change there. Let's merge this.

Great!

@wenzeslaus wenzeslaus merged commit bd65b0a into OSGeo:main Jun 20, 2025
27 checks passed
@wenzeslaus wenzeslaus deleted the pass-env-to-debug_level branch June 20, 2025 23:09
@github-actions github-actions bot added this to the 8.5.0 milestone Jun 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

general libraries module Python Related code is in Python tests Related to Test Suite

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants