[GRASS-SVN] r53799 - grass/branches/develbranch_6/gui/wxpython

svn_grass at osgeo.org svn_grass at osgeo.org
Wed Nov 14 01:37:50 PST 2012


Author: martinl
Date: 2012-11-14 01:37:49 -0800 (Wed, 14 Nov 2012)
New Revision: 53799

Modified:
   grass/branches/develbranch_6/gui/wxpython/gis_set.py
Log:
wxGUI/gis_set: welcome screen - location or mapset doesn't exists
	       (merge r53798 from trunk)


Modified: grass/branches/develbranch_6/gui/wxpython/gis_set.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gis_set.py	2012-11-14 09:34:11 UTC (rev 53798)
+++ grass/branches/develbranch_6/gui/wxpython/gis_set.py	2012-11-14 09:37:49 UTC (rev 53799)
@@ -39,7 +39,7 @@
 import wx.lib.scrolledpanel as scrolled
 
 from gui_core.ghelp import HelpFrame
-from core.gcmd      import GMessage, GError, DecodeString, RunCommand
+from core.gcmd      import GMessage, GError, DecodeString, RunCommand, GWarning
 from core.utils     import GetListOfLocations, GetListOfMapsets
 from location_wizard.dialogs import RegionDef
 
@@ -215,29 +215,35 @@
         if location == "<UNKNOWN>" or \
                 not os.path.isdir(os.path.join(self.gisdbase, location)):
             location = None
-
-        if location:
-            # list of locations
-            self.UpdateLocations(self.gisdbase)
+        
+        # list of locations
+        self.UpdateLocations(self.gisdbase)
+        try:
+            self.lblocations.SetSelection(self.listOfLocations.index(location),
+                                          force = True)
+            self.lblocations.EnsureVisible(self.listOfLocations.index(location))
+        except ValueError:
+            sys.stderr.write(_("ERROR: Location <%s> not found\n") % self.GetRCValue("LOCATION_NAME"))
+            if len(self.listOfLocations) > 0:
+                self.lblocations.SetSelection(0, force = True)
+                self.lblocations.EnsureVisible(0)
+                location = self.listOfLocations[0]
+            else:
+                return
+        
+        # list of mapsets
+        self.UpdateMapsets(os.path.join(self.gisdbase, location))
+        mapset = self.GetRCValue("MAPSET")
+        if mapset:
             try:
-                self.lblocations.SetSelection(self.listOfLocations.index(location),
-                                              force = True)
-                self.lblocations.EnsureVisible(self.listOfLocations.index(location))
+                self.lbmapsets.SetSelection(self.listOfMapsets.index(mapset),
+                                            force = True)
+                self.lbmapsets.EnsureVisible(self.listOfMapsets.index(mapset))
             except ValueError:
-                print >> sys.stderr, _("ERROR: Location <%s> not found") % location
-            
-            # list of mapsets
-            self.UpdateMapsets(os.path.join(self.gisdbase, location))
-            mapset = self.GetRCValue("MAPSET")
-            if mapset:
-                try:
-                    self.lbmapsets.SetSelection(self.listOfMapsets.index(mapset),
-                                                force = True)
-                    self.lbmapsets.EnsureVisible(self.listOfMapsets.index(mapset))
-                except ValueError:
-                    self.lbmapsets.Clear()
-                    print >> sys.stderr, _("ERROR: Mapset <%s> not found") % mapset
-                    
+                sys.stderr.write(_("ERROR: Mapset <%s> not found\n") % mapset)
+                self.lbmapsets.SetSelection(0, force = True)
+                self.lbmapsets.EnsureVisible(0)
+        
     def _do_layout(self):
         sizer           = wx.BoxSizer(wx.VERTICAL)
         dbase_sizer     = wx.BoxSizer(wx.HORIZONTAL)



More information about the grass-commit mailing list