Browse Source

PyGRASS GridModule silently ignores when module has no output defined, see https://trac.osgeo.org/grass/ticket/3852 (#21)

Martin Landa 5 years ago
parent
commit
f5821bae56
1 changed files with 7 additions and 0 deletions
  1. 7 0
      lib/python/pygrass/modules/grid/grid.py

+ 7 - 0
lib/python/pygrass/modules/grid/grid.py

@@ -600,6 +600,7 @@ class GridModule(object):
         loc = Location()
         mset = loc[self.mset.name]
         mset.visible.extend(loc.mapsets())
+        noutputs = 0
         for otmap in self.module.outputs:
             otm = self.module.outputs[otmap]
             if otm.typedesc == 'raster' and otm.value:
@@ -607,6 +608,12 @@ class GridModule(object):
                            self.mset.name, self.msetstr, bboxes,
                            self.module.flags.overwrite,
                            self.start_row, self.start_col, self.out_prefix)
+                noutputs += 1
+        if noutputs < 1:
+            msg = 'No raster output option defined for <{}>'.format(self.module.name)
+            if self.module.name == 'r.mapcalc':
+                msg += '. Use <{}.simple> instead'.format(self.module.name)
+            raise RuntimeError(msg)
 
     def rm_tiles(self):
         """Remove all the tiles."""