Browse Source

bugfix https://trac.osgeo.org/grass/ticket/1004
(merge https://trac.osgeo.org/grass/changeset/41465 from devbr6)


git-svn-id: https://svn.osgeo.org/grass/grass/trunk@41466 15284696-431f-4ddb-bdfa-cd5b030d7da7

Martin Landa 15 years ago
parent
commit
4e87a6f827
3 changed files with 28 additions and 11 deletions
  1. 6 6
      gui/wxpython/gis_set.py
  2. 5 3
      gui/wxpython/gui_modules/prompt.py
  3. 17 2
      gui/wxpython/gui_modules/utils.py

+ 6 - 6
gui/wxpython/gis_set.py

@@ -212,6 +212,7 @@ class GRASSStartup(wx.Frame):
         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 @@ class GRASSStartup(wx.Frame):
                 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 @@ class GRASSStartup(wx.Frame):
                 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 @@ class GRASSStartup(wx.Frame):
         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,

+ 5 - 3
gui/wxpython/gui_modules/prompt.py

@@ -842,13 +842,15 @@ class GPromptSTC(GPrompt, wx.stc.StyledTextCtrl):
             # 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)

+ 17 - 2
gui/wxpython/gui_modules/utils.py

@@ -595,8 +595,7 @@ def GetListOfMapsets(dbase, location, selectable = False):
             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 @@ def EncodeString(string):
         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