[GRASS-SVN] r65851 - in grass/trunk: gui/wxpython lib/init
svn_grass at osgeo.org
svn_grass at osgeo.org
Fri Aug 7 13:06:12 PDT 2015
Author: wenzeslaus
Date: 2015-08-07 13:06:12 -0700 (Fri, 07 Aug 2015)
New Revision: 65851
Modified:
grass/trunk/gui/wxpython/gis_set.py
grass/trunk/lib/init/grass.py
Log:
init: change gis_init return code
Previous return code was overlapping with Python when file is not found (e.g. not installed grass-gui).
In theory, it could be even handled separately, but the possible return/exit codes are unclear.
Modified: grass/trunk/gui/wxpython/gis_set.py
===================================================================
--- grass/trunk/gui/wxpython/gis_set.py 2015-08-07 19:41:56 UTC (rev 65850)
+++ grass/trunk/gui/wxpython/gis_set.py 2015-08-07 20:06:12 UTC (rev 65851)
@@ -45,6 +45,10 @@
class GRASSStartup(wx.Frame):
+ exit_success = 0
+ # 2 is file not found from python interpreter
+ exit_user_requested = 5
+
"""GRASS start-up screen"""
def __init__(self, parent = None, id = wx.ID_ANY, style = wx.DEFAULT_FRAME_STYLE):
@@ -998,12 +1002,12 @@
def ExitSuccessfully(self):
self.Destroy()
- sys.exit(0)
+ sys.exit(self.exit_success)
def OnExit(self, event):
"""'Exit' button clicked"""
self.Destroy()
- sys.exit(2)
+ sys.exit(self.exit_user_requested)
def OnHelp(self, event):
"""'Help' button clicked"""
@@ -1014,7 +1018,7 @@
def OnCloseWindow(self, event):
"""Close window event"""
event.Skip()
- sys.exit(2)
+ sys.exit(self.exit_user_requested)
def _nameValidationFailed(self, ctrl):
message = _("Name <%(name)s> is not a valid name for location or mapset. "
Modified: grass/trunk/lib/init/grass.py
===================================================================
--- grass/trunk/lib/init/grass.py 2015-08-07 19:41:56 UTC (rev 65850)
+++ grass/trunk/lib/init/grass.py 2015-08-07 20:06:12 UTC (rev 65851)
@@ -941,17 +941,24 @@
if grass_gui in ('wxpython', 'gtext'):
ret = call([os.getenv('GRASS_PYTHON'), wxpath("gis_set.py")])
+ # this if could be simplified to three branches (0, 5, rest)
+ # if there is no need to handle unknown code separately
if ret == 0:
pass
- elif ret == 1:
+ elif ret in [1, 2]:
+ # 1 probably error comming from gis_set.py
+ # 2 probably file not found from python interpreter
# formerly we were starting in text mode instead, now we just fail
# which is more straightforward for everybody
- fatal(_("Error in GUI startup. If necessary, please "
- "report this error to the GRASS developers.\n"
+ fatal(_("Error in GUI startup. See messages above (if any)"
+ " and if necessary, please"
+ " report this error to the GRASS developers.\n"
+ "On systems with package manager, make sure you have the right"
+ " GUI package, probably named grass-gui, installed.\n"
"To run GRASS GIS in text mode use the -text flag."))
- elif ret == 2:
+ elif ret == 5: # defined in gui/wxpython/gis_set.py
# User wants to exit from GRASS
- message(_("Received EXIT message from GUI.\nGRASS is not started. Bye."))
+ message(_("Exit was requested in GUI.\nGRASS GIS will not start. Bye."))
sys.exit(0)
else:
fatal(_("Invalid return code from GUI startup script.\n"
More information about the grass-commit
mailing list