소스 검색

some minor fixes in https://trac.osgeo.org/grass/changeset/45545
(merge https://trac.osgeo.org/grass/changeset/45546 from devbr6)


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

Martin Landa 14 년 전
부모
커밋
7907eb07e4
3개의 변경된 파일13개의 추가작업 그리고 7개의 파일을 삭제
  1. 0 1
      gui/wxpython/gis_set.py
  2. 3 2
      gui/wxpython/gui_modules/gcmd.py
  3. 10 4
      gui/wxpython/gui_modules/utils.py

+ 0 - 1
gui/wxpython/gis_set.py

@@ -620,7 +620,6 @@ 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,

+ 3 - 2
gui/wxpython/gui_modules/gcmd.py

@@ -31,6 +31,7 @@ import errno
 import signal
 import locale
 import traceback
+import types
 
 import wx
 
@@ -600,8 +601,8 @@ def RunCommand(prog, flags = "", overwrite = False, quiet = False, verbose = Fal
         ps.stdin.close()
         ps.stdin = None
     
-    stdout, stderr = map(lambda x: utils.DecodeString(x) if x and not 'None' else x, ps.communicate())
-        
+    stdout, stderr = map(lambda x: utils.DecodeString(x) if type(x) is types.StringType else x, ps.communicate())
+    
     ret = ps.returncode
         
     if ret != 0 and parent: 

+ 10 - 4
gui/wxpython/gui_modules/utils.py

@@ -642,15 +642,21 @@ def GetColorTables():
     return ret.splitlines()
 
 def DecodeString(string):
-    """!Return decoded string using system locales
+    """!Return decoded string
     
+    String is decoded as unicode, on failure
+    are used system locales.
+
     @param string string to be decoded
     
     @return decoded string
     """
-    enc = locale.getdefaultlocale()[1]
-    if enc:
-        return string.decode(enc)
+    try:
+        return string.decode('utf-8')
+    except LookupError:
+        enc = locale.getdefaultlocale()[1]
+        if enc:
+            return string.decode(enc)
     
     return string