[GRASS-SVN] r41465 - in grass/branches/develbranch_6/gui/wxpython: . gui_modules

svn_grass at osgeo.org svn_grass at osgeo.org
Wed Mar 17 07:00:18 EDT 2010


Author: martinl
Date: 2010-03-17 07:00:17 -0400 (Wed, 17 Mar 2010)
New Revision: 41465

Modified:
   grass/branches/develbranch_6/gui/wxpython/gis_set.py
   grass/branches/develbranch_6/gui/wxpython/gui_modules/prompt.py
   grass/branches/develbranch_6/gui/wxpython/gui_modules/utils.py
Log:
bugfix #1004


Modified: grass/branches/develbranch_6/gui/wxpython/gis_set.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gis_set.py	2010-03-17 10:37:01 UTC (rev 41464)
+++ grass/branches/develbranch_6/gui/wxpython/gis_set.py	2010-03-17 11:00:17 UTC (rev 41465)
@@ -212,6 +212,7 @@
         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)
@@ -221,10 +222,10 @@
                 self.lblocations.EnsureVisible(self.listOfLocations.index(location))
             except ValueError:
                 print >> sys.stderr, _("ERROR: Location <%s> not found") % \
-                    (location)
+                    (utils.UnicodeString(location))
                 
             # list of mapsets
-            self.UpdateMapsets(os.path.join(self.gisdbase,location))
+            self.UpdateMapsets(os.path.join(self.gisdbase, location))
             mapset = self.GetRCValue("MAPSET")
             if mapset:
                 try:
@@ -234,10 +235,8 @@
                 except ValueError:
                     self.lbmapsets.Clear()
                     print >> sys.stderr, _("ERROR: Mapset <%s> not found") % \
-                        (mapset)
-
-                # self.bstart.Enable(True)
-
+                        (utils.UnicodeString(mapset))
+            
     def _do_layout(self):
         label_style = wx.ADJUST_MINSIZE | wx.ALIGN_CENTER_HORIZONTAL
 
@@ -587,6 +586,7 @@
         disabled = []
         idx = 0
         for mapset in self.listOfMapsets:
+            mapset = utils.UnicodeString(mapset)
             if mapset not in self.listOfMapsetsSelectable or \
                     os.path.isfile(os.path.join(self.gisdbase,
                                                 locationName,

Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/prompt.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/prompt.py	2010-03-17 10:37:01 UTC (rev 41464)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/prompt.py	2010-03-17 11:00:17 UTC (rev 41465)
@@ -842,13 +842,15 @@
             # Run command on line when <return> is pressed    
             
             # find the command to run
-            line = str(self.GetCurLine()[0]).strip()
+            line = self.GetCurLine()[0].strip()
             if len(line) == 0:
                 return
             
             # parse command into list
-            # TODO: shell commands should probably be passed as string           
-            cmd = shlex.split(str(line))
+            try:
+                cmd = shlex.split(str(line))
+            except UnicodeError:
+                cmd = shlex.split(utils.EncodeString((line)))
             
             #send the command list to the processor 
             self.parent.RunCmd(cmd)

Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/utils.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/utils.py	2010-03-17 10:37:01 UTC (rev 41464)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/utils.py	2010-03-17 11:00:17 UTC (rev 41465)
@@ -599,8 +599,7 @@
             if os.path.isdir(mapset) and \
                     os.path.isfile(os.path.join(dbase, location, mapset, "WIND")) and \
                     os.path.basename(mapset) != 'PERMANENT':
-                listOfMapsets.append(os.path.basename(mapset))
-    
+                listOfMapsets.append(EncodeString(os.path.basename(mapset)))
         ListSortLower(listOfMapsets)
         listOfMapsets.insert(0, 'PERMANENT')
     
@@ -628,3 +627,19 @@
         return string.encode(enc)
     
     return string
+
+def UnicodeString(string):
+    """!Return unicode string
+    
+    @param string string to be converted
+    
+    @return unicode string
+    """
+    if isinstance(string, unicode):
+        return string
+    
+    enc = locale.getdefaultlocale()[1]
+    if enc:
+        return unicode(string, enc)
+    
+    return string



More information about the grass-commit mailing list