[GRASS-dev] [GRASS GIS] #1137: wxGUI doesn't work in Windows

#1137: wxGUI doesn't work in Windows
---------------------+------------------------------------------------------
Reporter: glynn | Owner: grass-dev@…
     Type: defect | Status: new
Priority: blocker | Milestone: 6.4.0
Component: wxGUI | Version: unspecified
Keywords: | Platform: MSWindows XP
      Cpu: All |
---------------------+------------------------------------------------------
In menuform.py, getInterfaceDescription() attempts to insert the full path
to grass-interface.dtd in the --interface-description output, using:
{{{
     p = re.compile('(grass-interface.dtd)')
     p.search(cmdout)
     cmdout = p.sub(globalvar.ETCDIR + r'/grass-interface.dtd', cmdout)
}}}

But the first argument to the !RegexObject.sub() method is a replacement
'''pattern''', not a literal string, meaning that certain backslash
sequences have special meaning.

This is problematic if globalvar.ETCDIR contains a recognised backslash
sequence, which is quite likely on Windows. In particular, \g is used to
insert the contents of a named or numbered group, and ETCDIR will almost
certainly contain this sequence as part of "\grass-". This results in the
error:
{{{
   File "C:\msys\1.0\home\glynn\src\grass-7.0\dist.i686-pc-
mingw32\etc\gui\wxpython\gui_modules\menuform.py", line 1997, in
getInterfaceDescription
     cmdout = p.sub(globalvar.ETCDIR + r'/grass-interface.dtd', cmdout)
   File "C:\Program Files\Python26\lib\re.py", line 273, in _subx
     template = _compile_repl(template, pattern)
   File "C:\Program Files\Python26\lib\re.py", line 260, in _compile_repl
     raise error, v # invalid expression
sre_constants.error: bad group name
}}}

Also, even without the error, the "\1" in "\1.0" would end up being
replaced by the first parenthesised group (grass-interface.dtd).

As the pattern is a literal string, I don't see any reason to use regular
expression. It may as well just use e.g.:
{{{
cmdout.replace('grass-interface.dtd', os.path.join(globalvar.ETCDIR,
'grass-interface.dtd'))
}}}
which also fixes the use of the wrong directory separator.

Also, if the DTD is supposed to be specified by a full path, the
implementation of --interface-description should be fixed, rather than
patching the output afterwards.

Priority set to "blocker" as this can make the wxGUI effectively non-
functional. Executing any command will trigger the error if $GISBASE
contains the wrong characters (this may be specific to Python 2.6; I can't
see any other reason why it wouldn't have been noticed earlier).

Platform set to "MSWindows" (applies to all versions) as backslashes in
pathnames are uncommon on other platforms (although technically
permitted).

Tested with the latest 7.0, but the code is identical in 6.x.

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

#1137: wxGUI doesn't work in Windows
---------------------+------------------------------------------------------
Reporter: glynn | Owner: grass-dev@…
     Type: defect | Status: new
Priority: blocker | Milestone: 6.4.0
Component: wxGUI | Version: unspecified
Keywords: | Platform: MSWindows XP
      Cpu: All |
---------------------+------------------------------------------------------

Comment(by neteler):

See also #1015 and #1017

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

On Wed, Aug 25, 2010 at 1:54 PM, GRASS GIS <trac@osgeo.org> wrote:

#1137: wxGUI doesn't work in Windows
---------------------+------------------------------------------------------
Reporter: glynn | Owner: grass-dev@…
Type: defect | Status: new
Priority: blocker | Milestone: 6.4.0
Component: wxGUI | Version: unspecified
Keywords: | Platform: MSWindows XP
Cpu: All |

Since this is tagged as blocker, no RC7 today?

Markus

#1137: wxGUI doesn't work in Windows
---------------------+------------------------------------------------------
Reporter: glynn | Owner: grass-dev@…
     Type: defect | Status: new
Priority: blocker | Milestone: 6.4.0
Component: wxGUI | Version: unspecified
Keywords: | Platform: MSWindows XP
      Cpu: All |
---------------------+------------------------------------------------------

Comment(by glynn):

Replying to [comment:1 neteler]:
> See also #1015 and #1017

So it also happens with Python 2.5. I'm at a loss to explain why this
wasn't caught earlier. The issue is present in the very first version of
menuform.py (r28481, which is nearly 5 years ago).

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

#1137: wxGUI doesn't work in Windows
---------------------+------------------------------------------------------
Reporter: glynn | Owner: grass-dev@…
     Type: defect | Status: new
Priority: blocker | Milestone: 6.4.0
Component: wxGUI | Version: unspecified
Keywords: | Platform: MSWindows XP
      Cpu: All |
---------------------+------------------------------------------------------

Comment(by martinl):

Replying to [ticket:1137 glynn]:

{{{
> cmdout.replace('grass-interface.dtd', os.path.join(globalvar.ETCDIR,
'grass-interface.dtd'))
}}}

is r43266 sufficient fix?

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

#1137: wxGUI doesn't work in Windows
---------------------+------------------------------------------------------
Reporter: glynn | Owner: grass-dev@…
     Type: defect | Status: new
Priority: blocker | Milestone: 6.4.0
Component: wxGUI | Version: unspecified
Keywords: | Platform: MSWindows XP
      Cpu: All |
---------------------+------------------------------------------------------

Comment(by glynn):

Replying to [comment:3 martinl]:

> is r43266 sufficient fix?

I think so.

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

#1137: wxGUI doesn't work in Windows
---------------------+------------------------------------------------------
Reporter: glynn | Owner: grass-dev@…
     Type: defect | Status: new
Priority: blocker | Milestone: 6.4.0
Component: wxGUI | Version: unspecified
Keywords: | Platform: MSWindows XP
      Cpu: All |
---------------------+------------------------------------------------------

Comment(by martinl):

Replying to [comment:4 glynn]:
> Replying to [comment:3 martinl]:
>
> > is r43266 sufficient fix?
>
> I think so.

backported to devbr6 (r43274) and relbr64 (r43275). WinGrass packages will
be available at http://josef.fsv.cvut.cz/wingrass/grass64/ within one
hour, please test.

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

#1137: wxGUI doesn't work in Windows
---------------------+------------------------------------------------------
Reporter: glynn | Owner: grass-dev@…
     Type: defect | Status: new
Priority: blocker | Milestone: 6.4.0
Component: wxGUI | Version: unspecified
Keywords: | Platform: MSWindows XP
      Cpu: All |
---------------------+------------------------------------------------------

Comment(by hellik):

Replying to [comment:5 martinl]:
> Replying to [comment:4 glynn]:
> > Replying to [comment:3 martinl]:
> >
> > > is r43266 sufficient fix?
> >
> > I think so.
>
> backported to devbr6 (r43274) and relbr64 (r43275). WinGrass packages
will be available at http://josef.fsv.cvut.cz/wingrass/grass64/ within one
hour, please test.

I've tried r43283

{{{
syringia@NADA /c/osgeo4w/usr/src/grass_trunk/bin.i686-pc-mingw32
$ grass70

syringia@NADA /c/osgeo4w/usr/src/grass_trunk/bin.i686-pc-mingw32
$ Cleaning up temporary files...
Starting GRASS GIS...
WARNUNG: Attention!
WARNUNG: Locking is not supported on Windows!

           __________ ___ __________ _______________
          / ____/ __ \/ | / ___/ ___/ / ____/ _/ ___/
         / / __/ /_/ / /| | \__ \\_ \ / / __ / / \__ \
        / /_/ / _, _/ ___ |___/ /__/ / / /_/ // / ___/ /
        \____/_/ |_/_/ |_/____/____/ \____/___//____/

Welcome to GRASS 7.0.svn (2010)

GRASS homepage: http://grass.osgeo.org
This version running through: shell
(C:\windows\system32\cmd.exe)
Help is available with the command: g.manual -i
See the licence terms with: g.version -c
If required, restart the GUI with: g.gui wxpython
When ready to quit enter: exit

Microsoft Windows [Version 6.0.6002]
Copyright (c) 2006 Microsoft Corporation. Alle Rechte vorbehalten.

c:\osgeo4w\usr\src\grass_trunk\bin.i686-pc-mingw32>Cleaning up temporary
files...
Done.

Goodbye from GRASS GIS

Traceback (most recent call last):
   File "c:\osgeo4w\usr\src\grass_trunk\dist.i686-pc-
mingw32\etc\gui\wxpython\wxgui.py", line 64, in <module>
     import gui_modules.preferences as preferences
   File "c:/osgeo4w/usr/src/grass_trunk/dist.i686-pc-
mingw32/etc/gui/wxpython/gui_modules/preferences.py", line 909, in
<module>
     globalSettings = Settings()
   File "c:/osgeo4w/usr/src/grass_trunk/dist.i686-pc-
mingw32/etc/gui/wxpython/gui_modules/preferences.py", line 591, in
__init__
     self.ReadSettingsFile()
   File "c:/osgeo4w/usr/src/grass_trunk/dist.i686-pc-
mingw32/etc/gui/wxpython/gui_modules/preferences.py", line 653, in
ReadSettingsFile
     gisdbase = gisenv['GISDBASE']
KeyError: 'GISDBASE'
}}}

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

#1137: wxGUI doesn't work in Windows
---------------------+------------------------------------------------------
Reporter: glynn | Owner: grass-dev@…
     Type: defect | Status: new
Priority: blocker | Milestone: 6.4.0
Component: wxGUI | Version: unspecified
Keywords: | Platform: MSWindows XP
      Cpu: All |
---------------------+------------------------------------------------------

Comment(by martinl):

Replying to [comment:6 hellik]:
> Replying to [comment:5 martinl]:
> > Replying to [comment:4 glynn]:
> > > Replying to [comment:3 martinl]:
> > >
> > > > is r43266 sufficient fix?
> > >
> > > I think so.
> >
> > backported to devbr6 (r43274) and relbr64 (r43275). WinGrass packages
will be available at http://josef.fsv.cvut.cz/wingrass/grass64/ within one
hour, please test.
>
> I've tried r43283

It wasn't indented to fix grass.py script. The original report

{{{
This is problematic if globalvar.ETCDIR contains a recognised backslash
sequence, which is quite likely on Windows. In particular, \g is used to
insert the contents of a named or numbered group, and ETCDIR will almost
certainly contain this sequence as part of "\grass-". This results in the
error:
}}}

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

#1137: wxGUI doesn't work in Windows
---------------------------+------------------------------------------------
  Reporter: glynn | Owner: grass-dev@…
      Type: defect | Status: closed
  Priority: blocker | Milestone: 6.4.0
Component: wxGUI | Version: unspecified
Resolution: fixed | Keywords:
  Platform: MSWindows XP | Cpu: All
---------------------------+------------------------------------------------
Changes (by martinl):

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

Comment:

Replying to [comment:7 martinl]:

{{{
> This is problematic if globalvar.ETCDIR contains a recognised backslash
> sequence, which is quite likely on Windows. In particular, \g is used to
> insert the contents of a named or numbered group, and ETCDIR will almost
> certainly contain this sequence as part of "\grass-". This results in
the error:
}}}

I am closing this ticket, please reopen if needed. Martin

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