[GRASS-SVN] r47272 - grass/branches/releasebranch_6_4/lib/python

svn_grass at osgeo.org svn_grass at osgeo.org
Wed Jul 27 11:00:41 EDT 2011


Author: mmetz
Date: 2011-07-27 08:00:41 -0700 (Wed, 27 Jul 2011)
New Revision: 47272

Modified:
   grass/branches/releasebranch_6_4/lib/python/db.py
Log:
db_select: clean up afterwards (backport from trunk)

Modified: grass/branches/releasebranch_6_4/lib/python/db.py
===================================================================
--- grass/branches/releasebranch_6_4/lib/python/db.py	2011-07-27 14:59:47 UTC (rev 47271)
+++ grass/branches/releasebranch_6_4/lib/python/db.py	2011-07-27 15:00:41 UTC (rev 47272)
@@ -92,21 +92,26 @@
     @param file  True if sql is filename
     @param args  see db.select arguments
     """
-    ofile = pytempfile.NamedTemporaryFile(mode = 'w+b')
+    fname = tempfile(create = False)
     if not file:
         ret = run_command('db.select', quiet = True,
                           flags = 'c',
                           table = table,
                           sql = sql,
-                          output = ofile.name)
+                          output = fname)
     else: # -> sql is file
         ret = run_command('db.select', quiet = True,
                           flags = 'c',
                           table = table,
                           input = sql,
-                          output = ofile.name)
+                          output = fname)
     
     if ret != 0:
         fatal(_("Fetching data from table <%s> failed") % table)
         
-    return ofile.readlines()
+    ofile = open(fname)
+    result = ofile.readlines()
+    ofile.close()
+    try_remove(fname)
+        
+    return result



More information about the grass-commit mailing list