[GRASS-SVN] r56867 - in grass/trunk: gui/wxpython/core gui/wxpython/gui_core lib/python/script
svn_grass at osgeo.org
svn_grass at osgeo.org
Fri Jun 21 09:14:06 PDT 2013
Author: glynn
Date: 2013-06-21 09:14:06 -0700 (Fri, 21 Jun 2013)
New Revision: 56867
Modified:
grass/trunk/gui/wxpython/core/render.py
grass/trunk/gui/wxpython/gui_core/gselect.py
grass/trunk/gui/wxpython/gui_core/mapdisp.py
grass/trunk/lib/python/script/core.py
Log:
Change find_program to take arguments as additional paramters rather than a list
Modified: grass/trunk/gui/wxpython/core/render.py
===================================================================
--- grass/trunk/gui/wxpython/core/render.py 2013-06-21 11:24:46 UTC (rev 56866)
+++ grass/trunk/gui/wxpython/core/render.py 2013-06-21 16:14:06 UTC (rev 56867)
@@ -451,7 +451,7 @@
"""!Return region projection and map units information
"""
projinfo = dict()
- if not grass.find_program('g.proj', ['--help']):
+ if not grass.find_program('g.proj', '--help'):
sys.exit(_("GRASS module '%s' not found. Unable to start map "
"display window.") % 'g.proj')
Modified: grass/trunk/gui/wxpython/gui_core/gselect.py
===================================================================
--- grass/trunk/gui/wxpython/gui_core/gselect.py 2013-06-21 11:24:46 UTC (rev 56866)
+++ grass/trunk/gui/wxpython/gui_core/gselect.py 2013-06-21 16:14:06 UTC (rev 56867)
@@ -1803,7 +1803,7 @@
driver = 'pg').splitlines()
if db is not None:
win.SetItems(sorted(db))
- elif grass.find_program('psql', ['--help']):
+ elif grass.find_program('psql', '--help'):
if not win.GetItems():
p = grass.Popen(['psql', '-ltA'], stdout = grass.PIPE)
ret = p.communicate()[0]
Modified: grass/trunk/gui/wxpython/gui_core/mapdisp.py
===================================================================
--- grass/trunk/gui/wxpython/gui_core/mapdisp.py 2013-06-21 11:24:46 UTC (rev 56866)
+++ grass/trunk/gui/wxpython/gui_core/mapdisp.py 2013-06-21 16:14:06 UTC (rev 56867)
@@ -105,7 +105,7 @@
def _initMap(self, Map):
"""!Initialize map display, set dimensions and map region
"""
- if not grass.find_program('g.region', ['--help']):
+ if not grass.find_program('g.region', '--help'):
sys.exit(_("GRASS module '%s' not found. Unable to start map "
"display window.") % 'g.region')
Modified: grass/trunk/lib/python/script/core.py
===================================================================
--- grass/trunk/lib/python/script/core.py 2013-06-21 11:24:46 UTC (rev 56866)
+++ grass/trunk/lib/python/script/core.py 2013-06-21 16:14:06 UTC (rev 56867)
@@ -1233,7 +1233,7 @@
name = fs[0]
return name
-def find_program(pgm, args = []):
+def find_program(pgm, *args):
"""!Attempt to run a program, with optional arguments.
You must call the program in a way that will return a successful
exit code. For GRASS modules this means you need to pass it some
@@ -1243,9 +1243,9 @@
Example:
@code
- >>> grass.find_program('r.sun', ['help'])
+ >>> grass.find_program('r.sun', 'help')
True
- >>> grass.find_program('gdalwarp', ['--version'])
+ >>> grass.find_program('gdalwarp', '--version')
True
@endcode
@@ -1258,11 +1258,8 @@
"""
nuldev = file(os.devnull, 'w+')
try:
- ret = call([pgm] + args, stdin = nuldev, stdout = nuldev, stderr = nuldev)
- if ret == 0:
- found = True
- else:
- found = False
+ call([pgm] + args, stdin = nuldev, stdout = nuldev, stderr = nuldev)
+ found = True
except:
found = False
nuldev.close()
More information about the grass-commit
mailing list