[GRASS-SVN] r41399 - in grass/trunk/gui/wxpython: . gui_modules
svn_grass at osgeo.org
svn_grass at osgeo.org
Fri Mar 12 08:43:36 EST 2010
Author: martinl
Date: 2010-03-12 08:43:35 -0500 (Fri, 12 Mar 2010)
New Revision: 41399
Modified:
grass/trunk/gui/wxpython/gis_set.py
grass/trunk/gui/wxpython/gui_modules/gcmd.py
grass/trunk/gui/wxpython/gui_modules/location_wizard.py
grass/trunk/gui/wxpython/gui_modules/utils.py
Log:
bugfix #995
(merge r41397, r41398) from devbr6
Modified: grass/trunk/gui/wxpython/gis_set.py
===================================================================
--- grass/trunk/gui/wxpython/gis_set.py 2010-03-12 13:38:04 UTC (rev 41398)
+++ grass/trunk/gui/wxpython/gis_set.py 2010-03-12 13:43:35 UTC (rev 41399)
@@ -198,8 +198,14 @@
self.gisdbase = os.getenv("HOME")
else:
self.gisdbase = os.getcwd()
- self.tgisdbase.SetValue(self.gisdbase)
-
+ try:
+ self.tgisdbase.SetValue(self.gisdbase)
+ except UnicodeDecodeError:
+ wx.MessageBox(parent = self, caption = _("Error"),
+ message = _("Unable to set GRASS database. "
+ "Check your locale settings."),
+ style=wx.OK | wx.ICON_ERROR | wx.CENTRE)
+
self.OnSetDatabase(None)
location = self.GetRCValue("LOCATION_NAME")
if location == "<UNKNOWN>" or \
@@ -523,7 +529,13 @@
def UpdateLocations(self, dbase):
"""!Update list of locations"""
- self.listOfLocations = utils.GetListOfLocations(dbase)
+ try:
+ self.listOfLocations = utils.GetListOfLocations(dbase)
+ except UnicodeEncodeError:
+ wx.MessageBox(parent = self, caption = _("Error"),
+ message = _("Unable to set GRASS database. "
+ "Check your locale settings."),
+ style=wx.OK | wx.ICON_ERROR | wx.CENTRE)
self.lblocations.Clear()
self.lblocations.InsertItems(self.listOfLocations, 0)
Modified: grass/trunk/gui/wxpython/gui_modules/gcmd.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/gcmd.py 2010-03-12 13:38:04 UTC (rev 41398)
+++ grass/trunk/gui/wxpython/gui_modules/gcmd.py 2010-03-12 13:43:35 UTC (rev 41399)
@@ -134,6 +134,18 @@
class Popen(subprocess.Popen):
"""!Subclass subprocess.Popen"""
+ def __init__(self, *args, **kwargs):
+ if subprocess.mswindows:
+ try:
+ kwargs['args'] = map(utils.EncodeString, kwargs['args'])
+ except KeyError:
+ if len(args) > 0:
+ targs = list(args)
+ targs[0] = map(utils.EncodeString, args[0])
+ args = tuple(targs)
+
+ subprocess.Popen.__init__(self, *args, **kwargs)
+
def recv(self, maxsize=None):
return self._recv('stdout', maxsize)
Modified: grass/trunk/gui/wxpython/gui_modules/location_wizard.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/location_wizard.py 2010-03-12 13:38:04 UTC (rev 41398)
+++ grass/trunk/gui/wxpython/gui_modules/location_wizard.py 2010-03-12 13:43:35 UTC (rev 41399)
@@ -1681,8 +1681,8 @@
projdesc = self.parent.projpage.projdesc
ellipsedesc = self.parent.ellipsepage.ellipsedesc
datumdesc = self.parent.datumpage.datumdesc
- self.ldatabase.SetLabel(str(database))
- self.llocation.SetLabel(str(location))
+ self.ldatabase.SetLabel(database)
+ self.llocation.SetLabel(location)
label = ''
if coordsys == 'epsg':
Modified: grass/trunk/gui/wxpython/gui_modules/utils.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/utils.py 2010-03-12 13:38:04 UTC (rev 41398)
+++ grass/trunk/gui/wxpython/gui_modules/utils.py 2010-03-12 13:43:35 UTC (rev 41399)
@@ -17,6 +17,7 @@
import platform
import string
import glob
+import locale
import globalvar
grassPath = os.path.join(globalvar.ETCDIR, "python")
@@ -465,7 +466,7 @@
return path[1].upper() + ':\\' + path[3:].replace('/', '\\')
return path
-
+
def ReadEpsgCodes(path):
"""!Read EPSG code from the file
@@ -551,14 +552,17 @@
@return list of locations (sorted)
"""
listOfLocations = list()
+
+ try:
+ for location in glob.glob(os.path.join(dbase, "*")):
+ try:
+ if os.path.join(location, "PERMANENT") in glob.glob(os.path.join(location, "*")):
+ listOfLocations.append(os.path.basename(location))
+ except:
+ pass
+ except UnicodeEncodeError, e:
+ raise e
- for location in glob.glob(os.path.join(dbase, "*")):
- try:
- if os.path.join(location, "PERMANENT") in glob.glob(os.path.join(location, "*")):
- listOfLocations.append(os.path.basename(location))
- except:
- pass
-
ListSortLower(listOfLocations)
return listOfLocations
@@ -607,3 +611,16 @@
return list()
return ret.splitlines()
+
+def EncodeString(string):
+ """!Return encoded string
+
+ @param string string to be encoded
+
+ @return encoded string
+ """
+ enc = locale.getdefaultlocale()[1]
+ if enc:
+ return string.encode(enc)
+
+ return string
More information about the grass-commit
mailing list