[GRASS-SVN] r55343 - grass/trunk/gui/wxpython/dbmgr
svn_grass at osgeo.org
svn_grass at osgeo.org
Wed Mar 13 01:25:24 PDT 2013
Author: annakrat
Date: 2013-03-13 01:25:24 -0700 (Wed, 13 Mar 2013)
New Revision: 55343
Modified:
grass/trunk/gui/wxpython/dbmgr/base.py
Log:
wxGUI: fix #1270 (merge from release branch, r55306)
Modified: grass/trunk/gui/wxpython/dbmgr/base.py
===================================================================
--- grass/trunk/gui/wxpython/dbmgr/base.py 2013-03-12 23:20:08 UTC (rev 55342)
+++ grass/trunk/gui/wxpython/dbmgr/base.py 2013-03-13 08:25:24 UTC (rev 55343)
@@ -815,17 +815,18 @@
# perform SQL non-select statements (e.g. 'delete from table where cat=1')
if len(listOfSQLStatements) > 0:
- sqlFile = tempfile.NamedTemporaryFile(mode = "wt")
+ fd, sqlFilePath = tempfile.mkstemp(text=True)
+ sqlFile = open(sqlFilePath, 'w')
for sql in 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.dbMgrData['mapDBInfo'].layers[self.selLayer]["driver"]
database = self.dbMgrData['mapDBInfo'].layers[self.selLayer]["database"]
@@ -835,10 +836,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
listOfSQLStatements = []
More information about the grass-commit
mailing list