[GRASS-SVN] r61428 - grass/trunk/lib/python/script

svn_grass at osgeo.org svn_grass at osgeo.org
Mon Jul 28 08:57:23 PDT 2014


Author: glynn
Date: 2014-07-28 08:57:23 -0700 (Mon, 28 Jul 2014)
New Revision: 61428

Modified:
   grass/trunk/lib/python/script/raster.py
Log:
Add env= parameter to mapcalc, mapcalc_start, raster_what


Modified: grass/trunk/lib/python/script/raster.py
===================================================================
--- grass/trunk/lib/python/script/raster.py	2014-07-28 13:35:08 UTC (rev 61427)
+++ grass/trunk/lib/python/script/raster.py	2014-07-28 15:57:23 UTC (rev 61428)
@@ -87,7 +87,8 @@
 
 # interface to r.mapcalc
 
-def mapcalc(exp, quiet = False, verbose = False, overwrite = False, seed = None, **kwargs):
+def mapcalc(exp, quiet = False, verbose = False, overwrite = False,
+            seed = None, env = None, **kwargs):
     """!Interface to r.mapcalc.
 
     @param exp expression
@@ -96,6 +97,7 @@
     @param overwrite True to enable overwriting the output (<tt>--o</tt>)
     @param seed an integer used to seed the random-number generator for the rand() function,
     or 'auto' to generate a random seed
+    @param env dictionary of environment variables for child process
     @param kwargs
     """
 
@@ -106,6 +108,7 @@
     e = t.substitute(**kwargs)
 
     if write_command('r.mapcalc', file = '-', stdin = e,
+                     env = env,
                      seed = seed,
                      quiet = quiet,
                      verbose = verbose,
@@ -113,7 +116,8 @@
         fatal(_("An error occurred while running r.mapcalc"))
 
 
-def mapcalc_start(exp, quiet = False, verbose = False, overwrite = False, seed = None, **kwargs):
+def mapcalc_start(exp, quiet = False, verbose = False, overwrite = False,
+                  seed = None, env = None, **kwargs):
     """!Interface to r.mapcalc, doesn't wait for it to finish, returns Popen object.
 
     \code
@@ -134,6 +138,7 @@
     @param overwrite True to enable overwriting the output (<tt>--o</tt>)
     @param seed an integer used to seed the random-number generator for the rand() function,
     or 'auto' to generate a random seed
+    @param env dictionary of environment variables for child process
     @param kwargs
     
     @return Popen object
@@ -146,6 +151,7 @@
     e = t.substitute(**kwargs)
 
     p = feed_command('r.mapcalc', file = '-',
+                     env = env,
                      seed = seed,
                      quiet = quiet,
                      verbose = verbose,
@@ -155,7 +161,7 @@
     return p
 
 # interface to r.what
-def raster_what(map, coord):
+def raster_what(map, coord, env = None):
     """!TODO"""
     if type(map) in (types.StringType, types.UnicodeType):
         map_list = [map]
@@ -173,14 +179,13 @@
     # separator '|' not included in command
     # because | is causing problems on Windows
     # change separator?
-    cmdParams = dict(quiet = True,
-                     flags = 'rf',
-                     map = ','.join(map_list),
-                     coordinates = ','.join(coord_list),
-                     null = _("No data"))
-    
     ret = read_command('r.what',
-                       **cmdParams)
+                       flags = 'rf',
+                       map = ','.join(map_list),
+                       coordinates = ','.join(coord_list),
+                       null = _("No data"),
+                       quiet = True,
+                       env = env)
     data = list()
     if not ret:
         return data



More information about the grass-commit mailing list