Opened 15 years ago

Last modified 9 years ago

#945 new defect

wxGUI: g.setproj fails

Reported by: hamish Owned by: grass-dev@…
Priority: major Milestone: 6.4.6
Component: wxGUI Version: svn-releasebranch64
Keywords: g.setproj Cc:
CPU: All Platform: All

Description

Hi,

(moved here from #693)

g.setproj fails on wxGUI wingrass 6.4.0.

the error is

Traceback (...):
 File "c:/Program Files/GRASS-64-SVN/etc/wxpython/wxgui.py", line 991, in OnXterm


xmon = xmonlist[0]
IndexError
:
list index out of range

the main problem here is that g.setproj wants a terminal but it doesn't need a Xmon. So the menuform.xml hander should be changed to something new.

Currently OnXterm has a function parameter of NeedXmon = True/False (or something like that) which defaults to True. If we could figure out how to pass that option = False as part of the XML menu tree it would solve it.

Alternatively we could split out a new handler function, but it would mostly be duplication and only used for g.setproj.

Hamish

Change History (18)

comment:1 by hamish, 15 years ago

or if we were feeling lazy we could just hardcode

 if command[0] == 'g.setproj':
    need_xmon=False;

comment:2 by martinl, 15 years ago

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

Hopefully fixed in r41041 (relbr64) and r41043 (devbr6).

comment:3 by hamish, 15 years ago

with the 6.4 nightly wingrass binary r41114 wxGUI, I get this error popup when I try to start g.setproj from the Config->Manage projections menu:

__ \"c:/Program Files/GRASS-64-SVN\etc\grass-run.bat\" __

Windows cannot find "\"c:Program Files/GRASS-64-SVN\etc\grass-run.bat\"".
Make sure you typed the name correctly, and then try again.
To search for a file, click the Start button, and then click
Search.

[Ok]

from the MSys terminal prompt I correctly get the "You must be in the PERMANENT mapset to run this" error message; from the wxGUI Cmd> prompt I get the popup module auto-GUI but nothing at all happens when I click [Run].

from the GIS.m tcl gui it flashes open a DOS box with the "you must be in PERMANENT.." error and a beep, and then after 250ms the dosbox closes again. You just have time to read the error message.

Hamish

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

Replying to hamish:

with the 6.4 nightly wingrass binary r41114 wxGUI, I get this error popup when I try to start g.setproj from the Config->Manage projections menu:

__ \"c:/Program Files/GRASS-64-SVN\etc\grass-run.bat\" __

Windows cannot find "\"c:Program Files/GRASS-64-SVN\etc\grass-run.bat\"".

IOW, OnXTerm() is still as broken as it always was. In particular, I note:

            cmdlist = ["cmd.exe", "/c", 'start "%s"' % runbat, command]

Try using:

            cmdlist = ["start", runbat, command]

then running the command with shell=True (if this isn't already set, which it should be).

Also try not using gcmd.Command(). It appears to be intended to run GRASS commands, and neither cmd.exe nor start are GRASS commands. It's also insanely hard to figure out what's going on once you get into gcmd.Command().

in reply to:  4 comment:5 by hamish, 15 years ago

Replying to glynn:

Try using:

            cmdlist = ["start", runbat, command]
  cmdlist = ["start", runbat, runbat, command]

does the trick.

AFAICT g.setproj is going to be the only thing using OnXTerm from the wxGUI on WinGrass, so the only thing that will ever use that line of code.

thanks, Hamish

comment:6 by hamish, 15 years ago

"start, runbat, runbat, command" applied in 6.4 and 6.5 svn.

comment:7 by hamish, 15 years ago

tested, works in 6.4.0nightly wingrass wxGUI.

one annoyance is that $GRASS_PAGER is set to be less instead of more. more seems to be a DOS built-in function, so msys startup/prompt can't detect/use it.

The nice thing about more is that you don't need to know how to use it, you just smash the keyboard until it goes away. For less you do need to know to use the q key to get out (easy once you know, not if you don't).

another is that OnXTerm should unset the GRASS_MESSAGE_FORMAT enviro var to avoid printing GRASS_INFO_WARNING(), GRASS_INFO_END() etc. to the terminal.

# unset
del os.environ['GRASS_MESSAGE_FORMAT']
...
# reset
os.environ['GRASS_MESSAGE_FORMAT'] = 'gui'

? (python doesn't like it)

Hamish

in reply to:  7 comment:8 by glynn, 15 years ago

Replying to hamish:

another is that OnXTerm should unset the GRASS_MESSAGE_FORMAT enviro var to avoid printing GRASS_INFO_WARNING(), GRASS_INFO_END() etc. to the terminal.

# unset
del os.environ['GRASS_MESSAGE_FORMAT']
...
# reset
os.environ['GRASS_MESSAGE_FORMAT'] = 'gui'

Apart from at startup, the wxGUI should just leave os.environ alone. If a child process needs a modified environment, pass it one via the env= parameter to subprocess.Popen(), e.g.:

   tmpenv = os.environ.copy()
   tmpenv['GRASS_MESSAGE_FORMAT'] = 'gui'
   p = grass.Popen(..., env = tmpenv)

If gcmd.Command doesn't support env=, it needs to be fixed.

comment:9 by hamish, 14 years ago

Priority: majorminor

status:

  • original bug is fixed, g.setproj now works.
  • The $GRASS_PAGER used is less, but Windows users won't have a clue how to use that. Suggest to set it to more in the startup script (see comment:7)
  • GRASS_MESSAGE_FORMAT ugliness remains, see previous two comments in this ticket for a possible solution.

Hamish

comment:10 by hellik, 14 years ago

Milestone: 6.4.06.4.2

comment:11 by martinl, 13 years ago

Cc: grass-dev@… removed
Owner: changed from martinl to grass-dev@…
Status: assignednew

comment:12 by hamish, 13 years ago

Milestone: 6.4.26.5.0
Priority: minormajor
Version: svn-releasebranch64svn-develbranch6

Hi, (reusing this ticket as it's still open)

all OnXTerm and OnXTermNoXMon menu items are failing on 6.5svn wingrass. In 6.4.2svn they are ok. e.g. for g.setproj from the Settings menu:

Traceback:
  File .../lmgr/frame.py line 1122, in OnXTermNoXMon
self.OnXTerm(event, need_xmon = false)
  File .../lmgr/frame.py line 1172, in OnXTerm

p = Command(cmdlist, wait=False)
NameError
:
global name 'Command' is not defined

see also outstanding issues in comment:9 (the most important of which is that GRASS_PAGER on wingrass should be set to use more not less, as all you need to know to use that program is if you smash the keyboard enough times you can get it to go away)

Hamish

comment:13 by neteler, 12 years ago

Milestone: 6.5.06.4.4
Version: svn-develbranch6svn-releasebranch64

Still broken in current winGRASS 6.4 (r55719):

wxGUI menu -> Settings -> Map projection -> g.setproj:

Traceback (most recent call last):
  File "C:\Program Files (x86)\GRASS GIS
6.4.3svn\etc\wxpython\lmgr\frame.py", line 1186, in
OnXTermNoXMon

self.OnXTerm(event, need_xmon = False)
  File "C:\Program Files (x86)\GRASS GIS
6.4.3svn\etc\wxpython\lmgr\frame.py", line 1236, in OnXTerm

p = Command(cmdlist, wait=False)
NameError
:
global name 'Command' is not defined

Perhaps trap this when platform == windows and pop up an error "Unsupported on Windows, use blabla... instead"?

comment:14 by hamish, 12 years ago

see comment:9 and comment:12.

In 6.4.2svn it *was* working, but something in the GUI got backported which then broke it. We should be able to fix this, I'm pretty sure it's not a fundamental problem, just a fiddly one.

note g.setproj is still the only way to access creating US State FIPS code locations by county, and it's nice to have the fall-back since +proj codes do not cover all possibilities that GRASS supports AFAIK. The wxPy loc'n wizard is absolutely wonderful, best I've used, but there's still another 2% to go before it's universal.

Hamish

comment:15 by hamish, 11 years ago

CPU: x86-32All
Keywords: wingrass removed
Platform: MSWindows XPAll
Priority: majorcritical
Summary: wxGUI: g.setproj fails on wingrasswxGUI: g.setproj fails

It's not just WinGrass, it happens on Linux too.

r.digit and r.le.setup also fail in the same way.

This is a regression from 6.4.2, where it was working.

Hamish

comment:16 by hamish, 11 years ago

Milestone: 6.4.46.4.3

OnXTerm 'Command' error fixed in relbr64 and devbr6 with r56738,40.

more set to be the default pager in wingrass in r56741 (devbr6). works within g.setproj run from the msys command line or wxGUI, but not from the msys command line directly (fails gracefully, cat-like).

Hamish

comment:17 by hamish, 11 years ago

Milestone: 6.4.36.4.4
Priority: criticalmajor

re. the pager problem, actually it wasn't failing gracefully, it was #ifdef'd out for wingrass. #ifdef removed, tested the pager with g.list and g.setproj in devbr6 and it works now with the isatty()-able cmd.exe window. backported to 6.4svn in r56780.

r.digit and g.setproj now start ok from the wxGUI menu, with and without Xmons.


Final issue to resolve before closing this bug:

  • GRASS_MESSAGE_FORMAT ugliness remains, see comment:7 and comment:8 in this ticket for a possible solution.

that's not critical, so bumping it down the road to 6.4.4 ...

Hamish

comment:18 by neteler, 9 years ago

Milestone: 6.4.46.4.6
Note: See TracTickets for help on using tickets.