[GRASS-SVN] r29446 - grass/trunk/gui/wxpython

svn_grass at osgeo.org svn_grass at osgeo.org
Sun Dec 16 06:23:16 EST 2007


Author: martinl
Date: 2007-12-16 06:23:16 -0500 (Sun, 16 Dec 2007)
New Revision: 29446

Modified:
   grass/trunk/gui/wxpython/gis_set.py
Log:
wxGUI: avoid crashing start-up screen when location mentioned in .grassrc doesn't exist

Modified: grass/trunk/gui/wxpython/gis_set.py
===================================================================
--- grass/trunk/gui/wxpython/gis_set.py	2007-12-16 11:19:23 UTC (rev 29445)
+++ grass/trunk/gui/wxpython/gis_set.py	2007-12-16 11:23:16 UTC (rev 29446)
@@ -64,9 +64,12 @@
             self.hbitmap = wx.StaticBitmap(self, wx.ID_ANY, wx.EmptyBitmap(530,150))
 
         # labels
-        versionCmd = gcmd.Command(['g.version'], log=None)
-            
-        grassVersion = versionCmd.ReadStdOutput()[0].replace('GRASS', '').strip()
+        ### crashes when LOCATION doesn't exist
+        # versionCmd = gcmd.Command(['g.version'], log=None)
+        # grassVersion = versionCmd.ReadStdOutput()[0].replace('GRASS', '').strip()
+        versionFile = open(os.path.join(self.gisbase, "etc", "VERSIONNUMBER"))
+        grassVersion = versionFile.readline().replace('%s' % os.linesep, '').strip()
+        versionFile.close()
 
         self.select_box = wx.StaticBox (parent=self, id=wx.ID_ANY,
                                         label=" %s " % _("Choose project location and mapset"))
@@ -175,7 +178,8 @@
 
         self.OnSetDatabase(None)
         location = self._getRCValue("LOCATION_NAME")
-        if location == "<UNKNOWN>":
+        if location == "<UNKNOWN>" or \
+                not os.path.isdir(os.path.join(self.gisdbase, location)):
             location = None
         if location:
             # list of locations



More information about the grass-commit mailing list