[GRASS-dev] [GRASS GIS] #3867: menudata.py: global name 'error_handler' is not defined

#3867: menudata.py: global name 'error_handler' is not defined
-------------------------+-------------------------
Reporter: marisn | Owner: wenzeslaus
     Type: defect | Status: assigned
Priority: normal | Milestone:
Component: wxGUI | Version: svn-trunk
Keywords: | CPU: Unspecified
Platform: Unspecified |
-------------------------+-------------------------
Some imports missing? Tested with f79c3568d69f2d706b9c9383a0a3e188d2137b0b

{{{
File "/home/maris/soft/grass-main/dist.x86_64-pc-linux-
gnu/gui/wxpython/wxgui.py", line 172, in <module>
     sys.exit(main())
   File "/home/maris/soft/grass-main/dist.x86_64-pc-linux-
gnu/gui/wxpython/wxgui.py", line 159, in main
     app = GMApp(workspaceFile)
   File "/home/maris/soft/grass-main/dist.x86_64-pc-linux-
gnu/gui/wxpython/wxgui.py", line 53, in __init__
     wx.App.__init__(self, False)
   File "/usr/lib64/python2.7/site-packages/wx-3.0-gtk2/wx/_core.py", line
8628, in __init__
     self._BootstrapApp()
   File "/usr/lib64/python2.7/site-packages/wx-3.0-gtk2/wx/_core.py", line
8196, in _BootstrapApp
     return _core_.PyApp__BootstrapApp(*args, **kwargs)
   File "/home/maris/soft/grass-main/dist.x86_64-pc-linux-
gnu/gui/wxpython/wxgui.py", line 106, in OnInit
     workspace=self.workspaceFile)
   File "/home/maris/soft/grass-main/dist.x86_64-pc-linux-
gnu/gui/wxpython/lmgr/frame.py", line 131, in __init__
     self._moduleTreeBuilder =
LayerManagerModuleTree(message_handler=add_menu_error)
   File "/home/maris/soft/grass-main/dist.x86_64-pc-linux-
gnu/gui/wxpython/lmgr/menudata.py", line 70, in __init__
     error_handler(_("Unable to parse user toolboxes XML files. "
NameError: global name 'error_handler' is not defined
}}}

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

#3867: menudata.py: global name 'error_handler' is not defined
--------------------------+-------------------------
  Reporter: marisn | Owner: wenzeslaus
      Type: defect | Status: assigned
  Priority: normal | Milestone:
Component: wxGUI | Version: svn-trunk
Resolution: | Keywords:
       CPU: Unspecified | Platform: Unspecified
--------------------------+-------------------------

Comment (by annakrat):

The fix is rather simple, but could you please test
https://github.com/OSGeo/grass/pull/43? I was not able to test and I
wonder why do you get that error at all.

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

#3867: menudata.py: global name 'error_handler' is not defined
--------------------------+-------------------------
  Reporter: marisn | Owner: wenzeslaus
      Type: defect | Status: assigned
  Priority: normal | Milestone:
Component: wxGUI | Version: svn-trunk
Resolution: | Keywords:
       CPU: Unspecified | Platform: Unspecified
--------------------------+-------------------------

Comment (by marisn):

Replying to [comment:1 annakrat]:
> The fix is rather simple, but could you please test
https://github.com/OSGeo/grass/pull/43? I was not able to test and I
wonder why do you get that error at all.

Yes, whit this fix it is possible to get one step further:

{{{
/usr/lib64/python2.7/site-packages/wx-3.0-gtk2/wx/_core.py:16629:
UserWarning: wxPython/wxWidgets release number mismatch
   warnings.warn("wxPython/wxWidgets release number mismatch")
r.agent: Unable to fetch interface description for command '<r.agent>'.

Details: <[Errno 2] No such file or directory>
r.agent: Unable to fetch interface description for command '<r.agent>'.

Details: <[Errno 2] No such file or directory>
Traceback (most recent call last):
   File "/home/maris/soft/grass-main/dist.x86_64-pc-linux-
gnu/gui/wxpython/wxgui.py", line 172, in <module>
     sys.exit(main())
   File "/home/maris/soft/grass-main/dist.x86_64-pc-linux-
gnu/gui/wxpython/wxgui.py", line 159, in main
     app = GMApp(workspaceFile)
   File "/home/maris/soft/grass-main/dist.x86_64-pc-linux-
gnu/gui/wxpython/wxgui.py", line 53, in __init__
     wx.App.__init__(self, False)
   File "/usr/lib64/python2.7/site-packages/wx-3.0-gtk2/wx/_core.py", line
8628, in __init__
     self._BootstrapApp()
   File "/usr/lib64/python2.7/site-packages/wx-3.0-gtk2/wx/_core.py", line
8196, in _BootstrapApp
     return _core_.PyApp__BootstrapApp(*args, **kwargs)
   File "/home/maris/soft/grass-main/dist.x86_64-pc-linux-
gnu/gui/wxpython/wxgui.py", line 106, in OnInit
     workspace=self.workspaceFile)
   File "/home/maris/soft/grass-main/dist.x86_64-pc-linux-
gnu/gui/wxpython/lmgr/frame.py", line 131, in __init__
     self._moduleTreeBuilder =
LayerManagerModuleTree(message_handler=add_menu_error)
   File "/home/maris/soft/grass-main/dist.x86_64-pc-linux-
gnu/gui/wxpython/lmgr/menudata.py", line 73, in __init__
     self, fallback, message_handler=message_handler)
   File "/home/maris/soft/grass-main/dist.x86_64-pc-linux-
gnu/gui/wxpython/core/menutree.py", line 73, in __init__
     expAddons(xmlTree)
   File "/home/maris/soft/grass-main/dist.x86_64-pc-linux-
gnu/gui/wxpython/core/toolboxes.py", line 363, in expandAddons
     _expandRuntimeModules(root, loadMetadata=True)
   File "/home/maris/soft/grass-main/dist.x86_64-pc-linux-
gnu/gui/wxpython/core/toolboxes.py", line 626, in _expandRuntimeModules
     desc, keywords = _loadMetadata(name)
   File "/home/maris/soft/grass-main/dist.x86_64-pc-linux-
gnu/gui/wxpython/core/toolboxes.py", line 663, in _loadMetadata
     task = gtask.parse_interface(module)
   File "/home/maris/soft/grass-main/dist.x86_64-pc-linux-
gnu/etc/python/grass/script/task.py", line 521, in parse_interface
     tree = etree.fromstring(get_interface_description(name))
   File "/home/maris/soft/grass-main/dist.x86_64-pc-linux-
gnu/etc/python/grass/script/task.py", line 497, in
get_interface_description
     "\n\nDetails: <{det}>".format(cmd=cmd, det=decode(cmderr))))
UnicodeEncodeError: 'ascii' codec can't encode characters in position 1-2:
ordinal not in range(128)
}}}

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

#3867: menudata.py: global name 'error_handler' is not defined
--------------------------+-------------------------
  Reporter: marisn | Owner: wenzeslaus
      Type: defect | Status: assigned
  Priority: normal | Milestone:
Component: wxGUI | Version: svn-trunk
Resolution: | Keywords:
       CPU: Unspecified | Platform: Unspecified
--------------------------+-------------------------

Comment (by annakrat):

Can't reproduce it. Anything special about your configuration? I can see
wxPython 3 and Python 2. Which addons do you have installed? It happens
during loading info about installed addons.

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

#3867: menudata.py: global name 'error_handler' is not defined
--------------------------+-------------------------
  Reporter: marisn | Owner: wenzeslaus
      Type: defect | Status: assigned
  Priority: normal | Milestone:
Component: wxGUI | Version: svn-trunk
Resolution: | Keywords:
       CPU: Unspecified | Platform: Unspecified
--------------------------+-------------------------

Comment (by marisn):

Replying to [comment:3 annakrat]:
> Can't reproduce it. Anything special about your configuration? I can see
wxPython 3 and Python 2. Which addons do you have installed? It happens
during loading info about installed addons.

Ah. I see. You will need some broken addons thus triggering error
processing code paths. You also will need a locale with non-ascii chars in
particular message causing failure :slight_smile: Try running with LC_ALL=lv_LV

Python 2.7.16
wxpython-3.0.2.0
wxGTK-3.0.4
Gentoo ~AMD64

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

#3867: menudata.py: global name 'error_handler' is not defined
--------------------------+-------------------------
  Reporter: marisn | Owner: wenzeslaus
      Type: defect | Status: assigned
  Priority: normal | Milestone:
Component: wxGUI | Version: svn-trunk
Resolution: | Keywords:
       CPU: Unspecified | Platform: Unspecified
--------------------------+-------------------------

Comment (by martinl):

Merged into master
https://github.com/OSGeo/grass/commit/46a32d8674d38ce04aa50c455cd6b71ef015dae0

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

#3867: menudata.py: global name 'error_handler' is not defined
--------------------------+-------------------------
  Reporter: marisn | Owner: wenzeslaus
      Type: defect | Status: assigned
  Priority: normal | Milestone: 7.4.5
Component: wxGUI | Version: svn-trunk
Resolution: | Keywords:
       CPU: Unspecified | Platform: Unspecified
--------------------------+-------------------------
Changes (by martinl):

* milestone: => 7.4.5

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

#3867: menudata.py: global name 'error_handler' is not defined
--------------------------+-------------------------
  Reporter: marisn | Owner: wenzeslaus
      Type: defect | Status: closed
  Priority: normal | Milestone: 7.4.5
Component: wxGUI | Version: svn-trunk
Resolution: fixed | Keywords:
       CPU: Unspecified | Platform: Unspecified
--------------------------+-------------------------
Changes (by martinl):

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

Comment:

Backported to 7.6 (bfb7e0a511ea62391a02fb7904f8b3902ecbc450) and 7.4
(29fc4ae1019d639719af206637e47b57b1b5f785)

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

#3867: menudata.py: global name 'error_handler' is not defined
--------------------------+-------------------------
  Reporter: marisn | Owner: wenzeslaus
      Type: defect | Status: reopened
  Priority: normal | Milestone: 7.4.5
Component: wxGUI | Version: svn-trunk
Resolution: | Keywords:
       CPU: Unspecified | Platform: Unspecified
--------------------------+-------------------------
Changes (by annakrat):

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

Comment:

I still can't reproduce it but please try this:
https://github.com/OSGeo/grass/pull/52

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

#3867: menudata.py: global name 'error_handler' is not defined
--------------------------+-------------------------
  Reporter: marisn | Owner: wenzeslaus
      Type: defect | Status: reopened
  Priority: normal | Milestone: 7.4.5
Component: wxGUI | Version: svn-trunk
Resolution: | Keywords:
       CPU: Unspecified | Platform: Unspecified
--------------------------+-------------------------

Comment (by hcho):

Hm... get_interface_description.. Looks familiar. Maybe, related to
https://github.com/OSGeo/grass/pull/46. Please try it.

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

#3867: menudata.py: global name 'error_handler' is not defined
--------------------------+-------------------------
  Reporter: marisn | Owner: wenzeslaus
      Type: defect | Status: reopened
  Priority: normal | Milestone: 7.4.5
Component: wxGUI | Version: svn-trunk
Resolution: | Keywords:
       CPU: Unspecified | Platform: Unspecified
--------------------------+-------------------------

Comment (by hcho):

Also, those who cannot reproduce this specific issue, please check your
make log and see if there are a lot of "Cannot parse interface for module"
errors without and with this PR.

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

#3867: menudata.py: global name 'error_handler' is not defined
--------------------------+-------------------------
  Reporter: marisn | Owner: wenzeslaus
      Type: defect | Status: reopened
  Priority: normal | Milestone: 7.4.5
Component: wxGUI | Version: svn-trunk
Resolution: | Keywords:
       CPU: Unspecified | Platform: Unspecified
--------------------------+-------------------------

Comment (by marisn):

Replying to [comment:8 annakrat]:
> I still can't reproduce it but please try this:
https://github.com/OSGeo/grass/pull/52

It is a cat and mouse game now:

{{{
r.agent: Unable to fetch interface description for command '<r.agent>'.

Details: <[Errno 2] No such file or directory>
Traceback (most recent call last):
   File "/home/maris/soft/grass-main/dist.x86_64-pc-linux-
gnu/gui/wxpython/wxgui.py", line 172, in <module>
     sys.exit(main())
   File "/home/maris/soft/grass-main/dist.x86_64-pc-linux-
gnu/gui/wxpython/wxgui.py", line 159, in main
     app = GMApp(workspaceFile)
   File "/home/maris/soft/grass-main/dist.x86_64-pc-linux-
gnu/gui/wxpython/wxgui.py", line 53, in __init__
     wx.App.__init__(self, False)
   File "/usr/lib64/python2.7/site-packages/wx-3.0-gtk2/wx/_core.py", line
8628, in __init__
     self._BootstrapApp()
   File "/usr/lib64/python2.7/site-packages/wx-3.0-gtk2/wx/_core.py", line
8196, in _BootstrapApp
     return _core_.PyApp__BootstrapApp(*args, **kwargs)
   File "/home/maris/soft/grass-main/dist.x86_64-pc-linux-
gnu/gui/wxpython/wxgui.py", line 106, in OnInit
     workspace=self.workspaceFile)
   File "/home/maris/soft/grass-main/dist.x86_64-pc-linux-
gnu/gui/wxpython/lmgr/frame.py", line 131, in __init__
     self._moduleTreeBuilder =
LayerManagerModuleTree(message_handler=add_menu_error)
   File "/home/maris/soft/grass-main/dist.x86_64-pc-linux-
gnu/gui/wxpython/lmgr/menudata.py", line 73, in __init__
     self, fallback, message_handler=message_handler)
   File "/home/maris/soft/grass-main/dist.x86_64-pc-linux-
gnu/gui/wxpython/core/menutree.py", line 73, in __init__
     expAddons(xmlTree)
   File "/home/maris/soft/grass-main/dist.x86_64-pc-linux-
gnu/gui/wxpython/core/toolboxes.py", line 363, in expandAddons
     _expandRuntimeModules(root, loadMetadata=True)
   File "/home/maris/soft/grass-main/dist.x86_64-pc-linux-
gnu/gui/wxpython/core/toolboxes.py", line 626, in _expandRuntimeModules
     desc, keywords = _loadMetadata(name)
   File "/home/maris/soft/grass-main/dist.x86_64-pc-linux-
gnu/gui/wxpython/core/toolboxes.py", line 665, in _loadMetadata
     sys.stderr.write("%s: %s\n" % (module, e))
   File "/home/maris/soft/grass-main/dist.x86_64-pc-linux-
gnu/etc/python/grass/exceptions/__init__.py", line 48, in __str__
     return str(self.value)
UnicodeEncodeError: 'ascii' codec can't encode characters in position
79-80: ordinal not in range(128)
}}}

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

#3867: menudata.py: global name 'error_handler' is not defined
--------------------------+-------------------------
  Reporter: marisn | Owner: wenzeslaus
      Type: defect | Status: reopened
  Priority: normal | Milestone: 7.4.5
Component: wxGUI | Version: svn-trunk
Resolution: | Keywords:
       CPU: Unspecified | Platform: Unspecified
--------------------------+-------------------------

Comment (by annakrat):

https://github.com/OSGeo/grass/pull/58

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

#3867: menudata.py: global name 'error_handler' is not defined
--------------------------+-------------------------
  Reporter: marisn | Owner: wenzeslaus
      Type: defect | Status: closed
  Priority: normal | Milestone: 7.4.5
Component: wxGUI | Version: svn-trunk
Resolution: fixed | Keywords:
       CPU: Unspecified | Platform: Unspecified
--------------------------+-------------------------
Changes (by marisn):

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

Comment:

Replying to [comment:12 annakrat]:
> https://github.com/OSGeo/grass/pull/58

Yes! This does the trick! Now I see a nice error message instead of
complete failure.

Closing as fixed with https://github.com/OSGeo/grass/pull/58

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