Bläddra i källkod

show error dialog when wxGUI is used

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@41740 15284696-431f-4ddb-bdfa-cd5b030d7da7
Martin Landa 15 år sedan
förälder
incheckning
83fd10dfd0
2 ändrade filer med 58 tillägg och 10 borttagningar
  1. 39 0
      gui/wxpython/gis_set_error.py
  2. 19 10
      lib/init/grass.py

+ 39 - 0
gui/wxpython/gis_set_error.py

@@ -0,0 +1,39 @@
+"""!
+@package gis_set_error.py
+
+GRASS start-up screen error message.
+
+(C) 2010 by the GRASS Development Team
+
+This program is free software under the GNU General Public License
+(>=v2). Read the file COPYING that comes with GRASS for details.
+
+@author Martin Landa <landa.martin gmail.com>
+"""
+
+import os
+import sys
+
+import gui_modules.globalvar as globalvar
+if not os.getenv("GRASS_WXBUNDLED"):
+    globalvar.CheckForWx()
+import wx
+
+def main():
+    app = wx.PySimpleApp()
+    
+    if len(sys.argv) == 1:
+        msg = "Unknown reason"
+    else:
+        msg = ''
+        for m in sys.argv[1:]:
+            msg += m
+    
+    wx.MessageBox(caption = "Error",
+                  message = msg,
+                  style = wx.OK | wx.ICON_ERROR)
+    
+    app.MainLoop()
+    
+if __name__ == "__main__":
+    main()

+ 19 - 10
lib/init/grass.py

@@ -3,12 +3,13 @@
 #
 #
 # MODULE:   	GRASS initialization (Python)
 # MODULE:   	GRASS initialization (Python)
 # AUTHOR(S):	Original author unknown - probably CERL
 # AUTHOR(S):	Original author unknown - probably CERL
-#               Andreas Lange - Germany - andreas.lange@rhein-main.de
-#   	    	Huidae Cho - Korea - grass4u@gmail.com
-#   	    	Justin Hickey - Thailand - jhickey@hpcc.nectec.or.th
-#   	    	Markus Neteler - Germany/Italy - neteler@itc.it
+#               Andreas Lange - Germany - andreas.lange at rhein-main.de
+#   	    	Huidae Cho - Korea - grass4u at gmail.com
+#   	    	Justin Hickey - Thailand - jhickey at hpcc.nectec.or.th
+#   	    	Markus Neteler - Germany/Italy - neteler at itc.it
 #		Hamish Bowman - New Zealand - hamish_b at yahoo,com
 #		Hamish Bowman - New Zealand - hamish_b at yahoo,com
 #		Converted to Python (based on init.sh) by Glynn Clements
 #		Converted to Python (based on init.sh) by Glynn Clements
+#               Martin Landa - Czech Republic - landa.martin at gmail.com
 # PURPOSE:  	Sets up some environment variables.
 # PURPOSE:  	Sets up some environment variables.
 #               It also parses any remaining command line options for
 #               It also parses any remaining command line options for
 #               setting the GISDBASE, LOCATION, and/or MAPSET.
 #               setting the GISDBASE, LOCATION, and/or MAPSET.
@@ -523,15 +524,23 @@ def check_lock():
     ret = call([gfile("etc", "lock"),
     ret = call([gfile("etc", "lock"),
 		lockfile,
 		lockfile,
 		"%d" % os.getpid()])
 		"%d" % os.getpid()])
+    
     if ret == 0:
     if ret == 0:
-	pass
+	msg = None
     elif ret == 2:
     elif ret == 2:
-	fatal("%s is currently running GRASS in selected mapset (file %s found). Concurrent use not allowed."
-	      % (user, lockfile))
+	msg = "%s is currently running GRASS in selected mapset (file %s found). " \
+            "Concurrent use not allowed." % \
+            (user, lockfile)
     else:
     else:
-	fatal("Unable to properly access \"%s\"\n" % lockfile +
-	      "Please notify system personel.")
-
+	msg = "Unable to properly access \"%s\"\n" % \
+            lockfile + "Please notify system personel."
+        
+    if msg:
+        if grass_gui == "wxpython":
+            thetest = call([os.getenv('GRASS_PYTHON'), os.path.join(wxpython_base, "gis_set_error.py"), msg])
+        else:
+            fatal(msg)
+    
 def make_fontcap():
 def make_fontcap():
     fc = os.getenv('GRASS_FONT_CAP')
     fc = os.getenv('GRASS_FONT_CAP')
     if fc and not os.access(fc, os.R_OK):
     if fc and not os.access(fc, os.R_OK):