[GRASS-SVN] r37820 - grass/trunk/scripts/v.colors

svn_grass at osgeo.org svn_grass at osgeo.org
Thu Jun 11 09:59:35 EDT 2009


Author: glynn
Date: 2009-06-11 09:59:34 -0400 (Thu, 11 Jun 2009)
New Revision: 37820

Modified:
   grass/trunk/scripts/v.colors/v.colors.py
Log:
Use temporary file to avoid deadlock


Modified: grass/trunk/scripts/v.colors/v.colors.py
===================================================================
--- grass/trunk/scripts/v.colors/v.colors.py	2009-06-11 13:07:54 UTC (rev 37819)
+++ grass/trunk/scripts/v.colors/v.colors.py	2009-06-11 13:59:34 UTC (rev 37820)
@@ -252,8 +252,8 @@
     # calculate colors and write SQL command file
     grass.message("Looking up colors ...")
 
-    p = grass.start_command('r.what.color', flags = 'i', input = tmp_colr,
-			    stdin = grass.PIPE, stdout = grass.PIPE)
+    f = open(tmp, 'w')
+    p = grass.feed_command('r.what.color', flags = 'i', input = tmp_colr, stdout = f)
     lastval = None
     for v in sorted(cvals):
 	if v == lastval:
@@ -261,20 +261,23 @@
 	p.stdin.write('%f\n' % v)
     p.stdin.close()
     p.wait()
+    f.close()
 
     tmp_vcol = "%s_vcol.sql" % tmp
-    f = open(tmp_vcol, 'w')
+    fi = open(tmp, 'r')
+    fo = open(tmp_vcol, 'w')
     t = string.Template("UPDATE $table SET $rgb_column = '$colr' WHERE $column = $value;\n")
     found = 0
-    for line in p.stdout:
+    for line in fi:
 	[value, colr] = line.split(':')
 	colr = colr.strip()
 	if len(colr.split(':')) != 3:
 	    continue
 	#g.message message="LINE=[$LINE]"
-	f.write(t.substitute(table = table, rgb_column = rgb_column, colr = colr, value = value))
+	fo.write(t.substitute(table = table, rgb_column = rgb_column, colr = colr, value = value))
 	found += 1
-    f.close()
+    fi.close()
+    fo.close()
     
     if not found:
 	grass.fatal("No values found in color range")



More information about the grass-commit mailing list