瀏覽代碼

wxGUI: better treat external scripts
(merge https://trac.osgeo.org/grass/changeset/44329 from devbr6)


git-svn-id: https://svn.osgeo.org/grass/grass/trunk@44330 15284696-431f-4ddb-bdfa-cd5b030d7da7

Martin Landa 14 年之前
父節點
當前提交
7fbeb881b7
共有 2 個文件被更改,包括 23 次插入5 次删除
  1. 19 4
      gui/wxpython/gui_modules/goutput.py
  2. 4 1
      gui/wxpython/gui_modules/menuform.py

+ 19 - 4
gui/wxpython/gui_modules/goutput.py

@@ -530,10 +530,25 @@ class GMConsole(wx.SplitterWindow):
         else:
             # Send any other command to the shell. Send output to
             # console output window
-            self.cmdThread.RunCmd(GrassCmd,
-                                  onDone,
-                                  command,
-                                  self.cmd_stdout, self.cmd_stderr)                                         
+            if len(command) == 1:
+                import menuform
+                try:
+                    task = menuform.GUI().ParseInterface(command)
+                except:
+                    task = None
+                # if not task.has_required():
+                # task = None # run command
+            else:
+                task = None
+                
+            if task:
+                # process GRASS command without argument
+                menuform.GUI().ParseCommand(command, parentframe = self)
+            else:
+                self.cmdThread.RunCmd(GrassCmd,
+                                      onDone,
+                                      command,
+                                      self.cmd_stdout, self.cmd_stderr)                                         
             self.cmd_output_timer.Start(50)
         
         return None

+ 4 - 1
gui/wxpython/gui_modules/menuform.py

@@ -2119,10 +2119,13 @@ def getInterfaceDescription(cmd):
 
     @param cmd command (name of GRASS module)
     """
+    nuldev = file(os.devnull, 'w+')
     try:
-        cmdout = grass.Popen([cmd, '--interface-description'], stdout = grass.PIPE).communicate()[0]
+        cmdout = grass.Popen([cmd, '--interface-description'], stdout = grass.PIPE,
+                             stderr = nuldev).communicate()[0]
     except OSError:
         raise gcmd.GException, _("Unable to fetch interface description for command '%s'.") % cmd
+    nuldev.close()
     
     return cmdout.replace('grass-interface.dtd', os.path.join(globalvar.ETCDIR, 'grass-interface.dtd'))