[GRASS-SVN] r43002 - grass/trunk/gui/wxpython
svn_grass at osgeo.org
svn_grass at osgeo.org
Wed Aug 4 14:39:05 EDT 2010
Author: martinl
Date: 2010-08-04 18:39:05 +0000 (Wed, 04 Aug 2010)
New Revision: 43002
Modified:
grass/trunk/gui/wxpython/wxgui.py
Log:
wxGUI: don't override workspace file when failed
Modified: grass/trunk/gui/wxpython/wxgui.py
===================================================================
--- grass/trunk/gui/wxpython/wxgui.py 2010-08-04 18:24:42 UTC (rev 43001)
+++ grass/trunk/gui/wxpython/wxgui.py 2010-08-04 18:39:05 UTC (rev 43002)
@@ -26,6 +26,7 @@
import getopt
import platform
import signal
+import tempfile
### XML
try:
@@ -846,30 +847,30 @@
def SaveToWorkspaceFile(self, filename):
"""!Save layer tree layout to workspace file
-
+
Return True on success, False on error
"""
-
+ tmpfile = tempfile.TemporaryFile(mode='w+b')
try:
- file = open(filename, "w")
- except IOError:
- wx.MessageBox(parent=self,
- message=_("Unable to open workspace file <%s> for writing.") % filename,
- caption=_("Error"), style=wx.OK | wx.ICON_ERROR | wx.CENTRE)
+ workspace.WriteWorkspaceFile(lmgr = self, file = tmpfile)
+ except StandardError, e:
+ gcmd.GError(parent = self,
+ message = _("Writing current settings to workspace file "
+ "failed."))
return False
-
+
try:
- workspace.WriteWorkspaceFile(lmgr=self, file=file)
- except StandardError, e:
- file.close()
- wx.MessageBox(parent=self,
- message=_("Writing current settings to workspace file failed (%s)." % e),
- caption=_("Error"),
- style=wx.OK | wx.ICON_ERROR | wx.CENTRE)
+ mfile = open(filename, "w")
+ tmpfile.seek(0)
+ for line in tmpfile.readlines():
+ mfile.write(line)
+ except IOError:
+ gcmd.GError(parent = self,
+ message = _("Unable to open file <%s> for writing.") % filename)
return False
-
- file.close()
+ mfile.close()
+
return True
def OnWorkspaceClose(self, event = None):
More information about the grass-commit
mailing list