[GRASS-dev] Re: [GRASS GIS] #1485: Cannot save workspace from wxGUI

GRASS GIS trac at osgeo.org
Tue Nov 1 00:31:02 EDT 2011


#1485: Cannot save workspace from wxGUI
-------------------------+--------------------------------------------------
 Reporter:  venkat       |       Owner:  grass-dev@…              
     Type:  defect       |      Status:  new                      
 Priority:  blocker      |   Milestone:  6.4.2                    
Component:  wxGUI        |     Version:  6.4.2 RCs                
 Keywords:  wingrass     |    Platform:  MSWindows 7              
      Cpu:  Unspecified  |  
-------------------------+--------------------------------------------------

Comment(by 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.

 [[BR]]
 There are comment-out in etc/wxpython/gui_modules/menuform.py, line 2016 -
 2019[[BR]]
 [[BR]]
 2011    def ParseInterface(self, cmd, parser = processTask):[[BR]]
 2012        """!Parse interface[[BR]]
 2013[[BR]]
 2014        @param cmd command to be parsed (given as list)[[BR]]
 2015        """[[BR]]
 2016        # enc = locale.getdefaultlocale()[1][[BR]]
 2017        # if enc and enc.lower() not in ("utf8", "utf-8"):[[BR]]
 2018        #     tree =
 etree.fromstring(getInterfaceDescription(cmd[0]).decode(enc).encode("utf-8"))[[BR]]
 2019        # else:[[BR]]
 2020        tree = etree.fromstring(getInterfaceDescription(cmd[0]))[[BR]]
 2021[[BR]]
 2022        return processTask(tree).GetTask()[[BR]]
 [[BR]]
 Enabling these line by removing comment-out, will fix this problem in
 6.4.1.[[BR]]
 [[BR]]
 [[BR]]
 Also, there need to be two more fix.[[BR]]
 [[BR]]
 in menuform.py, near line 2132[[BR]]
 [[BR]]
 2132    def GetCommandInputMapParamKey(self, cmd):[[BR]]
 2133        """!Get parameter key for input raster/vector map[[BR]]
 2134[[BR]]
 2135        @param cmd module name[[BR]]
 2136[[BR]]
 2137        @return parameter key[[BR]]
 2138        @return None on failure[[BR]]
 2139        """[[BR]]
 2140        # parse the interface decription[[BR]]
 2141        if not self.grass_task:[[BR]]
 2142            tree =
 etree.fromstring(getInterfaceDescription(cmd))[[BR]]
 2143            self.grass_task = processTask(tree).GetTask()[[BR]]
 2144[[BR]]
 2145            for p in self.grass_task.params:[[BR]]
 2146                if p.get('name', '') in ('input', 'map'):[[BR]]
 2147                    age = p.get('age', '')[[BR]]
 2148                    prompt = p.get('prompt', '')[[BR]]
 2149                    element = p.get('element', '')[[BR]]
 2150                    if age ==  'old' and[[BR]]
 2151                            element in ('cell', 'grid3', 'vector')
 and[[BR]]
 2152                            prompt in ('raster', '3d-raster',
 'vector'):[[BR]]
 2153                        return p.get('name', None)[[BR]]
 2154        return None[[BR]]
 [[BR]]
 change as follows[[BR]]
 [[BR]]
 Before:[[BR]]
 2141        if not self.grass_task:[[BR]]
 2142            tree =
 etree.fromstring(getInterfaceDescription(cmd))[[BR]]
 2143            self.grass_task = processTask(tree).GetTask()[[BR]]
 [[BR]]
 After Fix:[[BR]]
 2141        if not self.grass_task:[[BR]]
 2142            enc = locale.getdefaultlocale()[1][[BR]]
 2143            if enc and enc.lower() not in ("utf8″, “utf-8″):[[BR]]
 2144                p = re.compile(enc, re.IGNORECASE)[[BR]]
 2145                tree = etree.fromstring(p.sub(’utf-8′,
 getInterfaceDescription(cmd)).decode(enc).encode("utf-8″))[[BR]]
 2146            else:[[BR]]
 2147                tree =
 etree.fromstring(getInterfaceDescription(cmd))[[BR]]
 [[BR]]
 [[BR]]
 [[BR]]
 [[BR]]
 Also in menuform.py line 1957[[BR]]
 [[BR]]
 1957 def getInterfaceDescription(cmd):[[BR]]
 1958     """!Returns the XML description for the GRASS cmd.[[BR]]
 1959[[BR]]
 1960     The DTD must be located in $GISBASE/etc/grass-
 interface.dtd,[[BR]]
 1961     otherwise the parser will not succeed.[[BR]]
 1962[[BR]]
 1963     @param cmd command (name of GRASS module)[[BR]]
 1964     """[[BR]]
 1965     try:[[BR]]
 1966         cmdout, cmderr = grass.Popen([cmd, '--interface-
 description'], stdout = grass.PIPE,[[BR]]
 1967                                      stderr =
 grass.PIPE).communicate()[[BR]]
 1968     except OSError, e:[[BR]]
 1969         raise gcmd.GException, _("Unable to fetch interface
 description for command '%s'. "[[BR]]
 1970                                  "Details: %s") % (cmd,
 e.value)[[BR]]
 1971     if cmderr and cmderr[:7] != 'WARNING':[[BR]]
 1972         raise gcmd.GException, _("Unable to fetch interface
 description for command '%s'. "[[BR]]
 1973                                  "Details: %s") % (cmd, cmderr)[[BR]]
 1974[[BR]]
 1975     return cmdout.replace('grass-interface.dtd',
 os.path.join(globalvar.ETCDIR, 'grass-interface.dtd'))[[BR]]
 [[BR]]
 [[BR]]
 Before:[[BR]]
 1971     if cmderr and cmderr[:7] != 'WARNING':[[BR]]
 [[BR]]
 After Fix:[[BR]]
 1971     if cmderr and cmderr[12:19] != 'WARNING':[[BR]]
 [[BR]]
 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".[[BR]]
 [[BR]]
 [[BR]]
 There three fixes above solve issue in 6.4.2 (in multi-byte
 environmrnt).[[BR]]

-- 
Ticket URL: <http://trac.osgeo.org/grass/ticket/1485#comment:9>
GRASS GIS <http://grass.osgeo.org>



More information about the grass-dev mailing list