[GRASS-SVN] r58156 - grass/trunk/gui/wxpython/lmgr
svn_grass at osgeo.org
svn_grass at osgeo.org
Wed Nov 6 06:56:57 PST 2013
Author: martinl
Date: 2013-11-06 06:56:57 -0800 (Wed, 06 Nov 2013)
New Revision: 58156
Modified:
grass/trunk/gui/wxpython/lmgr/frame.py
Log:
wxGUI: avoid double launching user-defined scripts
Modified: grass/trunk/gui/wxpython/lmgr/frame.py
===================================================================
--- grass/trunk/gui/wxpython/lmgr/frame.py 2013-11-06 13:45:51 UTC (rev 58155)
+++ grass/trunk/gui/wxpython/lmgr/frame.py 2013-11-06 14:56:57 UTC (rev 58156)
@@ -791,7 +791,7 @@
tree.OnStartEditing(None)
def OnRunScript(self, event):
- """!Run script"""
+ """!Run user-defined script"""
# open dialog and choose script file
dlg = wx.FileDialog(parent = self, message = _("Choose script file to run"),
defaultDir = os.getcwd(),
@@ -845,10 +845,27 @@
style = wx.YES_NO | wx.YES_DEFAULT | wx.ICON_QUESTION)
if dlg.ShowModal() == wx.ID_YES:
SetAddOnPath(os.pathsep.join(addonPath), key = 'PATH')
+ dlg.Destroy()
self._gconsole.WriteCmdLog(_("Launching script '%s'...") % filename)
- self._gconsole.RunCmd([filename])
+ # check if the script has an interface (avoid double-launching
+ # of the script)
+ skipInterface = True
+ try:
+ sfile = open(filename, "r")
+ for line in sfile.readlines():
+ if len(line) < 2:
+ continue
+ if line[0] is '#' and line[1] is '%':
+ skipInterface = False
+ break
+ except IOError:
+ pass
+ finally:
+ sfile.close()
+ self._gconsole.RunCmd([filename], skipInterface=skipInterface)
+
def OnChangeLocation(self, event):
"""Change current location"""
dlg = LocationDialog(parent = self)
More information about the grass-commit
mailing list