[GRASS-dev] Using grass.message in Python: Why does G_message() print to stderr and not stdout?

Vaclav Petras wenzeslaus at gmail.com
Sun Sep 9 13:22:11 PDT 2018


On Sun, Sep 9, 2018 at 3:37 PM Markus Metz <markus.metz.giswork at gmail.com>
wrote:
>
>
>
> On Sun, Sep 9, 2018 at 4:46 PM Markus Neteler <neteler at osgeo.org> wrote:
>
> >
> > I'd also like to see a way to print through the parser, i.e. a
> > functionality similiar to "sh -x shellscript" which prints every step.
> > Is that possible?
>
> In Python you mean? Maybe one of the GRASS Python gurus can answer that
(not me).

It is not clear to me either what you are asking for. Do you want every
Python line? Python can do that with module `trace` (python -m trace
--trace). Here is an example (just for testing purposes, using the
--tmp-location and --exec):

grass --tmp-location XY --exec python -m trace --trace `grass
--tmp-location XY --exec which r.mask` -r

That gives little too much information, so perhaps:

FILE="`./bin.x86_64-pc-linux-gnu/grass77 --tmp-location XY --exec which
r.mask`"
grass --tmp-location XY --exec python -m trace --trace $FILE -r | grep
`basename $FILE`

Or do you want GRASS parser to print every module being executed?

Vaclav
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/grass-dev/attachments/20180909/85a96b39/attachment.html>


More information about the grass-dev mailing list