瀏覽代碼

Change find_program to take arguments as additional paramters rather than a list

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@56867 15284696-431f-4ddb-bdfa-cd5b030d7da7
Glynn Clements 12 年之前
父節點
當前提交
095ebb6128
共有 4 個文件被更改,包括 8 次插入11 次删除
  1. 1 1
      gui/wxpython/core/render.py
  2. 1 1
      gui/wxpython/gui_core/gselect.py
  3. 1 1
      gui/wxpython/gui_core/mapdisp.py
  4. 5 8
      lib/python/script/core.py

+ 1 - 1
gui/wxpython/core/render.py

@@ -451,7 +451,7 @@ class Map(object):
         """!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')
         

+ 1 - 1
gui/wxpython/gui_core/gselect.py

@@ -1803,7 +1803,7 @@ class GdalSelect(wx.Panel):
                                 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]

+ 1 - 1
gui/wxpython/gui_core/mapdisp.py

@@ -105,7 +105,7 @@ class MapFrameBase(wx.Frame):
     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')
         

+ 5 - 8
lib/python/script/core.py

@@ -1233,7 +1233,7 @@ def basename(path, ext=None):
         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 @@ def find_program(pgm, args = []):
     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 @@ def find_program(pgm, args = []):
     """
     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()