Opened 14 years ago

Closed 14 years ago

#1137 closed defect (fixed)

wxGUI doesn't work in Windows

Reported by: glynn Owned by: grass-dev@…
Priority: blocker Milestone: 6.4.0
Component: wxGUI Version: unspecified
Keywords: Cc:
CPU: All Platform: MSWindows XP

Description

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.

Change History (8)

comment:1 by neteler, 14 years ago

See also #1015 and #1017

in reply to:  1 comment:2 by glynn, 14 years ago

Replying to 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).

in reply to:  description ; comment:3 by martinl, 14 years ago

Replying to glynn:

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

is r43266 sufficient fix?

in reply to:  3 ; comment:4 by glynn, 14 years ago

Replying to martinl:

is r43266 sufficient fix?

I think so.

in reply to:  4 ; comment:5 by martinl, 14 years ago

Replying to glynn:

Replying to 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.

in reply to:  5 ; comment:6 by hellik, 14 years ago

Replying to martinl:

Replying to glynn:

Replying to 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'

in reply to:  6 ; comment:7 by martinl, 14 years ago

Replying to hellik:

Replying to martinl:

Replying to glynn:

Replying to 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: 

in reply to:  7 comment:8 by martinl, 14 years ago

Resolution: fixed
Status: newclosed

Replying to 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

Note: See TracTickets for help on using tickets.