[GRASS-dev] Use 'from=' parameter in python script

Vaclav Petras wenzeslaus at gmail.com
Thu Mar 22 06:52:17 PDT 2018


On Thu, Mar 22, 2018 at 5:36 AM, Nikos Alexandris <nik at nikosalexandris.net>
wrote:

>
> rescale_output = g.read_command('r.rescale', overwrite=True, verbose=True,
>        input=band, output=output_map_name, to=to_range)
> print rescale_output
>
> cls.runModule('r.rescale', overwrite=True, verbose=True,
>        input=band, output=output_map_name, to=to_range)
> ```
>
> the former will print the output of `r.rescale`, the latter will not.
>
>
> Is there a way to get the output of `runModule`, while building a test
> suite?
>

It's a PyGRASS module, so just access `module.outputs.stdout` afterwards.
Please extend the documentation if needed.

Is the purpose of `expecting_stdout=False` in `runModule()` to test if a
> module emits something to stdout? [0]
>

Yes. It's for cases like when r.univar prints nothing when raster map
contains NULLs only (or region is outside its extent).

HTH,
Vaclav
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/grass-dev/attachments/20180322/a6740c87/attachment.html>


More information about the grass-dev mailing list