[GRASS-dev] Print in one line a `g.message` and a raster's processing % progress counter

Markus Neteler neteler at osgeo.org
Sat Nov 9 03:51:11 PST 2013


On Sat, Nov 9, 2013 at 10:59 AM, Nikos Alexandris
<nik at nikosalexandris.net> wrote:
> A GRASSy shell script print's out, by using g.messave -i (or similar),
> something like:
>
> --%<---
>
> [1] ...
> [2] "Some message..."
> 100%
> [3] "Another message..."
> 100%
> [4] "And another message..."
> 100%
> [5] ...
>
> --->%--
>
> I would like to have the % progress counter right after the message, in the
> same line and not printed in a new line. How is this to be achieved?

It might be an idea to add a new flag for this like "echo" offers:

echo - display a line of text
       -n     do not output the trailing newline

> This is a bash shell question. Yet, what technique is there for a python
> script?

Random link:
http://stackoverflow.com/questions/275018/how-can-i-remove-chomp-a-newline-in-python

I am not sure if a new flag should be added to g.message.

Note that there is also

GRASS_MESSAGE_FORMAT [various modules, wxGUI]
it may be set to either
 - standard - sets percentage output and message formatting style to
standard formatting,
 - gui - sets percentage output and message formatting style to GUI formatting,
 - silent - disables percentage output and error messages,
 - plain - sets percentage output and message formatting style to
ASCII output without rewinding control characters.
http://grass.osgeo.org/grass70/manuals/variables.html

hope this helps,
Markus


More information about the grass-dev mailing list