[GRASS-SVN] r47001 - grass/trunk/gui/wxpython/gui_modules
svn_grass at osgeo.org
svn_grass at osgeo.org
Tue Jul 5 10:00:43 EDT 2011
Author: martinl
Date: 2011-07-05 07:00:43 -0700 (Tue, 05 Jul 2011)
New Revision: 47001
Modified:
grass/trunk/gui/wxpython/gui_modules/render.py
Log:
wxGUI: recover original cmdfile
Modified: grass/trunk/gui/wxpython/gui_modules/render.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/render.py 2011-07-05 13:11:57 UTC (rev 47000)
+++ grass/trunk/gui/wxpython/gui_modules/render.py 2011-07-05 14:00:43 UTC (rev 47001)
@@ -25,6 +25,7 @@
import math
import copy
import tempfile
+import stat
import wx
from wx.lib.newevent import NewEvent
@@ -855,9 +856,11 @@
"""!Parse cmd file for standalone application
"""
try:
+ cmdTimestamp = os.path.getmtime(self.cmdfile)
fd = open(self.cmdfile, 'r')
grass.try_remove(self.mapfile)
- for cmd in fd.readlines():
+ cmdLines = fd.readlines()
+ for cmd in cmdLines:
cmdStr = cmd.strip().split(' ')
cmd = utils.CmdToTuple(cmdStr)
@@ -867,11 +870,23 @@
(self.cmdfile, e))
return
+ fd.close()
+
+ # recover original cmdfile
+ try:
+ fd = open(self.cmdfile, 'w')
+ fd.writelines(cmdLines)
+
+ except IOError, e:
+ grass.warning(_("Unable to recover cmdfile '%s'. Details: %s") % \
+ (self.cmdfile, e))
+
+ fd.close()
+ os.utime(self.cmdfile, (os.stat(self.cmdfile)[stat.ST_ATIME], cmdTimestamp))
+
Debug.msg(1, "Map.__parseCmdFile(): cmdfile=%s" % self.cmdfile)
Debug.msg(1, " nlayers=%d" % len(self.layers))
- fd.close()
-
def _renderCmdFile(self, force, windres):
if not force:
return self.mapfile
More information about the grass-commit
mailing list