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

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?

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

Thank you, Nikos

On Sat, Nov 9, 2013 at 10:59 AM, Nikos Alexandris
<nik@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

Nikos Alexandris:

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?

Markus Neteler:

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

That is a nice idea. I don’t know of course if others consider this as necessary, but I’d like to be able to compress further and minimalise the extent of "g.message"s in the command line.

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-i

n-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

Thanks!