Opened 11 years ago

Closed 11 years ago

#1485 closed defect (fixed)

Cannot save workspace from wxGUI

Reported by: venkat Owned by: martinl
Priority: blocker Milestone: 6.4.2
Component: wxGUI Version: 6.4.2 RCs
Keywords: wingrass, cp932 Cc: grass-dev@…
CPU: Unspecified Platform: MSWindows 7

Description

Cannot save workspace from wxGUI

Please see the error in attached PDF

Attachments (1)

save_workspace.pdf (31.8 KB ) - added by venkat 11 years ago.
screen-shot

Download all attachments as: .zip

Change History (25)

by venkat, 11 years ago

Attachment: save_workspace.pdf added

screen-shot

comment:1 by martinl, 11 years ago

Component: DefaultwxGUI
Summary: GRASS6.4.2RC1 WX-Python GUI, menu does not work at allCannot save workspace from wxGUI

comment:2 by martinl, 11 years ago

Next time please attach png rather then pdf...

comment:3 by martinl, 11 years ago

Keywords: wingrass added

comment:4 by martinl, 11 years ago

Version: svn-trunk6.4.2 RCs

comment:5 by martinl, 11 years ago

I see same problem with path mismatch (see #1380)

C:\Program Files...

versus

c:\osgeo4w

How did you installed winGRASS?

comment:6 by neteler, 11 years ago

Venka, the only way I see is to clean up the machine and remove both OSGeo4W and winGRASS standalone to avoid the current mixture.

comment:7 by Venkat, 11 years ago

Tried on brand new computer. The issue is about unicode encoding. GRASS-6.4.2RC1, 6.4.1 do no seem to support Unicode. As I mentioned in http://trac.osgeo.org/grass/ticket/1380#comment:15

On Window-7 System local needs to be changed from Contro Panel --> Region and Language --> Change system locale. On Japanese Windows-7 the system locale is set to "Japanese". (Japanese/Chinese/Korean? are use double byte encoding, unlike English, German etc.). d.rast wxGUI works if I set the "system locale" to English or German (I tried with German too).

So something needs to be done about getting wxGUI working when System Locale is set to Japanese (and/or Chinese, Korean).

Venka

comment:8 by glynn, 11 years ago

So something needs to be done about getting wxGUI working when System Locale is set to Japanese

It's unclear whether GRASS can be made to work reliably with the Shift-JIS (CP932) encoding, due to the use of 0x5C (backslash/yen) as the second byte of a double-byte sequence. On Windows, GRASS always treats 0x5C as a directory separator. Similar use of 0x7C (vertical bar) may also cause problems, as it's commonly used as a field separator.

So far, we've yet to find a solution which doesn't involve far more work than is feasible.

comment:9 by naokiueda, 11 years ago

This #1485 probably same cause as #1380. I'd like to add a fixed code for 6.4.1. This has done by another GRASS User, who fixed this also in 6.4.0. Note that this fix, as it is, does not fit for 6.4.2, because base source code has changed a lot.


There are comment-out in etc/wxpython/gui_modules/menuform.py, line 2016 - 2019

2011 def ParseInterface(self, cmd, parser = processTask):
2012 """!Parse interface
2013
2014 @param cmd command to be parsed (given as list)
2015 """
2016 # enc = locale.getdefaultlocale()[1]
2017 # if enc and enc.lower() not in ("utf8", "utf-8"):
2018 # tree = etree.fromstring(getInterfaceDescription(cmd[0]).decode(enc).encode("utf-8"))
2019 # else:
2020 tree = etree.fromstring(getInterfaceDescription(cmd[0]))
2021
2022 return processTask(tree).GetTask()

Enabling these line by removing comment-out, will fix this problem in 6.4.1.


Also, there need to be two more fix.

in menuform.py, near line 2132

2132 def GetCommandInputMapParamKey(self, cmd):
2133 """!Get parameter key for input raster/vector map
2134
2135 @param cmd module name
2136
2137 @return parameter key
2138 @return None on failure
2139 """
2140 # parse the interface decription
2141 if not self.grass_task:
2142 tree = etree.fromstring(getInterfaceDescription(cmd))
2143 self.grass_task = processTask(tree).GetTask()
2144
2145 for p in self.grass_task.params:
2146 if p.get('name', ) in ('input', 'map'):
2147 age = p.get('age',
)
2148 prompt = p.get('prompt', )
2149 element = p.get('element',
)
2150 if age == 'old' and
2151 element in ('cell', 'grid3', 'vector') and
2152 prompt in ('raster', '3d-raster', 'vector'):
2153 return p.get('name', None)
2154 return None

change as follows

Before:
2141 if not self.grass_task:
2142 tree = etree.fromstring(getInterfaceDescription(cmd))
2143 self.grass_task = processTask(tree).GetTask()

After Fix:
2141 if not self.grass_task:
2142 enc = locale.getdefaultlocale()[1]
2143 if enc and enc.lower() not in ("utf8″, “utf-8″):
2144 p = re.compile(enc, re.IGNORECASE)
2145 tree = etree.fromstring(p.sub(’utf-8′, getInterfaceDescription(cmd)).decode(enc).encode("utf-8″))
2146 else:
2147 tree = etree.fromstring(getInterfaceDescription(cmd))




Also in menuform.py line 1957

1957 def getInterfaceDescription(cmd):
1958 """!Returns the XML description for the GRASS cmd.
1959
1960 The DTD must be located in $GISBASE/etc/grass-interface.dtd,
1961 otherwise the parser will not succeed.
1962
1963 @param cmd command (name of GRASS module)
1964 """
1965 try:
1966 cmdout, cmderr = grass.Popen([cmd, '--interface-description'], stdout = grass.PIPE,
1967 stderr = grass.PIPE).communicate()
1968 except OSError, e:
1969 raise gcmd.GException, _("Unable to fetch interface description for command '%s'. "
1970 "Details: %s") % (cmd, e.value)
1971 if cmderr and cmderr[:7] != 'WARNING':
1972 raise gcmd.GException, _("Unable to fetch interface description for command '%s'. "
1973 "Details: %s") % (cmd, cmderr)
1974
1975 return cmdout.replace('grass-interface.dtd', os.path.join(globalvar.ETCDIR, 'grass-interface.dtd'))


Before:
1971 if cmderr and cmderr[:7] != 'WARNING':

After Fix:
1971 if cmderr and cmderr[12:19] != 'WARNING':

This has to be done because this condition see if error string start with "WARNING" or not, but as a matter of fact, errot string was "GRASSINFO_WARNING".


There three fixes above solve issue in 6.4.2 (in multi-byte environmrnt).

comment:10 by naokiueda, 11 years ago

I'd like to also add this fix in 6.4.0. Base source code is 6.4.0 RC6

I think porting fixes above and below can solve this ticket issue and #1380. GRASS used to handle double byte characters before..


Before:

def GetCommandInputMapParamKey(self, cmd):

"""Get parameter key for input raster/vector map

@param cmd module name

@return parameter key
@return None on failure
"""
# parse the interface decription
if not self.grass_task:

self.grass_task = grassTask()
handler = processTask(self.grass_task)


xml.sax.parseString(getInterfaceDescription(cmd), handler)



After Fix:

def GetCommandInputMapParamKey(self, cmd):

"""Get parameter key for input raster/vector map

@param cmd module name

@return parameter key
@return None on failure
"""
# parse the interface decription
if not self.grass_task:

self.grass_task = grassTask()
handler = processTask(self.grass_task)


# xml.sax.parseString(getInterfaceDescription(cmd), handler)

enc = locale.getdefaultlocale()[1]
if enc and enc.lower() not in ("utf8", "utf-8"):

xml.sax.parseString(getInterfaceDescription(cmd).decode(enc).split('\n',1)[1].replace(, '<?xml version="1.0" encoding="utf-8"?>\n', 1).encode("utf-8"),

handler)

else:

xml.sax.parseString(getInterfaceDescription(cmd),

handler)

in reply to:  9 ; comment:11 by martinl, 11 years ago

Replying to naokiueda:

This #1485 probably same cause as #1380. I'd like to add a fixed code for 6.4.1. This has done by another GRASS User, who fixed this also in 6.4.0. Note that this fix, as it is, does not fit for 6.4.2, because base source code has changed a lot.

Done for devbr6 (GRASS 6.5) in r49064. Could you try the next daily build from http://wingrass.fsv.cvut.cz/grass65/ ?

in reply to:  11 comment:12 by martinl, 11 years ago

Replying to martinl:

Done for devbr6 (GRASS 6.5) in r49064. Could you try the next daily build from http://wingrass.fsv.cvut.cz/grass65/ ?

To track changes - small typo in r49068

comment:13 by martinl, 11 years ago

Cc: grass-dev@… added
Owner: changed from grass-dev@… to martinl
Status: newassigned

comment:14 by martinl, 11 years ago

Keywords: cp932 added

comment:15 by naokiueda, 11 years ago

I tested with r49086 that is just build. Problem still remains, and looks same as before.

I got an following error in GRASS console, when I click d.rast icon.


Traceback (most recent call last):

File "C:/Program Files/GRASS

6.5.SVN/etc/wxpython/wxgui.py", line 1376, in OnAddRaster

self.curr_page.maptree.AddLayer('raster')

File "c:/osgeo4w/usr/src/grass6_devel/dist.i686-pc-

mingw32/etc/wxpython/gui_modules/layertree.py", line 852, in AddLayer

File "c:/osgeo4w/usr/src/grass6_devel/dist.i686-pc-

mingw32/etc/wxpython/gui_modules/layertree.py", line 917, in PropertiesDialog

File "C:\Program Files\GRASS

6.5.SVN\etc\wxpython\gui_modules\menuform.py", line 1818, in ParseCommand

blackList = _blackList)

File "C:\Program Files\GRASS

6.5.SVN\etc\python\grass\script\task.py", line 453, in parse_interface

tree = etree.fromstring(get_interface_description(name).deco de(enc).encode("utf-8"))

File "C:\Program Files\GRASS

6.5.SVN\Python25\lib\xml\etree\ElementTree.py", line 963, in XML

parser.feed(text)

File "C:\Program Files\GRASS

6.5.SVN\Python25\lib\xml\etree\ElementTree.py", line 1245, in feed

self._parser.Parse(data, 0) xml.parsers.expat . ExpatError : unknown encoding: line 1, column 30 Traceback (most recent call last):

File "c:/osgeo4w/usr/src/grass6_devel/dist.i686-pc-

mingw32/etc/wxpython/gui_modules/layertree.py", line 992, in OnActivateLayer

File "c:/osgeo4w/usr/src/grass6_devel/dist.i686-pc-

mingw32/etc/wxpython/gui_modules/layertree.py", line 917, in PropertiesDialog

File "C:\Program Files\GRASS

6.5.SVN\etc\wxpython\gui_modules\menuform.py", line 1818, in ParseCommand

blackList = _blackList)

File "C:\Program Files\GRASS

6.5.SVN\etc\python\grass\script\task.py", line 453, in parse_interface

tree = etree.fromstring(get_interface_description(name).deco de(enc).encode("utf-8"))

File "C:\Program Files\GRASS

6.5.SVN\Python25\lib\xml\etree\ElementTree.py", line 963, in XML

parser.feed(text)

File "C:\Program Files\GRASS

6.5.SVN\Python25\lib\xml\etree\ElementTree.py", line 1245, in feed

self._parser.Parse(data, 0) xml.parsers.expat . ExpatError : unknown encoding: line 1, column 30

in reply to:  15 ; comment:16 by martinl, 11 years ago

Replying to naokiueda:

I tested with r49086 that is just build. Problem still remains, and looks same as before.

I have applied changes that you have suggested. I thought that it could help.

I got an following error in GRASS console, when I click d.rast icon.

Please next time use pre-formated text http://trac.osgeo.org/grass/wiki/WikiFormatting (-> Preformatted Text). Otherwise it's hard to read it.

in reply to:  16 comment:17 by martinl, 11 years ago

Replying to martinl:

Replying to naokiueda:

I tested with r49086 that is just build. Problem still remains, and looks same as before.

I probably found the reason why it fails, could you try r49091 (ie. next winGRASS build)?

comment:18 by naokiueda, 11 years ago

I tested with r49105 that should contain r49091.
I still got "ExpatError" "unknown encoding: line 1, column 30".

When I download r49105, the Python scripts (menuform.py, task.py) does not contain changes of 49064, 49086 , or 49091. So I ported chages by referencing diffs, and test it.
Result is still same.

comment:19 by Venkat, 11 years ago

I tested with winGRASS r49125-1 on Windows-7 (Japanese). The multi-byte Japanese encoding issue wxGUI seems to be solved. Tested d.rast, r.in.gdal and save workspace for the wxGUI and they all seem to work.

Will these changes in winGRASS r49125-1 to support multi-byte encoding back-ported to GRASS-6.4.2? We would like to continue with testing wxGUI in winGRASS, should be wait for the GRASS-6.4.2 back port or continue testing with winGRASS-6.5.

As a final goal we would like to use GRASS-6.4.2 in Japanese environment for our training materials.

in reply to:  18 comment:20 by martinl, 11 years ago

Replying to naokiueda:

I tested with r49105 that should contain r49091.
I still got "ExpatError" "unknown encoding: line 1, column 30".

When I download r49105, the Python scripts (menuform.py, task.py) does not contain changes of 49064, 49086 , or 49091. So I ported chages by referencing diffs, and test it.
Result is still same.

Do you mean GRASS 6.5?

in reply to:  19 ; comment:21 by martinl, 11 years ago

Replying to Venkat:

Will these changes in winGRASS r49125-1 to support multi-byte encoding back-ported to GRASS-6.4.2? We would like to continue with testing wxGUI in winGRASS, should be wait for the GRASS-6.4.2 back port or continue testing with winGRASS-6.5.

done in r49141. Try out the next daily build from http://wingrass.fsv.cvut.cz/grass64/ or grass64-dev package from OSGeo4W.

in reply to:  21 comment:22 by martinl, 11 years ago

Replying to martinl:

done in r49141. Try out the next daily build from http://wingrass.fsv.cvut.cz/grass64/ or grass64-dev package from OSGeo4W.

Please could you confirm that it's also fixed for G64? Thanks. Martin

comment:23 by venkat, 11 years ago

Tested with WinGRASS-6.4.SVN-r49145-1. d,rast, r,in.gdal, save workspace in wxGUI seem to be working fine. Will do further test wxGUI.

Sorry for the delay in reporting the test results. Many thanks for unstinting support from Martin L and Markus N.

in reply to:  23 comment:24 by martinl, 11 years ago

Resolution: fixed
Status: assignedclosed

Replying to venkat:

Tested with WinGRASS-6.4.SVN-r49145-1. d,rast, r,in.gdal, save workspace in wxGUI seem to be working fine. Will do further test wxGUI.

Good news, I am closing the tickets. Feel free to re-open if needed.

Sorry for the delay in reporting the test results. Many thanks for unstinting support from Martin L and Markus N.

You are welcome:-) Martin

Note: See TracTickets for help on using tickets.