[GRASS-SVN] r56794 - grass/branches/develbranch_6/lib/python

svn_grass at osgeo.org svn_grass at osgeo.org
Wed Jun 19 04:28:42 PDT 2013


Author: hamish
Date: 2013-06-19 04:28:42 -0700 (Wed, 19 Jun 2013)
New Revision: 56794

Modified:
   grass/branches/develbranch_6/lib/python/core.py
Log:
add usage example for find_program, note that the exe needs to return with a non-zero exit code (merge from trunk)

Modified: grass/branches/develbranch_6/lib/python/core.py
===================================================================
--- grass/branches/develbranch_6/lib/python/core.py	2013-06-19 11:23:34 UTC (rev 56793)
+++ grass/branches/develbranch_6/lib/python/core.py	2013-06-19 11:28:42 UTC (rev 56794)
@@ -971,11 +971,25 @@
 
 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
+    valid CLI option, like "--help". For other programs a common
+    valid do-little option is "--version".
+  
+    Example:
 
+    @code
+    >>> grass.find_program('r.sun', ['help'])
+    True
+    >>> grass.find_program('gdalwarp', ['--version'])
+    True
+    @endcode
+
     @param pgm program name
     @param args list of arguments
 
     @return False if the attempt failed due to a missing executable
+            or non-zero return code
     @return True otherwise
     """
     nuldev = file(os.devnull, 'w+')



More information about the grass-commit mailing list