[GRASS-dev] [GRASS GIS] #1004: WxGUI CMD fails if command contains non-latin letters

#1004: WxGUI CMD fails if command contains non-latin letters
-----------------------------+----------------------------------------------
Reporter: marisn | Owner: grass-dev@lists.osgeo.org
     Type: defect | Status: new
Priority: major | Milestone: 6.4.0
Component: wxGUI | Version: svn-releasebranch64
Keywords: wxgui, wingrass | Platform: MSWindows Vista
      Cpu: x86-32 |
-----------------------------+----------------------------------------------
If I enter some command in WxGUI CMD prompt that contains non-latin
letters, I get ugly Python error:

{{{
Traceback (most recent call last):
   File "C:/Program
Files/GRASS-64-SVN/etc/wxpython/wxgui.py", line 462, in
OnRunCmd

cmd = shlex.split(str(cmdString))
UnicodeEncodeError
:
'ascii' codec can't encode character u'\u0160' in position
55: ordinal not in range(128)
}}}

Tested on WinGRASS WinGRASS-6.4.SVN-r41428-1 running Vista

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/1004&gt;
GRASS GIS <http://grass.osgeo.org>

#1004: WxGUI CMD fails if command contains non-latin letters
------------------------------+---------------------------------------------
  Reporter: marisn | Owner: grass-dev@lists.osgeo.org
      Type: defect | Status: new
  Priority: major | Milestone: 6.4.0
Component: wxGUI | Version: svn-releasebranch64
Resolution: | Keywords: unicode, wingrass
  Platform: MSWindows Vista | Cpu: x86-32
------------------------------+---------------------------------------------
Changes (by martinl):

* cc: martinl (added)
  * keywords: wxgui, wingrass => unicode, wingrass

Comment:

The problem here is the fact that shlex does not support unicode...

http://docs.python.org/library/shlex.html

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/1004#comment:1&gt;
GRASS GIS <http://grass.osgeo.org>

#1004: WxGUI CMD fails if command contains non-latin letters
------------------------------+---------------------------------------------
  Reporter: marisn | Owner: martinl
      Type: defect | Status: assigned
  Priority: major | Milestone: 6.4.0
Component: wxGUI | Version: svn-releasebranch64
Resolution: | Keywords: unicode, wingrass
  Platform: MSWindows Vista | Cpu: x86-32
------------------------------+---------------------------------------------
Changes (by martinl):

* cc: martinl (removed)
* cc: grass-dev@lists.osgeo.org (added)
  * owner: grass-dev@lists.osgeo.org => martinl
  * status: new => assigned

Comment:

Replying to [comment:1 martinl]:
> The problem here is the fact that shlex does not support unicode...
>
> http://docs.python.org/library/shlex.html

Quick workaround implemented in r41459.

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/1004#comment:2&gt;
GRASS GIS <http://grass.osgeo.org>

#1004: WxGUI CMD fails if command contains non-latin letters
------------------------------+---------------------------------------------
  Reporter: marisn | Owner: martinl
      Type: defect | Status: assigned
  Priority: major | Milestone: 6.4.0
Component: wxGUI | Version: svn-releasebranch64
Resolution: | Keywords: unicode, wingrass
  Platform: MSWindows Vista | Cpu: x86-32
------------------------------+---------------------------------------------
Comment (by marisn):

WinGRASS-6.4.SVN-r41467-1

{{{
Exception in thread Thread-6:
Traceback (most recent call last):
   File "C:\OSGeo4W\apps\Python25\lib\threading.py", line
486, in __bootstrap_inner
     self.run()
   File "C:\Program
Files\GRASS-64-SVN\etc\wxpython\gui_modules\gcmd.py", line
539, in run
     shell=sys.platform=="win32")
   File "C:\Program
Files\GRASS-64-SVN\etc\wxpython\gui_modules\gcmd.py", line
139, in __init__
     targs[0] = map(utils.EncodeString, args[0])
   File "c:\osgeo4w\usr\src\grass64_release\dist.i686-pc-
mingw32\etc\wxpython\gui_modules\utils.py", line 345, in
EncodeString
     return string.encode(enc)
   File "C:\Program
Files\GRASS-64-SVN\Python25\lib\encodings\cp1257.py", line
12, in encode
     return
codecs.charmap_encode(input,errors,encoding_table)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in
position 0: ordinal not in range(128)
Exception
Traceback (most recent call last):
exceptions
   File "C:/Program
Files/GRASS-64-SVN/etc/wxpython/wxgui.py", line 471, in
OnRunCmd
.

AttributeError
self.goutput.RunCmd(cmd, switchPage=True)
:
   File "C:\Program
Files\GRASS-64-SVN\etc\wxpython\gui_modules\goutput.py",
line 377, in RunCmd
"'Popen' object has no attribute '_child_created'"

  in
stderr=self.cmd_stderr)
<bound method Popen.__del__ of <gui_modules.gcmd.Popen
object at 0x03F3B210>>
   File "C:\Program
Files\GRASS-64-SVN\etc\wxpython\gui_modules\gcmd.py", line
369, in __init__
  ignored

_("Error: ") + self.GetError()))
   File "C:\Program
Files\GRASS-64-SVN\etc\wxpython\gui_modules\gcmd.py", line
458, in GetError

return _("Unable to exectute command: '%s'") % '
'.join(self.cmd)
UnicodeDecodeError
:
'ascii' codec can't decode byte 0xe2 in position 3: ordinal
not in range(128)
}}}

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/1004#comment:3&gt;
GRASS GIS <http://grass.osgeo.org>

#1004: WxGUI CMD fails if command contains non-latin letters
-------------------------------+--------------------------------------------
Reporter: marisn | Owner: martinl
     Type: defect | Status: assigned
Priority: major | Milestone: 6.4.0
Component: wxGUI | Version: svn-releasebranch64
Keywords: unicode, wingrass | Platform: MSWindows Vista
      Cpu: x86-32 |
-------------------------------+--------------------------------------------

Comment(by neteler):

See also trac #995

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/1004#comment:4&gt;
GRASS GIS <http://grass.osgeo.org>

#1004: WxGUI CMD fails if command contains non-latin letters
-------------------------------+--------------------------------------------
Reporter: marisn | Owner: martinl
     Type: defect | Status: assigned
Priority: major | Milestone: 6.4.0
Component: wxGUI | Version: svn-releasebranch64
Keywords: unicode, wingrass | Platform: MSWindows Vista
      Cpu: x86-32 |
-------------------------------+--------------------------------------------

Comment(by martinl):

Please try out r45549 (trunk or devbr6)

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/1004#comment:5&gt;
GRASS GIS <http://grass.osgeo.org>

#1004: WxGUI CMD fails if command contains non-latin letters
-------------------------------+--------------------------------------------
Reporter: marisn | Owner: martinl
     Type: defect | Status: assigned
Priority: major | Milestone: 6.4.0
Component: wxGUI | Version: svn-releasebranch64
Keywords: unicode, wingrass | Platform: MSWindows Vista
      Cpu: x86-32 |
-------------------------------+--------------------------------------------

Comment(by marisn):

Still fails.

String for testing:
{{{
db.out.ogr input=bugsites dsn="C:\Users\tests\Documents\šaursliežu
dzelzceļš\šaurā datubāze"
}}}

WinGRASS-6.5.SVN-r45558-1
{{{
Traceback (most recent call last):
   File "C:\Program Files\GRASS
6.5.SVN\etc\wxpython\gui_modules\prompt.py", line 1064, in
OnKeyPressed

cmd = map(utils.DecodeString, cmd)
   File "c:/osgeo4w/usr/src/grass6_devel/dist.i686-pc-
mingw32/etc/wxpython/gui_modules/utils.py", line 655, in
DecodeString
   File "C:\Program Files\GRASS
6.5.SVN\Python25\lib\encodings\utf_8.py", line 16, in decode

return codecs.utf_8_decode(input, errors, True)
UnicodeDecodeError
:
'utf8' codec can't decode bytes in position 29-32: invalid
data

}}}

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/1004#comment:6&gt;
GRASS GIS <http://grass.osgeo.org>

#1004: WxGUI CMD fails if command contains non-latin letters
-------------------------------+--------------------------------------------
Reporter: marisn | Owner: martinl
     Type: defect | Status: assigned
Priority: major | Milestone: 6.4.1
Component: wxGUI | Version: svn-releasebranch64
Keywords: unicode, wingrass | Platform: MSWindows Vista
      Cpu: x86-32 |
-------------------------------+--------------------------------------------
Changes (by hellik):

  * milestone: 6.4.0 => 6.4.1

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/1004#comment:7&gt;
GRASS GIS <http://grass.osgeo.org>

#1004: WxGUI CMD fails if command contains non-latin letters
-------------------------------+--------------------------------------------
Reporter: marisn | Owner: martinl
     Type: defect | Status: assigned
Priority: major | Milestone: 6.4.1
Component: wxGUI | Version: svn-releasebranch64
Keywords: unicode, wingrass | Platform: MSWindows Vista
      Cpu: x86-32 |
-------------------------------+--------------------------------------------

Comment(by neteler):

Some decoding stuff has been backported to 6.4/6.5, is this still an
issue?

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/1004#comment:8&gt;
GRASS GIS <http://grass.osgeo.org>

#1004: WxGUI CMD fails if command contains non-latin letters
-------------------------------+--------------------------------------------
Reporter: marisn | Owner: martinl
     Type: defect | Status: assigned
Priority: major | Milestone: 6.4.2
Component: wxGUI | Version: svn-releasebranch64
Keywords: unicode, wingrass | Platform: MSWindows Vista
      Cpu: x86-32 |
-------------------------------+--------------------------------------------
Changes (by marisn):

  * milestone: 6.4.1 => 6.4.2

Comment:

Replying to [comment:8 neteler]:
> Some decoding stuff has been backported to 6.4/6.5, is this still an
issue?
Can't test it, as now it fails somewhere in parser with "Sorry <> is not a
valid option". Will have to open a new ticket for it at first.

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/1004#comment:9&gt;
GRASS GIS <http://grass.osgeo.org>

#1004: WxGUI CMD fails if command contains non-latin letters
------------------------------+---------------------------------------------
  Reporter: marisn | Owner: martinl
      Type: defect | Status: closed
  Priority: major | Milestone: 6.4.2
Component: wxGUI | Version: svn-releasebranch64
Resolution: fixed | Keywords: unicode, wingrass
  Platform: MSWindows Vista | Cpu: x86-32
------------------------------+---------------------------------------------
Changes (by marisn):

  * status: assigned => closed
  * resolution: => fixed

Comment:

Works now for me on Linux with UTF-8 locale. Complaints about "not valid
option" are another issue.

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/1004#comment:10&gt;
GRASS GIS <http://grass.osgeo.org>