[GRASS-dev] [GRASS GIS] #2008: grass.script's find_program() can't find modules
GRASS GIS
trac at osgeo.org
Fri Jun 21 01:36:27 PDT 2013
#2008: grass.script's find_program() can't find modules
-----------------------+----------------------------------------------------
Reporter: hamish | Owner: grass-dev@…
Type: defect | Status: reopened
Priority: critical | Milestone: 6.4.4
Component: Python | Version: svn-releasebranch64
Resolution: | Keywords: find_program()
Platform: All | Cpu: x86-64
-----------------------+----------------------------------------------------
Comment(by zarch):
Replying to [comment:21 glynn]:
> What is self._runCommand? Or what is "self" for that matter?
> find_program() is a function, not a method. And it isn't part of the
> wxGUI, so it can't use any functions from it.
In my example I'm not using any method...
I only replace the function "find_program" with "try", in the example that
you can find:
http://trac.osgeo.org/grass/browser/grass/trunk/gui/wxpython/core/render.py?rev=56800#L454
{{{
Index: gui/wxpython/core/render.py
===================================================================
--- gui/wxpython/core/render.py (revision 56810)
+++ gui/wxpython/core/render.py (working copy)
@@ -451,12 +451,13 @@
"""!Return region projection and map units information
"""
projinfo = dict()
- if not grass.find_program('g.proj'):
- sys.exit(_("GRASS module '%s' not found. Unable to start map
"
- "display window.") % 'g.proj')
+ try:
ret = self._runCommand(RunCommand, prog = 'g.proj',
read = True, flags = 'p')
+ except OSError:
+ sys.exit(_("GRASS module '%s' not found. Unable to start map
"
+ "display window.") % 'g.proj')
if not ret:
return projinfo
}}}
As you see probably we don't need to define a new function...
--
Ticket URL: <https://trac.osgeo.org/grass/ticket/2008#comment:22>
GRASS GIS <http://grass.osgeo.org>
More information about the grass-dev
mailing list