瀏覽代碼

wxGUI/modeler: ignore missing parameters (show warning)

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@43653 15284696-431f-4ddb-bdfa-cd5b030d7da7
Martin Landa 14 年之前
父節點
當前提交
4bd63d737a
共有 2 個文件被更改,包括 17 次插入6 次删除
  1. 4 2
      gui/wxpython/gui_modules/gmodeler.py
  2. 13 4
      gui/wxpython/gui_modules/menuform.py

+ 4 - 2
gui/wxpython/gui_modules/gmodeler.py

@@ -2837,8 +2837,10 @@ class ProcessModelFile:
             cmd.append('%s=%s' % (name,
                                   self._filterValue(self._getNodeText(p, 'value'))))
         
-        task = menuform.GUI().ParseCommand(cmd = cmd,
-                                           show = None)
+        task, err = menuform.GUI().ParseCommand(cmd = cmd,
+                                                show = None, checkError = True)
+        if err:
+            GWarning(os.linesep.join(err))
         
         for opt, name in parameterized:
             if opt == 'flag':

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

@@ -2039,7 +2039,7 @@ class GUI:
         return processTask(tree).GetTask()
     
     def ParseCommand(self, cmd, gmpath = None, completed = None, parentframe = None,
-                     show = True, modal = False, centreOnParent = True):
+                     show = True, modal = False, centreOnParent = True, checkError = False):
         """!Parse command
         
         Note: cmd is given as list
@@ -2072,6 +2072,7 @@ class GUI:
             if 'flags' in dcmd_params:
                 self.grass_task.flags = dcmd_params['flags']
         
+        err = list()
         # update parameters if needed && validate command
         if len(cmd) > 1:
             i = 0
@@ -2092,8 +2093,13 @@ class GUI:
                             value = option
                         else:
                             raise ValueError, _("Unable to parse command %s") % ' '.join(cmd)
-
-                    element = self.grass_task.get_param(key)['element']
+                    
+                    element = self.grass_task.get_param(key, raiseError = False)
+                    if not element:
+                        err.append(_("%s: parameter '%s' not available") % (cmd[0], key))
+                        continue
+                    element = element['element']
+                    
                     if element in ['cell', 'vector']:
                         # mapname -> mapname@mapset
                         try:
@@ -2137,7 +2143,10 @@ class GUI:
         
         self.cmd = cmd
         
-        return self.grass_task
+        if checkError:
+            return self.grass_task, err
+        else:
+            return self.grass_task
     
     def GetCommandInputMapParamKey(self, cmd):
         """!Get parameter key for input raster/vector map