[GRASS-SVN] r45548 - grass/branches/develbranch_6/gui/wxpython/gui_modules

svn_grass at osgeo.org svn_grass at osgeo.org
Fri Mar 4 11:02:06 EST 2011


Author: martinl
Date: 2011-03-04 08:02:06 -0800 (Fri, 04 Mar 2011)
New Revision: 45548

Modified:
   grass/branches/develbranch_6/gui/wxpython/gui_modules/goutput.py
   grass/branches/develbranch_6/gui/wxpython/gui_modules/prompt.py
Log:
wxGUI: read/write history file with encoding 'utf-8' (see #1293)


Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/goutput.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/goutput.py	2011-03-04 15:12:03 UTC (rev 45547)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/goutput.py	2011-03-04 16:02:06 UTC (rev 45548)
@@ -24,6 +24,7 @@
 import time
 import threading
 import Queue
+import codecs
 
 import wx
 import wx.stc
@@ -411,7 +412,7 @@
 
     def WriteError(self, line):
         """!Write message in error style"""
-        self.WriteLog(line, style=self.cmd_output.StyleError, switchPage = True)
+        self.WriteLog(line, style = self.cmd_output.StyleError, switchPage = True)
 
     def RunCmd(self, command, compReg = True, switchPage = False,
                onDone = None):
@@ -434,10 +435,13 @@
         # update history file
         env = grass.gisenv()
         try:
-            fileHistory = open(os.path.join(env['GISDBASE'], env['LOCATION_NAME'], env['MAPSET'],
-                                            '.bash_history'), 'a')
+            fileHistory = codecs.open(os.path.join(env['GISDBASE'],
+                                                   env['LOCATION_NAME'],
+                                                   env['MAPSET'],
+                                                   '.bash_history'),
+                                      encoding = 'utf-8', mode = 'a')
         except IOError, e:
-            self.WriteError(str(e))
+            self.WriteError(e)
             fileHistory = None
         
         if fileHistory:
@@ -1067,8 +1071,8 @@
                 elif os.environ.has_key('GRASS_DB_ENCODING'):
                     txt = unicode(txt, os.environ['GRASS_DB_ENCODING'])
                 else:
-                    txt = _('Unable to encode text. Please set encoding in GUI preferences.') + '\n'
-                    
+                    txt = utils.EncodeString(txt)
+                
                 self.AddText(txt)
         
         # reset output window to read only

Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/prompt.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/prompt.py	2011-03-04 15:12:03 UTC (rev 45547)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/prompt.py	2011-03-04 16:02:06 UTC (rev 45548)
@@ -24,6 +24,7 @@
 import shlex
 import copy
 import difflib
+import codecs
 
 import wx
 import wx.stc
@@ -505,10 +506,11 @@
         hist = list()
         env = grass.gisenv()
         try:
-            fileHistory = open(os.path.join(env['GISDBASE'],
-                                            env['LOCATION_NAME'],
-                                            env['MAPSET'],
-                                            '.bash_history'), 'r')
+            fileHistory = codecs.open(os.path.join(env['GISDBASE'],
+                                                   env['LOCATION_NAME'],
+                                                   env['MAPSET'],
+                                                   '.bash_history'),
+                                      encoding = 'utf-8', mode = 'r')
         except IOError:
             return hist
         
@@ -1059,6 +1061,7 @@
                 cmd = utils.split(str(line))
             except UnicodeError:
                 cmd = utils.split(utils.EncodeString((line)))
+            cmd = map(utils.DecodeString, cmd)
             
             #  send the command list to the processor 
             if cmd[0] in ('r.mapcalc', 'r3.mapcalc') and len(cmd) == 1:



More information about the grass-commit mailing list