[GRASS-dev] [GRASS GIS] #945: wxGUI: g.setproj fails on wingrass

#945: wxGUI: g.setproj fails on wingrass
---------------------------------+------------------------------------------
Reporter: hamish | Owner: grass-dev@lists.osgeo.org
     Type: defect | Status: new
Priority: major | Milestone: 6.4.0
Component: wxGUI | Version: svn-releasebranch64
Keywords: g.setproj, wingrass | Platform: MSWindows XP
      Cpu: x86-32 |
---------------------------------+------------------------------------------
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

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

#945: wxGUI: g.setproj fails on wingrass
---------------------------+------------------------------------------------
  Reporter: hamish | Owner: grass-dev@lists.osgeo.org
      Type: defect | Status: new
  Priority: major | Milestone: 6.4.0
Component: wxGUI | Version: svn-releasebranch64
Resolution: | Keywords: g.setproj, wingrass
  Platform: MSWindows XP | Cpu: x86-32
---------------------------+------------------------------------------------
Comment (by hamish):

or if we were feeling lazy we could just hardcode
{{{
  if command[0] == 'g.setproj':
     need_xmon=False;
}}}

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

#945: wxGUI: g.setproj fails on wingrass
---------------------------+------------------------------------------------
  Reporter: hamish | Owner: martinl
      Type: defect | Status: assigned
  Priority: major | Milestone: 6.4.0
Component: wxGUI | Version: svn-releasebranch64
Resolution: | Keywords: g.setproj, wingrass
  Platform: MSWindows XP | Cpu: x86-32
---------------------------+------------------------------------------------
Changes (by martinl):

* cc: grass-dev@lists.osgeo.org (added)
  * owner: grass-dev@lists.osgeo.org => martinl
  * status: new => assigned

Comment:

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

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

#945: wxGUI: g.setproj fails on wingrass
---------------------------+------------------------------------------------
  Reporter: hamish | Owner: martinl
      Type: defect | Status: assigned
  Priority: major | Milestone: 6.4.0
Component: wxGUI | Version: svn-releasebranch64
Resolution: | Keywords: g.setproj, wingrass
  Platform: MSWindows XP | Cpu: x86-32
---------------------------+------------------------------------------------
Comment (by 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\"".
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

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

#945: wxGUI: g.setproj fails on wingrass
---------------------------+------------------------------------------------
  Reporter: hamish | Owner: martinl
      Type: defect | Status: assigned
  Priority: major | Milestone: 6.4.0
Component: wxGUI | Version: svn-releasebranch64
Resolution: | Keywords: g.setproj, wingrass
  Platform: MSWindows XP | Cpu: x86-32
---------------------------+------------------------------------------------
Comment (by glynn):

Replying to [comment:3 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().

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

#945: wxGUI: g.setproj fails on wingrass
---------------------------+------------------------------------------------
  Reporter: hamish | Owner: martinl
      Type: defect | Status: assigned
  Priority: major | Milestone: 6.4.0
Component: wxGUI | Version: svn-releasebranch64
Resolution: | Keywords: g.setproj, wingrass
  Platform: MSWindows XP | Cpu: x86-32
---------------------------+------------------------------------------------
Comment (by hamish):

Replying to [comment:4 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

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

#945: wxGUI: g.setproj fails on wingrass
---------------------------+------------------------------------------------
  Reporter: hamish | Owner: martinl
      Type: defect | Status: assigned
  Priority: major | Milestone: 6.4.0
Component: wxGUI | Version: svn-releasebranch64
Resolution: | Keywords: g.setproj, wingrass
  Platform: MSWindows XP | Cpu: x86-32
---------------------------+------------------------------------------------
Comment (by hamish):

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

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

#945: wxGUI: g.setproj fails on wingrass
---------------------------+------------------------------------------------
  Reporter: hamish | Owner: martinl
      Type: defect | Status: assigned
  Priority: major | Milestone: 6.4.0
Component: wxGUI | Version: svn-releasebranch64
Resolution: | Keywords: g.setproj, wingrass
  Platform: MSWindows XP | Cpu: x86-32
---------------------------+------------------------------------------------
Comment (by hamish):

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

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

#945: wxGUI: g.setproj fails on wingrass
---------------------------+------------------------------------------------
  Reporter: hamish | Owner: martinl
      Type: defect | Status: assigned
  Priority: major | Milestone: 6.4.0
Component: wxGUI | Version: svn-releasebranch64
Resolution: | Keywords: g.setproj, wingrass
  Platform: MSWindows XP | Cpu: x86-32
---------------------------+------------------------------------------------
Comment (by glynn):

Replying to [comment:7 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.

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

#945: wxGUI: g.setproj fails on wingrass
---------------------------------+------------------------------------------
Reporter: hamish | Owner: martinl
     Type: defect | Status: assigned
Priority: minor | Milestone: 6.4.0
Component: wxGUI | Version: svn-releasebranch64
Keywords: g.setproj, wingrass | Platform: MSWindows XP
      Cpu: x86-32 |
---------------------------------+------------------------------------------
Changes (by hamish):

  * priority: major => minor

Comment:

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

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

#945: wxGUI: g.setproj fails on wingrass
---------------------------------+------------------------------------------
Reporter: hamish | Owner: martinl
     Type: defect | Status: assigned
Priority: minor | Milestone: 6.4.2
Component: wxGUI | Version: svn-releasebranch64
Keywords: g.setproj, wingrass | Platform: MSWindows XP
      Cpu: x86-32 |
---------------------------------+------------------------------------------
Changes (by hellik):

  * milestone: 6.4.0 => 6.4.2

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

#945: wxGUI: g.setproj fails on wingrass
---------------------------------+------------------------------------------
Reporter: hamish | Owner: grass-dev@…
     Type: defect | Status: new
Priority: minor | Milestone: 6.4.2
Component: wxGUI | Version: svn-releasebranch64
Keywords: g.setproj, wingrass | Platform: MSWindows XP
      Cpu: x86-32 |
---------------------------------+------------------------------------------
Changes (by martinl):

* cc: grass-dev@… (removed)
  * owner: martinl => grass-dev@…
  * status: assigned => new

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

#945: wxGUI: g.setproj fails on wingrass
---------------------------------+------------------------------------------
Reporter: hamish | Owner: grass-dev@…
     Type: defect | Status: new
Priority: major | Milestone: 6.5.0
Component: wxGUI | Version: svn-develbranch6
Keywords: g.setproj, wingrass | Platform: MSWindows XP
      Cpu: x86-32 |
---------------------------------+------------------------------------------
Changes (by hamish):

  * priority: minor => major
  * version: svn-releasebranch64 => svn-develbranch6
  * milestone: 6.4.2 => 6.5.0

Comment:

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

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

#945: wxGUI: g.setproj fails on wingrass
---------------------------------+------------------------------------------
Reporter: hamish | Owner: grass-dev@…
     Type: defect | Status: new
Priority: major | Milestone: 6.4.4
Component: wxGUI | Version: svn-releasebranch64
Keywords: g.setproj, wingrass | Platform: MSWindows XP
      Cpu: x86-32 |
---------------------------------+------------------------------------------
Changes (by neteler):

  * version: svn-develbranch6 => svn-releasebranch64
  * milestone: 6.5.0 => 6.4.4

Comment:

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"?

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

#945: wxGUI: g.setproj fails on wingrass
---------------------------------+------------------------------------------
Reporter: hamish | Owner: grass-dev@…
     Type: defect | Status: new
Priority: major | Milestone: 6.4.4
Component: wxGUI | Version: svn-releasebranch64
Keywords: g.setproj, wingrass | Platform: MSWindows XP
      Cpu: x86-32 |
---------------------------------+------------------------------------------

Comment(by hamish):

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

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

#945: wxGUI: g.setproj fails
-----------------------+----------------------------------------------------
Reporter: hamish | Owner: grass-dev@…
     Type: defect | Status: new
Priority: critical | Milestone: 6.4.4
Component: wxGUI | Version: svn-releasebranch64
Keywords: g.setproj | Platform: All
      Cpu: All |
-----------------------+----------------------------------------------------
Changes (by hamish):

  * keywords: g.setproj, wingrass => g.setproj
  * platform: MSWindows XP => All
  * cpu: x86-32 => All
  * priority: major => critical

Comment:

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

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

#945: wxGUI: g.setproj fails
-----------------------+----------------------------------------------------
Reporter: hamish | Owner: grass-dev@…
     Type: defect | Status: new
Priority: critical | Milestone: 6.4.3
Component: wxGUI | Version: svn-releasebranch64
Keywords: g.setproj | Platform: All
      Cpu: All |
-----------------------+----------------------------------------------------
Changes (by hamish):

  * milestone: 6.4.4 => 6.4.3

Comment:

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

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

#945: wxGUI: g.setproj fails
-----------------------+----------------------------------------------------
Reporter: hamish | Owner: grass-dev@…
     Type: defect | Status: new
Priority: major | Milestone: 6.4.4
Component: wxGUI | Version: svn-releasebranch64
Keywords: g.setproj | Platform: All
      Cpu: All |
-----------------------+----------------------------------------------------
Changes (by hamish):

  * priority: critical => major
  * milestone: 6.4.3 => 6.4.4

Comment:

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

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