[GRASS-SVN] r55306 - grass/branches/releasebranch_6_4/gui/wxpython/dbmgr
svn_grass at osgeo.org
svn_grass at osgeo.org
Sun Mar 10 14:03:38 PDT 2013
Author: annakrat
Date: 2013-03-10 14:03:38 -0700 (Sun, 10 Mar 2013)
New Revision: 55306
Modified:
grass/branches/releasebranch_6_4/gui/wxpython/dbmgr/manager.py
Log:
wxGUI: attempt to fix #1270
Modified: grass/branches/releasebranch_6_4/gui/wxpython/dbmgr/manager.py
===================================================================
--- grass/branches/releasebranch_6_4/gui/wxpython/dbmgr/manager.py 2013-03-10 20:48:30 UTC (rev 55305)
+++ grass/branches/releasebranch_6_4/gui/wxpython/dbmgr/manager.py 2013-03-10 21:03:38 UTC (rev 55306)
@@ -1905,17 +1905,18 @@
# perform SQL non-select statements (e.g. 'delete from table where cat=1')
if len(self.listOfSQLStatements) > 0:
- sqlFile = tempfile.NamedTemporaryFile(mode = "wt")
+ fd, sqlFilePath = tempfile.mkstemp(text=True)
+ sqlFile = open(sqlFilePath, 'w')
for sql in self.listOfSQLStatements:
enc = UserSettings.Get(group = 'atm', key = 'encoding', subkey = 'value')
if not enc and 'GRASS_DB_ENCODING' in os.environ:
enc = os.environ['GRASS_DB_ENCODING']
if enc:
- sqlFile.file.write(sql.encode(enc) + ';')
+ sqlFile.write(sql.encode(enc) + ';')
else:
- sqlFile.file.write(sql + ';')
- sqlFile.file.write(os.linesep)
- sqlFile.file.flush()
+ sqlFile.write(sql + ';')
+ sqlFile.write(os.linesep)
+ sqlFile.close()
driver = self.mapDBInfo.layers[self.layer]["driver"]
database = self.mapDBInfo.layers[self.layer]["database"]
@@ -1925,10 +1926,12 @@
RunCommand('db.execute',
parent = self,
- input = sqlFile.name,
+ input = sqlFilePath,
driver = driver,
database = database)
+ os.close(fd)
+ os.remove(sqlFilePath)
# reset list of statements
self.listOfSQLStatements = []
More information about the grass-commit
mailing list