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

svn_grass at osgeo.org svn_grass at osgeo.org
Wed Jul 27 10:53:14 EDT 2011


Author: mmetz
Date: 2011-07-27 07:53:14 -0700 (Wed, 27 Jul 2011)
New Revision: 47269

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

Modified: grass/branches/develbranch_6/lib/python/db.py
===================================================================
--- grass/branches/develbranch_6/lib/python/db.py	2011-07-27 14:51:27 UTC (rev 47268)
+++ grass/branches/develbranch_6/lib/python/db.py	2011-07-27 14:53:14 UTC (rev 47269)
@@ -92,21 +92,25 @@
     @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()
+    result = ofile.readlines()
+    ofile.close()
+    try_remove(fname)
+        
+    return result



More information about the grass-commit mailing list