Skip to content

Commit

Permalink
wxGUI: Ignore stderr of the GUI (#3049)
Browse files Browse the repository at this point in the history
When GUI is started by the init (grass.py) script, error messages coming from wxGUI are now ignored. The messages can be inspected by setting GRASS_DEBUG.

There is many GTK critical messages which seem very critical, but are harmless for the end user and we had little luck in fixing them, perhaps because we are using GTK only through wxPython and not directly. Complains about the messages far outnumber complains about non-functional widgets on GTK, so hiding the messages not relevant to the end user by default makes sense. Other programs typically don't face this issue as they are not started from terminal or they use daemon process for the main process, so it's unclear what is the common practice except for the result being no messages are typically visible to the end user.

* React to GRASS GIS environment WX_DEBUG besides system environment variable GRASS_DEBUG
  • Loading branch information
wenzeslaus authored Feb 2, 2024
1 parent 13a7936 commit 5e3858b
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions lib/init/grass.py
Original file line number Diff line number Diff line change
Expand Up @@ -1787,8 +1787,18 @@ def start_gui(grass_gui):
debug("GRASS GUI should be <%s>" % grass_gui)
# Check for gui interface
if grass_gui == "wxpython":
# TODO: report failures
return Popen([os.getenv("GRASS_PYTHON"), wxpath("wxgui.py")])
# Lazy-import to avoid dependency during standard import time.
# pylint: disable=import-outside-toplevel
import grass.script as gs

if is_debug() or "WX_DEBUG" in gs.gisenv():
stderr_redirect = None
else:
stderr_redirect = subprocess.DEVNULL
# TODO: report start failures?
return Popen(
[os.getenv("GRASS_PYTHON"), wxpath("wxgui.py")], stderr=stderr_redirect
)
return None


Expand Down

0 comments on commit 5e3858b

Please sign in to comment.