[GRASS-SVN] r41466 - in grass/trunk/gui/wxpython: . gui_modules

svn_grass at osgeo.org svn_grass at osgeo.org
Wed Mar 17 07:11:05 EDT 2010


Author: martinl
Date: 2010-03-17 07:11:04 -0400 (Wed, 17 Mar 2010)
New Revision: 41466

Modified:
   grass/trunk/gui/wxpython/gis_set.py
   grass/trunk/gui/wxpython/gui_modules/prompt.py
   grass/trunk/gui/wxpython/gui_modules/utils.py
Log:
bugfix #1004
(merge r41465 from devbr6)


Modified: grass/trunk/gui/wxpython/gis_set.py
===================================================================
--- grass/trunk/gui/wxpython/gis_set.py	2010-03-17 11:00:17 UTC (rev 41465)
+++ grass/trunk/gui/wxpython/gis_set.py	2010-03-17 11:11:04 UTC (rev 41466)
@@ -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
 
@@ -585,6 +584,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/trunk/gui/wxpython/gui_modules/prompt.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/prompt.py	2010-03-17 11:00:17 UTC (rev 41465)
+++ grass/trunk/gui/wxpython/gui_modules/prompt.py	2010-03-17 11:11:04 UTC (rev 41466)
@@ -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/trunk/gui/wxpython/gui_modules/utils.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/utils.py	2010-03-17 11:00:17 UTC (rev 41465)
+++ grass/trunk/gui/wxpython/gui_modules/utils.py	2010-03-17 11:11:04 UTC (rev 41466)
@@ -595,8 +595,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')
     
@@ -624,3 +623,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