Opened 5 years ago

Closed 5 years ago

#3867 closed defect (fixed)

menudata.py: global name 'error_handler' is not defined

Reported by: marisn Owned by: wenzeslaus
Priority: normal Milestone: 7.4.5
Component: wxGUI Version: svn-trunk
Keywords: Cc:
CPU: Unspecified Platform: Unspecified

Description

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

Change History (13)

comment:1 by annakrat, 5 years ago

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.

in reply to:  1 comment:2 by marisn, 5 years ago

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

comment:3 by annakrat, 5 years ago

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.

in reply to:  3 comment:4 by marisn, 5 years ago

Replying to 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 :) Try running with LC_ALL=lv_LV

Python 2.7.16 wxpython-3.0.2.0 wxGTK-3.0.4 Gentoo ~AMD64

comment:6 by martinl, 5 years ago

Milestone: 7.4.5

comment:7 by martinl, 5 years ago

Resolution: fixed
Status: assignedclosed

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

comment:8 by annakrat, 5 years ago

Resolution: fixed
Status: closedreopened

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

comment:9 by hcho, 5 years ago

Hm... get_interface_description.. Looks familiar. Maybe, related to https://github.com/OSGeo/grass/pull/46. Please try it. I think get_real_command in core.py is the culprit. I had to add .py extension in the search.

Last edited 5 years ago by hcho (previous) (diff)

comment:10 by hcho, 5 years ago

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.

in reply to:  8 comment:11 by marisn, 5 years ago

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

in reply to:  12 comment:13 by marisn, 5 years ago

Resolution: fixed
Status: reopenedclosed

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

Note: See TracTickets for help on using tickets.