[GRASS-SVN] r70023 - grass-addons/grass7/raster/r.catchment

svn_grass at osgeo.org svn_grass at osgeo.org
Tue Dec 6 15:17:47 PST 2016


Author: isaacullah
Date: 2016-12-06 15:17:47 -0800 (Tue, 06 Dec 2016)
New Revision: 70023

Modified:
   grass-addons/grass7/raster/r.catchment/r.catchment.py
Log:
Minor edit to resolve issue with temporary files on Windows OS. Replaced old use of tempfile.NamedTemporaryFile with standard GRASS python interface to g.tempfile (grass.tempfile). This should mitigate issues on Windows.

Modified: grass-addons/grass7/raster/r.catchment/r.catchment.py
===================================================================
--- grass-addons/grass7/raster/r.catchment/r.catchment.py	2016-12-06 23:07:44 UTC (rev 70022)
+++ grass-addons/grass7/raster/r.catchment/r.catchment.py	2016-12-06 23:17:47 UTC (rev 70023)
@@ -127,8 +127,6 @@
 import sys
 import os
 import subprocess
-import tempfile
-
 # Just in case system can't find where grass.script is
 grass_install_tree = os.getenv('GISBASE')
 sys.path.append(grass_install_tree + os.sep + 'etc' + os.sep + 'python')
@@ -141,7 +139,8 @@
 # stdout where the keys are numeric values, n is the character that separates
 # the key from the data, o is a defined blank dictionary to write results to
 def out2dictnum(m, n, o):
-    """Execute a grass command, and parse it to a dictionary"""
+    """Execute a grass command, and parse it to a dictionary
+    This works differently than standard grass.parse_command syntax"""
     p1 = subprocess.Popen('%s' % m, stdout=subprocess.PIPE, shell='bash')
     p2 = p1.stdout.readlines()
     for y in p2:
@@ -322,7 +321,7 @@
         "units." % (int(cutoff), displayarea)))
     ####################################################
         grass.verbose(_('Creating output map'))
-        temp = tempfile.NamedTemporaryFile()
+        temp = grass.tempfile()
         temp.write('0 thru %s = %s\n' % (int(cutoff),  mapval))
         temp.flush()
         grass.run_command('r.reclass', overwrite=grass.overwrite(), input=cost,



More information about the grass-commit mailing list