[GRASS-dev] r.mapcalc and g.remove --v/q issues

Hi,

Propably due to the recent work on --v and --q flags (great stuff, many
thanks to the authors!), r.mapcalc doesn't print any progress indicator
anymore.

Also g.remove doesn't return any info if trying to remove a
non-existant map. If used with --v it will print eg.:

$ g.remove rast=dummy --v
REMOVE [dummy]
raster MISSING
header MISSING
category MISSING
color MISSING
history MISSING
misc MISSING
fcell MISSING
g3dcell MISSING

as it used before introducing --q and --v. But if --v is not
explicitely set (default), it will remain silent.

It should print "ERROR: raster map <dummy> not found" instead.

And IMO it would be best if it printed such info in either case (quiet
or verbose), as the current g.remove --v output is over-informative.
All those header/category/color etc. entries are a noise that should be
printed only at a higher level of debug, not by defalt, I think.

BTW - what's the "g3dcell" above?

If the map to be removed is present, in --q mode nothing should be
printed, and in the --v mode only "Raster map <dummy> removed" instead
of the current 9 lines of output.

Also in case of vectors, currently it's:

    exists: doesn't exist:

--v: REMOVE REMOVE
        ERROR: Vector map <x> not found

--q: silent ERROR: Vector map <x> not found

Which should be:

    exists: doesn't exist:

--v: Vector map <x> removed ERROR: Vector map <x> not found

--q: silent ERROR: Vector map <x> not found

Maciek

Maciej Sieczka wrote:

Propably due to the recent work on --v and --q flags (great stuff, many
thanks to the authors!), r.mapcalc doesn't print any progress indicator
anymore.

AFAIK, modules are quiet by default now. If you want verbosity (e.g.
progress indication) you have to enable it.

As r.mapcalc doesn't use G_parser(), --v won't work; you would need to
set GRASS_VERBOSE.

There probably needs to be a "stub" version of G_parser() which
implements the built-in switches (--help, --verbose etc) but doesn't
attempt to parse the entire command line.

Changing the syntax of r.mapcalc to conform to the normal convention
would probably be too radical a change. While we can fix our own
scripts, there are likely to be a lot of home-grown scripts which
would be broken (not to mention users who are accustomed to using the
existing syntax from the command line).

Also g.remove doesn't return any info if trying to remove a
non-existant map. If used with --v it will print eg.:

$ g.remove rast=dummy --v
REMOVE [dummy]
raster MISSING
header MISSING
category MISSING
color MISSING
history MISSING
misc MISSING
fcell MISSING
g3dcell MISSING

as it used before introducing --q and --v. But if --v is not
explicitely set (default), it will remain silent.

It should print "ERROR: raster map <dummy> not found" instead.

Specifying a map which doesn't exist (one with no elements) has never
been an error. At most, it should generate a warning if no elements
are found.

--
Glynn Clements <glynn@gclements.plus.com>

Glynn Clements wrote:

Maciej Sieczka wrote:

Propably due to the recent work on --v and --q flags (great stuff, many
thanks to the authors!), r.mapcalc doesn't print any progress indicator
anymore.

AFAIK, modules are quiet by default now. If you want verbosity (e.g.
progress indication) you have to enable it.

I didn't realize that quiet mode implies no progress indicator. In that
case verbose should be the default IMO, because we can't leave users
without a feedback from the module progress unless they implicitely
requests that. Am I wrong?

As r.mapcalc doesn't use G_parser(), --v won't work; you would need to
set GRASS_VERBOSE.

There probably needs to be a "stub" version of G_parser() which
implements the built-in switches (--help, --verbose etc) but doesn't
attempt to parse the entire command line.

Changing the syntax of r.mapcalc to conform to the normal convention
would probably be too radical a change. While we can fix our own
scripts, there are likely to be a lot of home-grown scripts which
would be broken (not to mention users who are accustomed to using the
existing syntax from the command line).

If verbose would be the default that would also fix the problem of
no-progress in r.mapcalc by default.

Also g.remove doesn't return any info if trying to remove a
non-existant map. If used with --v it will print eg.:

$ g.remove rast=dummy --v
REMOVE [dummy]
raster MISSING
header MISSING
category MISSING
color MISSING
history MISSING
misc MISSING
fcell MISSING
g3dcell MISSING

as it used before introducing --q and --v. But if --v is not
explicitely set (default), it will remain silent.

It should print "ERROR: raster map <dummy> not found" instead.

Specifying a map which doesn't exist (one with no elements) has never
been an error.

Not really, it is an error in case of vectors already. Try this:

$ g.remove vect=dummy

you'll get:

ERROR: Vector map <dummy> not found

$ echo $?
1

At most, it should generate a warning if no elements
are found.

Why shouldn't it generate an error? The user is trying to use a
non-existant map for the g.remove input. Other modules return an error
in such case. g.remove vect does the same. But g.remove
rast/rast3d/region/group doesn't. Shouldn't they conform?

Also, in the verbose mode, only a single-line information like "Raster
map <dummy> removed" should be printed insated of the current 9 lines:

$ g.remove rast=dummy --v
REMOVE [dummy]
raster
header
category
color MISSING
history
misc
fcell MISSING
g3dcell MISSING

BTW, I'd like to ask again what is the g3dcell?

Talking of g.remove - could the following types should be disposed in
GRASS 7?:

1. sites - there is no sites functionality in Grass>=5.7
2. region3d - 3D region settings have been merged into region
3. 3dview - remainment of Grass <5.7 3d.view command
4? icon - I don't know, propably too? what is it?
5. oldvect
6. asciivect

Same applies to g.copy/rename/list

?

Maciek

Maciej Sieczka wrote:

>> Propably due to the recent work on --v and --q flags (great stuff,
>> many thanks to the authors!), r.mapcalc doesn't print any progress
>> indicator anymore.

> AFAIK, modules are quiet by default now. If you want verbosity (e.g.
> progress indication) you have to enable it.

I didn't realize that quiet mode implies no progress indicator. In
that case verbose should be the default IMO, because we can't leave
users without a feedback from the module progress unless they
implicitely requests that. Am I wrong?

(not sure if I fully understand the current mode, sorry I haven't been
following this thread, but from observation, ...)

I think it is wrong to make all modules --quiet be default. Many years
of tuning have gone into the current message level, we just throw that
out? Sure some modules are very noisy and that should be dealt with
(remove useless noise and move debug info to G_debug()).

IMO the "only create output if something interesting happens"
guideline should only apply to UNIX-like small "do one thing well"
modules. Quick little modules used in a script (ie in a loop) can be
made a bit quieter, sure.

But for long running modules like v.surf.rst and r.sun, we should
definitely let the user know what's going on, what mode the module is
running in, how many points used for processing, etc. Anything which is
expected to take longer than about 10 seconds under normal conditions
should at least give G_percent() output IMO.

This is especially important for new users who are not confident or
knowledgeable about what is going on or how long it will take.

Hiding all G_message() and G_percent() output *by default* is totally
nuts. Adding --quiet or GRASS_VERBOSE=0 isn't hard if you are writing a
script or GUI frontend.

It's great to have the fine grained control, but I suggest this change:

Index: verbose.c

RCS file: /home/grass/grassrepository/grass6/lib/gis/verbose.c,v
retrieving revision 2.3
diff -u -r2.3 verbose.c
--- verbose.c 25 Sep 2006 09:43:09 -0000 2.3
+++ verbose.c 8 Oct 2006 11:52:26 -0000
@@ -46,7 +46,7 @@
                 ;
         }
         else
- verbose = MINLEVEL;
+ verbose = MAXLEVEL;
     }
     return verbose;
}

2c,
Hamish

ps -
in verbose.c, is this test correct?

static int verbose;
G_verbose() {
..
    /* verbose not defined -> get it from env. */
    if ( !verbose ) {
..
}

so it gets read from GRASS_VERBOSE not only if its unset but also if
it happens to be at MINLEVEL?

Maciej Sieczka wrote:

$ g.remove rast=dummy --v
REMOVE [dummy]

..

g3dcell MISSING

BTW, I'd like to ask again what is the g3dcell?

3D raster map created with r3.*
?

Talking of g.remove - could the following types should be disposed in
GRASS 7?:

1. sites - there is no sites functionality in Grass>=5.7

actually there is, see lib/sites/README
by 7.0 this may be gone though.

4? icon - I don't know, propably too? what is it?

this should stay. A user (without write access to $GISBASE) can have their
own vector symbols in their a mapset. (icon=basic/circle and friends)
probably change the name to symbol.

5. oldvect

backwards compatibility with GRASS 5, keep as long as we keep v.convert.

6. asciivect

v.out.ascii / v.in.ascii used to store format=standard data in a folder
in the mapset. keep for backwards compatibility with GRASS 5, keep as
long as we keep v.convert.

Same applies to g.copy/rename/list

types should be listed in g.list help page.

Hamish

Hamish wrote:

Maciej Sieczka wrote:

$ g.remove rast=dummy --v
REMOVE [dummy]

.

g3dcell MISSING

BTW, I'd like to ask again what is the g3dcell?

3D raster map created with r3.*
?

I think not. Create a rast3d and rast maps of the same name 'dummy'.
Although rast3d 'dummy' is present, g.remove rast=dummy still prints
"g3dcell MISSING"

Why would rast3d be listed in 'g.remove *rast*' output anyway?

Talking of g.remove - could the following types should be disposed in
GRASS 7?:

1. sites - there is no sites functionality in Grass>=5.7

actually there is, see lib/sites/README
by 7.0 this may be gone though.

My bad (there is even v.in.sites in Grass 6).

4? icon - I don't know, propably too? what is it?

this should stay. A user (without write access to $GISBASE) can have their
own vector symbols in their a mapset. (icon=basic/circle and friends)
probably change the name to symbol.

Where exactly in the mapset can be icons stored?

What are the Grass commands to create those icons? I mean - if there
are none, either in Grass 5 or 6, there also shouldn't be a command
for... removing them.

5. oldvect

backwards compatibility with GRASS 5, keep as long as we keep v.convert.

6. asciivect

v.out.ascii / v.in.ascii used to store format=standard data in a folder
in the mapset. keep for backwards compatibility with GRASS 5, keep as
long as we keep v.convert.

Same applies to g.copy/rename/list

types should be listed in g.list help page.

Or better there should be a general site with types described and each
g.copy/list/remove/rename should link to it.

Maciek

Maciej Sieczka wrote:

>> Propably due to the recent work on --v and --q flags (great stuff, many
>> thanks to the authors!), r.mapcalc doesn't print any progress indicator
>> anymore.

> AFAIK, modules are quiet by default now. If you want verbosity (e.g.
> progress indication) you have to enable it.

I didn't realize that quiet mode implies no progress indicator. In that
case verbose should be the default IMO, because we can't leave users
without a feedback from the module progress unless they implicitely
requests that. Am I wrong?

Yes. The normal behaviour for Unix command-line programs is not to
print anything unless something unexpected happens.

> Specifying a map which doesn't exist (one with no elements) has never
> been an error.

Not really, it is an error in case of vectors already. Try this:

$ g.remove vect=dummy

It has never been an error for rasters (or other types), and wasn't
for vectors until the vector subsystem was changed to the DBMI-backed
implementation.

The fact that it's now an error for vectors (and only vectors) is
essentially an oversight.

When vector maps ceased to be simply a collection of files, the
general/manage code needed to be modified for that specific case. If
you look at the code, you will note that most of it is "generic"; it
applies to any type of entity which is defined in the
$GISBASE/etc/element_list. Vectors are a hard-coded special case.

> At most, it should generate a warning if no elements
> are found.

Why shouldn't it generate an error? The user is trying to use a
non-existant map for the g.remove input. Other modules return an error
in such case. g.remove vect does the same. But g.remove
rast/rast3d/region/group doesn't. Shouldn't they conform?

Compatibility. Management commands are used extensively in scripts.

Apart from anything else, generating an error at the point that the
specific map is processed (the way that vectors are currently handled)
means that it won't even attempt to remove any subsequent maps. E.g.

  g.remove vect=vect1,vectnonexist,vect2

will abort on vectnonexist and won't attempt to remove vect2.

Also, in the verbose mode, only a single-line information like "Raster
map <dummy> removed" should be printed insated of the current 9 lines:

$ g.remove rast=dummy --v
REMOVE [dummy]
raster
header
category
color MISSING
history
misc
fcell MISSING
g3dcell MISSING

IMHO, verbose mode should display everything, quiet mode should
display a single warning for each map with no elements (i.e. the map
doesn't exist).

BTW, I'd like to ask again what is the g3dcell?

No idea.

Talking of g.remove - could the following types should be disposed in
GRASS 7?:

1. sites - there is no sites functionality in Grass>=5.7
2. region3d - 3D region settings have been merged into region
3. 3dview - remainment of Grass <5.7 3d.view command
4? icon - I don't know, propably too? what is it?
5. oldvect
6. asciivect

Same applies to g.copy/rename/list

Removing them from copy/rename seems reasonable enough. However you
might upgrade from 5.x to 6.x but still have 5.x entities left in the
database directories, so you need some way to remove them.

--
Glynn Clements <glynn@gclements.plus.com>

Hamish wrote:

> >> Propably due to the recent work on --v and --q flags (great stuff,
> >> many thanks to the authors!), r.mapcalc doesn't print any progress
> >> indicator anymore.
>
> > AFAIK, modules are quiet by default now. If you want verbosity (e.g.
> > progress indication) you have to enable it.
>
> I didn't realize that quiet mode implies no progress indicator. In
> that case verbose should be the default IMO, because we can't leave
> users without a feedback from the module progress unless they
> implicitely requests that. Am I wrong?

(not sure if I fully understand the current mode, sorry I haven't been
following this thread, but from observation, ...)

I think it is wrong to make all modules --quiet be default. Many years
of tuning have gone into the current message level, we just throw that
out?

I doubt that there has been any "tuning". Previously, modules wrote
out anything which the author thought might be useful to someone, on
the basis that the user can ignore what is displayed but can't see
something which isn't displayed. Unless a piece of information was
always displayed, it simply wasn't available.

ps -
in verbose.c, is this test correct?

No.

static int verbose;
G_verbose() {
..
    /* verbose not defined -> get it from env. */
    if ( !verbose ) {
..
}

so it gets read from GRASS_VERBOSE not only if its unset but also if
it happens to be at MINLEVEL?

It should initialise verbose to -1 then check "if (verbose < 0) ..."
instead.

--
Glynn Clements <glynn@gclements.plus.com>

Hi,

I agree, default verbose level should be set to MAXLEVEL (--v) ...

Martin

2006/10/8, Hamish <hamish_nospam@yahoo.com>:

Maciej Sieczka wrote:

> >> Propably due to the recent work on --v and --q flags (great stuff,
> >> many thanks to the authors!), r.mapcalc doesn't print any progress
> >> indicator anymore.
>
> > AFAIK, modules are quiet by default now. If you want verbosity (e.g.
> > progress indication) you have to enable it.
>
> I didn't realize that quiet mode implies no progress indicator. In
> that case verbose should be the default IMO, because we can't leave
> users without a feedback from the module progress unless they
> implicitely requests that. Am I wrong?

(not sure if I fully understand the current mode, sorry I haven't been
following this thread, but from observation, ...)

I think it is wrong to make all modules --quiet be default. Many years
of tuning have gone into the current message level, we just throw that
out? Sure some modules are very noisy and that should be dealt with
(remove useless noise and move debug info to G_debug()).

IMO the "only create output if something interesting happens"
guideline should only apply to UNIX-like small "do one thing well"
modules. Quick little modules used in a script (ie in a loop) can be
made a bit quieter, sure.

But for long running modules like v.surf.rst and r.sun, we should
definitely let the user know what's going on, what mode the module is
running in, how many points used for processing, etc. Anything which is
expected to take longer than about 10 seconds under normal conditions
should at least give G_percent() output IMO.

This is especially important for new users who are not confident or
knowledgeable about what is going on or how long it will take.

Hiding all G_message() and G_percent() output *by default* is totally
nuts. Adding --quiet or GRASS_VERBOSE=0 isn't hard if you are writing a
script or GUI frontend.

It's great to have the fine grained control, but I suggest this change:

Index: verbose.c

RCS file: /home/grass/grassrepository/grass6/lib/gis/verbose.c,v
retrieving revision 2.3
diff -u -r2.3 verbose.c
--- verbose.c 25 Sep 2006 09:43:09 -0000 2.3
+++ verbose.c 8 Oct 2006 11:52:26 -0000
@@ -46,7 +46,7 @@
                 ;
         }
         else
- verbose = MINLEVEL;
+ verbose = MAXLEVEL;
     }
     return verbose;
}

2c,
Hamish

ps -
in verbose.c, is this test correct?

static int verbose;
G_verbose() {
..
    /* verbose not defined -> get it from env. */
    if ( !verbose ) {
..
}

so it gets read from GRASS_VERBOSE not only if its unset but also if
it happens to be at MINLEVEL?

_______________________________________________
grass-dev mailing list
grass-dev@grass.itc.it
http://grass.itc.it/mailman/listinfo/grass-dev

--
Martin Landa <landa.martin@gmail.com> * http://gama.fsv.cvut.cz/~landa *

Glynn Clements wrote:

Maciej Sieczka wrote:

Propably due to the recent work on --v and --q flags (great stuff, many
thanks to the authors!), r.mapcalc doesn't print any progress indicator
anymore.

AFAIK, modules are quiet by default now. If you want verbosity (e.g.
progress indication) you have to enable it.

I didn't realize that quiet mode implies no progress indicator. In that
case verbose should be the default IMO, because we can't leave users
without a feedback from the module progress unless they implicitely
requests that. Am I wrong?

Yes. The normal behaviour for Unix command-line programs is not to
print anything unless something unexpected happens.

GRASS modules are not 'normal UNIX programs'. A user must be informed
if there's a progress. Otherwise he will not even know if the module
freezed or what. I fully second what Hamish says in this regard (in his
post in this thread).

Specifying a map which doesn't exist (one with no elements) has never
been an error.

Not really, it is an error in case of vectors already. Try this:

$ g.remove vect=dummy

It has never been an error for rasters (or other types), and wasn't
for vectors until the vector subsystem was changed to the DBMI-backed
implementation.

The fact that it's now an error for vectors (and only vectors) is
essentially an oversight.

When vector maps ceased to be simply a collection of files, the
general/manage code needed to be modified for that specific case. If
you look at the code, you will note that most of it is "generic"; it
applies to any type of entity which is defined in the
$GISBASE/etc/element_list. Vectors are a hard-coded special case.

At most, it should generate a warning if no elements
are found.

Why shouldn't it generate an error? The user is trying to use a
non-existant map for the g.remove input. Other modules return an error
in such case. g.remove vect does the same. But g.remove
rast/rast3d/region/group doesn't. Shouldn't they conform?

Compatibility. Management commands are used extensively in scripts.

Apart from anything else, generating an error at the point that the
specific map is processed (the way that vectors are currently handled)
means that it won't even attempt to remove any subsequent maps. E.g.

  g.remove vect=vect1,vectnonexist,vect2

will abort on vectnonexist and won't attempt to remove vect2.

Fine. Then g.remove vect should be fixed to behave like the other
types, and a non-fatal "WARNING: Vector map <dummy> not found" shoud be
issued if needed. Same for all other types. And, most importantly,
those warnings should issued by default, unless the user requests
g.remove to run quietly (which implies that a verbose mode should be
the default). Otherwise the user will not know that the map he tried to
remove doesn't exist.

Also, in the verbose mode, only a single-line information like "Raster
map <dummy> removed" should be printed insated of the current 9 lines:

$ g.remove rast=dummy --v
REMOVE [dummy]
raster
header
category
color MISSING
history
misc
fcell MISSING
g3dcell MISSING

IMHO, verbose mode should display everything, quiet mode should
display a single warning for each map with no elements (i.e. the map
doesn't exist).

But all those lines: raster, header, category, color, history, misc,
fcell are meaningless for a normal user. He should only be told that
"Raster map <blahblah> was removed". Why does one need to read all
those lines anyway? They don't give any usefull information but
distract and occupy space on the terminal. They should be displayed
only at a higher DEBUG level.

g3dcell MISSING

BTW, I'd like to ask again what is the g3dcell?

No idea.

Could it be removed then?

Talking of g.remove - could the following types should be disposed in
GRASS 7?:

1. sites - there is no sites functionality in Grass>=5.7
2. region3d - 3D region settings have been merged into region
3. 3dview - remainment of Grass <5.7 3d.view command
4? icon - I don't know, propably too? what is it?
5. oldvect
6. asciivect

Same applies to g.copy/rename/list

Removing them from copy/rename seems reasonable enough. However you
might upgrade from 5.x to 6.x

I'm talking about GRASS 7.

but still have 5.x entities left in the database directories, so
you need some way to remove them.

The question might be: is GRASS 7 supposed to provide tools to make the
switch from GRASS 5 easy, like GRASS 6 does?

Maciek

... I meant that all G_percent () and G_message () output should be
printed by default (in the current verbose implementation it is
MAXLEVEL).

* Currently, there are 3 levels of verbosity:
* \param 0 - module should print nothing but errors and warnings
(G_fatal_error, G_warning)
* \param 1 - module will print progress information (G_percent)
* \param 2 - module will print all messages (G_message)

Martin

2006/10/8, Martin Landa <landa.martin@gmail.com>:

Hi,

I agree, default verbose level should be set to MAXLEVEL (--v) ...

Martin

2006/10/8, Hamish <hamish_nospam@yahoo.com>:
> Maciej Sieczka wrote:
>
> > >> Propably due to the recent work on --v and --q flags (great stuff,
> > >> many thanks to the authors!), r.mapcalc doesn't print any progress
> > >> indicator anymore.
> >
> > > AFAIK, modules are quiet by default now. If you want verbosity (e.g.
> > > progress indication) you have to enable it.
> >
> > I didn't realize that quiet mode implies no progress indicator. In
> > that case verbose should be the default IMO, because we can't leave
> > users without a feedback from the module progress unless they
> > implicitely requests that. Am I wrong?
>
> (not sure if I fully understand the current mode, sorry I haven't been
> following this thread, but from observation, ...)
>
> I think it is wrong to make all modules --quiet be default. Many years
> of tuning have gone into the current message level, we just throw that
> out? Sure some modules are very noisy and that should be dealt with
> (remove useless noise and move debug info to G_debug()).
>
> IMO the "only create output if something interesting happens"
> guideline should only apply to UNIX-like small "do one thing well"
> modules. Quick little modules used in a script (ie in a loop) can be
> made a bit quieter, sure.
>
> But for long running modules like v.surf.rst and r.sun, we should
> definitely let the user know what's going on, what mode the module is
> running in, how many points used for processing, etc. Anything which is
> expected to take longer than about 10 seconds under normal conditions
> should at least give G_percent() output IMO.
>
> This is especially important for new users who are not confident or
> knowledgeable about what is going on or how long it will take.
>
> Hiding all G_message() and G_percent() output *by default* is totally
> nuts. Adding --quiet or GRASS_VERBOSE=0 isn't hard if you are writing a
> script or GUI frontend.
>
> It's great to have the fine grained control, but I suggest this change:
>
> Index: verbose.c
> ===================================================================
> RCS file: /home/grass/grassrepository/grass6/lib/gis/verbose.c,v
> retrieving revision 2.3
> diff -u -r2.3 verbose.c
> --- verbose.c 25 Sep 2006 09:43:09 -0000 2.3
> +++ verbose.c 8 Oct 2006 11:52:26 -0000
> @@ -46,7 +46,7 @@
> ;
> }
> else
> - verbose = MINLEVEL;
> + verbose = MAXLEVEL;
> }
> return verbose;
> }
>
> 2c,
> Hamish
>
> ps -
> in verbose.c, is this test correct?
>
> static int verbose;
> G_verbose() {
> ..
> /* verbose not defined -> get it from env. */
> if ( !verbose ) {
> ..
> }
>
> so it gets read from GRASS_VERBOSE not only if its unset but also if
> it happens to be at MINLEVEL?
>
> _______________________________________________
> grass-dev mailing list
> grass-dev@grass.itc.it
> http://grass.itc.it/mailman/listinfo/grass-dev
>

--
Martin Landa <landa.martin@gmail.com> * http://gama.fsv.cvut.cz/~landa *

--
Martin Landa <landa.martin@gmail.com> * http://gama.fsv.cvut.cz/~landa *

Hi,

trying to cleanup g.remove module I have prepared the patch. Is it OK
for you? Any comments welcomed...

Best regards, Martin

2006/10/8, Maciej Sieczka <tutey@o2.pl>:

Glynn Clements wrote:

> Maciej Sieczka wrote:

>> Propably due to the recent work on --v and --q flags (great stuff, many
>> thanks to the authors!), r.mapcalc doesn't print any progress indicator
>> anymore.

> AFAIK, modules are quiet by default now. If you want verbosity (e.g.
> progress indication) you have to enable it.

I didn't realize that quiet mode implies no progress indicator. In that
case verbose should be the default IMO, because we can't leave users
without a feedback from the module progress unless they implicitely
requests that. Am I wrong?

> As r.mapcalc doesn't use G_parser(), --v won't work; you would need to
> set GRASS_VERBOSE.
>
> There probably needs to be a "stub" version of G_parser() which
> implements the built-in switches (--help, --verbose etc) but doesn't
> attempt to parse the entire command line.
>
> Changing the syntax of r.mapcalc to conform to the normal convention
> would probably be too radical a change. While we can fix our own
> scripts, there are likely to be a lot of home-grown scripts which
> would be broken (not to mention users who are accustomed to using the
> existing syntax from the command line).

If verbose would be the default that would also fix the problem of
no-progress in r.mapcalc by default.

>> Also g.remove doesn't return any info if trying to remove a
>> non-existant map. If used with --v it will print eg.:
>>
>> $ g.remove rast=dummy --v
>> REMOVE [dummy]
>> raster MISSING
>> header MISSING
>> category MISSING
>> color MISSING
>> history MISSING
>> misc MISSING
>> fcell MISSING
>> g3dcell MISSING
>>
>> as it used before introducing --q and --v. But if --v is not
>> explicitely set (default), it will remain silent.
>>
>> It should print "ERROR: raster map <dummy> not found" instead.

> Specifying a map which doesn't exist (one with no elements) has never
> been an error.

Not really, it is an error in case of vectors already. Try this:

$ g.remove vect=dummy

you'll get:

ERROR: Vector map <dummy> not found

$ echo $?
1

> At most, it should generate a warning if no elements
> are found.

Why shouldn't it generate an error? The user is trying to use a
non-existant map for the g.remove input. Other modules return an error
in such case. g.remove vect does the same. But g.remove
rast/rast3d/region/group doesn't. Shouldn't they conform?

Also, in the verbose mode, only a single-line information like "Raster
map <dummy> removed" should be printed insated of the current 9 lines:

$ g.remove rast=dummy --v
REMOVE [dummy]
raster
header
category
color MISSING
history
misc
fcell MISSING
g3dcell MISSING

BTW, I'd like to ask again what is the g3dcell?

Talking of g.remove - could the following types should be disposed in
GRASS 7?:

1. sites - there is no sites functionality in Grass>=5.7
2. region3d - 3D region settings have been merged into region
3. 3dview - remainment of Grass <5.7 3d.view command
4? icon - I don't know, propably too? what is it?
5. oldvect
6. asciivect

Same applies to g.copy/rename/list

?

Maciek

_______________________________________________
grass-dev mailing list
grass-dev@grass.itc.it
http://grass.itc.it/mailman/listinfo/grass-dev

--
Martin Landa <landa.martin@gmail.com> * http://gama.fsv.cvut.cz/~landa *

(attachments)

g_remove.diff.gz (2.09 KB)

On Mon, 9 Oct 2006, Hamish wrote:

I think it is wrong to make all modules --quiet be default. Many years
of tuning have gone into the current message level, we just throw that
out? Sure some modules are very noisy and that should be dealt with
(remove useless noise and move debug info to G_debug()).

IMO the "only create output if something interesting happens"
guideline should only apply to UNIX-like small "do one thing well"
modules. Quick little modules used in a script (ie in a loop) can be
made a bit quieter, sure.

But for long running modules like v.surf.rst and r.sun, we should
definitely let the user know what's going on, what mode the module is
running in, how many points used for processing, etc. Anything which is
expected to take longer than about 10 seconds under normal conditions
should at least give G_percent() output IMO.

This is especially important for new users who are not confident or
knowledgeable about what is going on or how long it will take.

Hiding all G_message() and G_percent() output *by default* is totally
nuts. Adding --quiet or GRASS_VERBOSE=0 isn't hard if you are writing a
script or GUI frontend.

I agree with all this - it's what I was trying to say when Jachym first proposed this and I suggested a --quiet flag would be better to have than --verbose (i.e. keep the current output as default but allow frontends that need to run modules in quiet to achieve that), but I couldn't find the words to express myself very well and so gave up replying to the thread :confused: I'm surprised more people didn't object at the time; FWIW it's worth I just have trouble with the idea of treating GRASS modules as normal Unix programs that only emit output when there's an error.

Paul

Maciej Sieczka wrote:

>>>> Propably due to the recent work on --v and --q flags (great stuff, many
>>>> thanks to the authors!), r.mapcalc doesn't print any progress indicator
>>>> anymore.
>>> AFAIK, modules are quiet by default now. If you want verbosity (e.g.
>>> progress indication) you have to enable it.

>> I didn't realize that quiet mode implies no progress indicator. In that
>> case verbose should be the default IMO, because we can't leave users
>> without a feedback from the module progress unless they implicitely
>> requests that. Am I wrong?

> Yes. The normal behaviour for Unix command-line programs is not to
> print anything unless something unexpected happens.

GRASS modules are not 'normal UNIX programs'. A user must be informed
if there's a progress. Otherwise he will not even know if the module
freezed or what. I fully second what Hamish says in this regard (in his
post in this thread).

On that, we'll just have to disagree. It isn't important, as the user
can just set GRASS_VERBOSE explicitly if the default value isn't to
their liking.

> Apart from anything else, generating an error at the point that the
> specific map is processed (the way that vectors are currently handled)
> means that it won't even attempt to remove any subsequent maps. E.g.
>
> g.remove vect=vect1,vectnonexist,vect2
>
> will abort on vectnonexist and won't attempt to remove vect2.

Fine. Then g.remove vect should be fixed to behave like the other
types, and a non-fatal "WARNING: Vector map <dummy> not found" shoud be
issued if needed. Same for all other types. And, most importantly,
those warnings should issued by default, unless the user requests
g.remove to run quietly (which implies that a verbose mode should be
the default). Otherwise the user will not know that the map he tried to
remove doesn't exist.

Warnings are supposed to be issued even at minimum verbosity. It's the
more detailed output which needs to vary according the verbosity
settings.

>> Also, in the verbose mode, only a single-line information like "Raster
>> map <dummy> removed" should be printed insated of the current 9 lines:
>>
>> $ g.remove rast=dummy --v
>> REMOVE [dummy]
>> raster
>> header
>> category
>> color MISSING
>> history
>> misc
>> fcell MISSING
>> g3dcell MISSING

> IMHO, verbose mode should display everything, quiet mode should
> display a single warning for each map with no elements (i.e. the map
> doesn't exist).

But all those lines: raster, header, category, color, history, misc,
fcell are meaningless for a normal user. He should only be told that
"Raster map <blahblah> was removed". Why does one need to read all
those lines anyway? They don't give any usefull information but
distract and occupy space on the terminal. They should be displayed
only at a higher DEBUG level.

In retrospect, I agree that those should be considered "debug"
information. Historically, they have been the only way to discover
that a map is entirely absent.

BTW, etc/element_list doesn't distinguish between "core" elements
(e.g. cellhd, cell etc) and ancilliary elements (history, color etc).
Ideally, it shouldn't be possible to have the latter without the
former, but I wouldn't assume that it's completely impossible in
practice.

For now, I think we'll have to be satisfied with distinguishing
between zero elements existing and one or more elements existing,
regardless of the signficance of the elements.

>>> g3dcell MISSING

>> BTW, I'd like to ask again what is the g3dcell?

> No idea.

Could it be removed then?

No idea.

>> Talking of g.remove - could the following types should be disposed in
>> GRASS 7?:
>>
>> 1. sites - there is no sites functionality in Grass>=5.7
>> 2. region3d - 3D region settings have been merged into region
>> 3. 3dview - remainment of Grass <5.7 3d.view command
>> 4? icon - I don't know, propably too? what is it?
>> 5. oldvect
>> 6. asciivect
>>
>> Same applies to g.copy/rename/list

> Removing them from copy/rename seems reasonable enough. However you
> might upgrade from 5.x to 6.x

I'm talking about GRASS 7.

> but still have 5.x entities left in the database directories, so
> you need some way to remove them.

The question might be: is GRASS 7 supposed to provide tools to make the
switch from GRASS 5 easy, like GRASS 6 does?

I see no reason to remove that functionality, given that it's
essentially a few lines in the element_list file. None of this is
actually coded.

--
Glynn Clements <glynn@gclements.plus.com>

Martin Landa wrote:

trying to cleanup g.remove module I have prepared the patch. Is it OK
for you? Any comments welcomed...

Rather than hard-coding checks for specific entity types:

+ if (G_strcasecmp(list[n].alias, "rast") == 0 ) {
+ if ((mapset = G_find_cell2 (old, "")) == NULL) {
+ G_warning(_("Raster map <%s> not found"), old);
+ result = 1;
+ }
+ }
+
+ if (G_strcasecmp(list[n].alias, "rast3d") == 0 ) {
+ if ((mapset = G_find_grid3 (old, "")) == NULL) {
+ G_warning(_("Raster 3d map <%s> not found"), old);
+ result = 1;
+ }
+ }

I would add a flag which is initially cleared for each entity (map
etc) and set when an element is actually removed. A warning would be
generated if the flag is still clear when all of the elements for an
entity have been processed.

E.g.:

+ removed = 0;
   for (i = 0; i < list[n].nelem; i++) {
       switch (G_remove (list[n].element[i], old))
       {
       case -1:
- G_warning (" %-*s %s", len, list[n].desc[i],_("COULD NOT REMOVE"));
+ G_warning ("%s: %s", list[n].desc[i],_("couldn't be removed"));
           result = 1;
     break;
       case 0:
- G_message (" %-*s %s", len, list[n].desc[i],_("MISSING"));
+ G_debug (1, "%s: %s", list[n].desc[i],_("missing"));
     break;
       case 1:
- G_message (" %-*s ", len, list[n].desc[i]);
+ G_debug (1, "%s: %s", list[n].desc[i],_("removed"));
+ removed = 1;
     break;
       }
   }
+
+ if (!removed)
+ G_warning ("%s: %s", list[n].desc[i],_("nothing removed"));

--
Glynn Clements <glynn@gclements.plus.com>

hi,

was this patch commited to cvs ?

thanks

jachym

On Mon, Oct 09, 2006 at 11:28:05AM +0100, Glynn Clements wrote:

Martin Landa wrote:

> trying to cleanup g.remove module I have prepared the patch. Is it OK
> for you? Any comments welcomed...

Rather than hard-coding checks for specific entity types:

+ if (G_strcasecmp(list[n].alias, "rast") == 0 ) {
+ if ((mapset = G_find_cell2 (old, "")) == NULL) {
+ G_warning(_("Raster map <%s> not found"), old);
+ result = 1;
+ }
+ }
+
+ if (G_strcasecmp(list[n].alias, "rast3d") == 0 ) {
+ if ((mapset = G_find_grid3 (old, "")) == NULL) {
+ G_warning(_("Raster 3d map <%s> not found"), old);
+ result = 1;
+ }
+ }

I would add a flag which is initially cleared for each entity (map
etc) and set when an element is actually removed. A warning would be
generated if the flag is still clear when all of the elements for an
entity have been processed.

E.g.:

+ removed = 0;
   for (i = 0; i < list[n].nelem; i++) {
       switch (G_remove (list[n].element[i], old))
       {
       case -1:
- G_warning (" %-*s %s", len, list[n].desc[i],_("COULD NOT REMOVE"));
+ G_warning ("%s: %s", list[n].desc[i],_("couldn't be removed"));
           result = 1;
     break;
       case 0:
- G_message (" %-*s %s", len, list[n].desc[i],_("MISSING"));
+ G_debug (1, "%s: %s", list[n].desc[i],_("missing"));
     break;
       case 1:
- G_message (" %-*s ", len, list[n].desc[i]);
+ G_debug (1, "%s: %s", list[n].desc[i],_("removed"));
+ removed = 1;
     break;
       }
   }
+
+ if (!removed)
+ G_warning ("%s: %s", list[n].desc[i],_("nothing removed"));

--
Glynn Clements <glynn@gclements.plus.com>

_______________________________________________
grass-dev mailing list
grass-dev@grass.itc.it
http://grass.itc.it/mailman/listinfo/grass-dev

--
Jachym Cepicky
e-mail: jachym.cepicky@centrum.cz
URL: http://les-ejk.cz
GPG: http://les-ejk.cz/gnupg_public_key/jachym_cepicky-gpg_public_key.asc
-----------------------------------------
OFFICE:
Department of Geoinformation Technologies
Zemedelska 3
613 00, Brno
Czech Republick
e-mail: xcepicky@node.mendelu.cz
URL: http://mapserver.mendelu.cz
Tel.: +420 545 134 514

hallo,

On Mon, Oct 09, 2006 at 01:04:14AM +1300, Hamish wrote:

- verbose = MINLEVEL;
+ verbose = MAXLEVEL;

I agree

ps -
in verbose.c, is this test correct?

static int verbose;
G_verbose() {
..
    /* verbose not defined -> get it from env. */
    if ( !verbose ) {
..
}

so it gets read from GRASS_VERBOSE not only if its unset but also if
it happens to be at MINLEVEL?

no, sorry, this is not correct. as glyn writes, it should be initialized
to -1 and the test should look like

    if ( verbose < 0 )

could you commit this changes, or should I?

thank you

jachym

--
Jachym Cepicky
e-mail: jachym.cepicky@centrum.cz
URL: http://les-ejk.cz
GPG: http://les-ejk.cz/gnupg_public_key/jachym_cepicky-gpg_public_key.asc
-----------------------------------------
OFFICE:
Department of Geoinformation Technologies
Zemedelska 3
613 00, Brno
Czech Republick
e-mail: xcepicky@node.mendelu.cz
URL: http://mapserver.mendelu.cz
Tel.: +420 545 134 514

Hi,

thanks Glynn!, modified patch applied in CVS.

Best regards, Martin

2006/10/9, Glynn Clements <glynn@gclements.plus.com>:

Martin Landa wrote:

> trying to cleanup g.remove module I have prepared the patch. Is it OK
> for you? Any comments welcomed...

Rather than hard-coding checks for specific entity types:

+ if (G_strcasecmp(list[n].alias, "rast") == 0 ) {
+ if ((mapset = G_find_cell2 (old, "")) == NULL) {
+ G_warning(_("Raster map <%s> not found"), old);
+ result = 1;
+ }
+ }
+
+ if (G_strcasecmp(list[n].alias, "rast3d") == 0 ) {
+ if ((mapset = G_find_grid3 (old, "")) == NULL) {
+ G_warning(_("Raster 3d map <%s> not found"), old);
+ result = 1;
+ }
+ }

I would add a flag which is initially cleared for each entity (map
etc) and set when an element is actually removed. A warning would be
generated if the flag is still clear when all of the elements for an
entity have been processed.

E.g.:

+ removed = 0;
        for (i = 0; i < list[n].nelem; i++) {
            switch (G_remove (list[n].element[i], old))
            {
            case -1:
- G_warning (" %-*s %s", len, list[n].desc[i],_("COULD NOT REMOVE"));
+ G_warning ("%s: %s", list[n].desc[i],_("couldn't be removed"));
                result = 1;
                break;
            case 0:
- G_message (" %-*s %s", len, list[n].desc[i],_("MISSING"));
+ G_debug (1, "%s: %s", list[n].desc[i],_("missing"));
                break;
            case 1:
- G_message (" %-*s ", len, list[n].desc[i]);
+ G_debug (1, "%s: %s", list[n].desc[i],_("removed"));
+ removed = 1;
                break;
            }
        }
+
+ if (!removed)
+ G_warning ("%s: %s", list[n].desc[i],_("nothing removed"));

--
Glynn Clements <glynn@gclements.plus.com>

--
Martin Landa <landa.martin@gmail.com> * http://gama.fsv.cvut.cz/~landa *

On Mon, Oct 09, 2006 at 06:39:01PM +0200, Martin Landa wrote:

Hi,

thanks Glynn!, modified patch applied in CVS.

Best regards, Martin

thanks you both!

jachym

--
Jachym Cepicky
e-mail: jachym.cepicky@centrum.cz
URL: http://les-ejk.cz
GPG: http://les-ejk.cz/gnupg_public_key/jachym_cepicky-gpg_public_key.asc
-----------------------------------------
OFFICE:
Department of Geoinformation Technologies
Zemedelska 3
613 00, Brno
Czech Republick
e-mail: xcepicky@node.mendelu.cz
URL: http://mapserver.mendelu.cz
Tel.: +420 545 134 514

Hi all,

please take a look at new behaviour of g.remove. If it is OK for you,
I will modify in this way g.copy/g.rename modules.

Best, Martin

2006/10/9, Martin Landa <landa.martin@gmail.com>:

Hi,

thanks Glynn!, modified patch applied in CVS.

Best regards, Martin

2006/10/9, Glynn Clements <glynn@gclements.plus.com>:
>
> Martin Landa wrote:
>
> > trying to cleanup g.remove module I have prepared the patch. Is it OK
> > for you? Any comments welcomed...
>
> Rather than hard-coding checks for specific entity types:
>
> + if (G_strcasecmp(list[n].alias, "rast") == 0 ) {
> + if ((mapset = G_find_cell2 (old, "")) == NULL) {
> + G_warning(_("Raster map <%s> not found"), old);
> + result = 1;
> + }
> + }
> +
> + if (G_strcasecmp(list[n].alias, "rast3d") == 0 ) {
> + if ((mapset = G_find_grid3 (old, "")) == NULL) {
> + G_warning(_("Raster 3d map <%s> not found"), old);
> + result = 1;
> + }
> + }
>
> I would add a flag which is initially cleared for each entity (map
> etc) and set when an element is actually removed. A warning would be
> generated if the flag is still clear when all of the elements for an
> entity have been processed.
>
> E.g.:
>
> + removed = 0;
> for (i = 0; i < list[n].nelem; i++) {
> switch (G_remove (list[n].element[i], old))
> {
> case -1:
> - G_warning (" %-*s %s", len, list[n].desc[i],_("COULD NOT REMOVE"));
> + G_warning ("%s: %s", list[n].desc[i],_("couldn't be removed"));
> result = 1;
> break;
> case 0:
> - G_message (" %-*s %s", len, list[n].desc[i],_("MISSING"));
> + G_debug (1, "%s: %s", list[n].desc[i],_("missing"));
> break;
> case 1:
> - G_message (" %-*s ", len, list[n].desc[i]);
> + G_debug (1, "%s: %s", list[n].desc[i],_("removed"));
> + removed = 1;
> break;
> }
> }
> +
> + if (!removed)
> + G_warning ("%s: %s", list[n].desc[i],_("nothing removed"));
>
> --
> Glynn Clements <glynn@gclements.plus.com>
>

--
Martin Landa <landa.martin@gmail.com> * http://gama.fsv.cvut.cz/~landa *

--
Martin Landa <landa.martin@gmail.com> * http://gama.fsv.cvut.cz/~landa *