[GRASS-SVN] r48444 - grass/trunk/gui/wxpython/gui_modules
svn_grass at osgeo.org
svn_grass at osgeo.org
Sat Sep 24 07:38:43 EDT 2011
Author: martinl
Date: 2011-09-24 04:38:43 -0700 (Sat, 24 Sep 2011)
New Revision: 48444
Modified:
grass/trunk/gui/wxpython/gui_modules/goutput.py
grass/trunk/gui/wxpython/gui_modules/menuform.py
Log:
wxGUI: do not allow to run commands which tries to read stdin
Modified: grass/trunk/gui/wxpython/gui_modules/goutput.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/goutput.py 2011-09-24 11:35:16 UTC (rev 48443)
+++ grass/trunk/gui/wxpython/gui_modules/goutput.py 2011-09-24 11:38:43 UTC (rev 48444)
@@ -442,10 +442,13 @@
@param compReg True use computation region
@param switchPage switch to output page
@param onDone function to be called when command is finished
+
+ @return 0 on success
+ @return 1 on failure
"""
if len(command) == 0:
Debug.msg(2, "GPrompt:RunCmd(): empty command")
- return
+ return 0
# update history file
env = grass.gisenv()
@@ -501,7 +504,7 @@
gcmd.GMessage(parent = self.parent,
message = _("Command '%s' not yet implemented in the WxGUI. "
"Try adding it as a command layer instead.") % command[0])
- return None
+ return 1
if layertype == 'barscale':
self.parent.curr_page.maptree.GetMapDisplay().OnAddBarscale(None)
@@ -518,6 +521,21 @@
else:
# other GRASS commands (r|v|g|...)
+ # check for <input>=-
+ # gtask.parse_command() is probably overkill here, use brute force instead
+ for opt in command[1:]:
+ if opt[0] == '-':
+ # skip flags
+ continue
+ key, value = map(lambda x: x.strip(), opt.split('=', 1))
+ if value == '-':
+ gcmd.GError(parent = self,
+ message = _("Unable to run command:\n%(cmd)s\n\n"
+ "Option <%(opt)s>: read from standard input is not "
+ "supported by wxGUI") % { 'cmd': ' '.join(command),
+ 'opt': key })
+ return 1
+
# switch to 'Command output' if required
if switchPage:
self._notebook.SetSelectionByName('output')
@@ -533,10 +551,7 @@
del os.environ["GRASS_REGION"]
if len(command) == 1:
- import menuform
task = gtask.parse_interface(command[0])
- # if not task.has_required():
- # task = None # run command
else:
task = None
@@ -548,8 +563,6 @@
self.cmdThread.RunCmd(command, stdout = self.cmdStdOut, stderr = self.cmdStrErr,
onDone = onDone)
self.cmdOutputTimer.Start(50)
-
- return None
# deactivate computational region and return to display settings
if compReg and tmpreg:
@@ -558,7 +571,6 @@
# Send any other command to the shell. Send output to
# console output window
if len(command) == 1:
- import menuform
try:
task = gtask.parse_interface(command[0])
except:
@@ -574,7 +586,7 @@
onDone = onDone)
self.cmdOutputTimer.Start(50)
- return None
+ return 0
def ClearHistory(self, event):
"""!Clear history of commands"""
Modified: grass/trunk/gui/wxpython/gui_modules/menuform.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/menuform.py 2011-09-24 11:35:16 UTC (rev 48443)
+++ grass/trunk/gui/wxpython/gui_modules/menuform.py 2011-09-24 11:38:43 UTC (rev 48444)
@@ -688,6 +688,7 @@
if not cmd or len(cmd) < 1:
return
+ ret = 0
if self.standalone or cmd[0][0:2] != "d.":
# Send any non-display command to parent window (probably wxgui.py)
# put to parents switch to 'Command output'
@@ -697,13 +698,17 @@
if self.task.path:
cmd[0] = self.task.path # full path
- self.goutput.RunCmd(cmd, onDone = self.OnDone)
+ ret = self.goutput.RunCmd(cmd, onDone = self.OnDone)
except AttributeError, e:
print >> sys.stderr, "%s: Probably not running in wxgui.py session?" % (e)
print >> sys.stderr, "parent window is: %s" % (str(self.parent))
else:
gcmd.Command(cmd)
+ if ret != 0:
+ self.notebookpanel.notebook.SetSelection(0)
+ return
+
# update buttons status
for btn in (self.btn_run,
self.btn_cancel,
More information about the grass-commit
mailing list