[GRASS-user] result from g.copy when layer exists

Hi

I am a bit irritated, ut maybe I don't dee the reasoning behind this:'

,----
| RASS 7.0.svn (grass):~ > g.copy rast=MASK,tmp
| WARNING: <tmp> already exists
| [Raster MASK present]
| GRASS 7.0.svn (grass):~ >
`----

If the layer already exists, shouldn't the command give actually an
error and not only a warning?

A warning implies for me that the command worked, but maybe something
unexpected could have happened (or happened) - but this one clearly did
not work, as the layer has not been copied?

Cheers,

Rainer

--
Rainer M. Krug

email: RMKrug<at>gmail<dot>com

Rainer M Krug wrote:

I am a bit irritated, ut maybe I don't dee the reasoning behind this:'

,----
| RASS 7.0.svn (grass):~ > g.copy rast=MASK,tmp
| WARNING: <tmp> already exists
| [Raster MASK present]
| GRASS 7.0.svn (grass):~ >
`----

If the layer already exists, shouldn't the command give actually an
error and not only a warning?

A warning implies for me that the command worked, but maybe something
unexpected could have happened (or happened) - but this one clearly did
not work, as the layer has not been copied?

In GRASS, errors are fatal; the program will be terminated as soon as
the error message has been printed.

Each of g.copy's options accept an arbitray number of
source+destination pairs, and the various options aren't mutually
exclusive (e.g. a single invocation can copy both raster and vector
maps).

If it can't perform a particular copy for any reason, it generates a
warning then moves on to the next item.

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

Glynn Clements <glynn@gclements.plus.com> writes:

Rainer M Krug wrote:

I am a bit irritated, ut maybe I don't dee the reasoning behind this:'

,----
| RASS 7.0.svn (grass):~ > g.copy rast=MASK,tmp
| WARNING: <tmp> already exists
| [Raster MASK present]
| GRASS 7.0.svn (grass):~ >
`----

If the layer already exists, shouldn't the command give actually an
error and not only a warning?

A warning implies for me that the command worked, but maybe something
unexpected could have happened (or happened) - but this one clearly did
not work, as the layer has not been copied?

In GRASS, errors are fatal; the program will be terminated as soon as
the error message has been printed.

Exactly - if e.g. in r.mapcalc an invalid expression is entered,
r.mapcalc issues the error message and quits.

Each of g.copy's options accept an arbitray number of
source+destination pairs, and the various options aren't mutually
exclusive (e.g. a single invocation can copy both raster and vector
maps).

True.

If it can't perform a particular copy for any reason, it generates a
warning then moves on to the next item.

True - but this does not answer my question. But I looked at cp in bash,
and it behaves in the same way.
So I think I have to live with this.

Thanks,

Rainer

--
Rainer M. Krug

email: RMKrug<at>gmail<dot>com

Rainer MK wrote:

>> I am a bit irritated, ut maybe I don't dee the reasoning behind this:'

>> ,----
>> | RASS 7.0.svn (grass):~ > g.copy rast=MASK,tmp
>> | WARNING: <tmp> already exists
>> | [Raster MASK present]
>> | GRASS 7.0.svn (grass):~ >
>> `----

>> If the layer already exists, shouldn't the command give actually an
>> error and not only a warning?

>> A warning implies for me that the command worked, but maybe something
>> unexpected could have happened (or happened) - but this one clearly did
>> not work, as the layer has not been copied?

Glynn Clements:

> In GRASS, errors are fatal; the program will be terminated as soon as
> the error message has been printed.

Rainer MK:

Exactly - if e.g. in r.mapcalc an invalid expression is entered,
r.mapcalc issues the error message and quits.

> Each of g.copy's options accept an arbitray number of
> source+destination pairs, and the various options aren't mutually
> exclusive (e.g. a single invocation can copy both raster and vector
> maps).

True.

> If it can't perform a particular copy for any reason, it generates a
> warning then moves on to the next item.

True - but this does not answer my question. But I looked at cp in bash,
and it behaves in the same way.
So I think I have to live with this.

Just sharing my thoughts about: Imagine copying 1000 maps. And one is meant
to fail, say the 1st one of them. You wouldn't, probably, like the copy
process to be interrupted just for one map that failed. Right?

Greets, Nikos

Nikos Alexandris <nik@nikosalexandris.net> writes:

Rainer MK wrote:

>> I am a bit irritated, ut maybe I don't dee the reasoning behind this:'

>> ,----
>> | RASS 7.0.svn (grass):~ > g.copy rast=MASK,tmp
>> | WARNING: <tmp> already exists
>> | [Raster MASK present]
>> | GRASS 7.0.svn (grass):~ >
>> `----

>> If the layer already exists, shouldn't the command give actually an
>> error and not only a warning?

>> A warning implies for me that the command worked, but maybe something
>> unexpected could have happened (or happened) - but this one clearly did
>> not work, as the layer has not been copied?

Glynn Clements:

> In GRASS, errors are fatal; the program will be terminated as soon as
> the error message has been printed.

Rainer MK:

Exactly - if e.g. in r.mapcalc an invalid expression is entered,
r.mapcalc issues the error message and quits.

> Each of g.copy's options accept an arbitray number of
> source+destination pairs, and the various options aren't mutually
> exclusive (e.g. a single invocation can copy both raster and vector
> maps).

True.

> If it can't perform a particular copy for any reason, it generates a
> warning then moves on to the next item.

True - but this does not answer my question. But I looked at cp in bash,
and it behaves in the same way.
So I think I have to live with this.

Just sharing my thoughts about: Imagine copying 1000 maps. And one is meant
to fail, say the 1st one of them. You wouldn't, probably, like the copy
process to be interrupted just for one map that failed. Right?

Depends: when using in a script, I would like it to fail, as the
following commands might give wrong resuls as they would be based on the
previous map and not the copied one.

Also, in a script this could mean that previous commands did not clean
their temporary files properly - other cause for an interruption of the
script.

When doing it from the command prompt, I would say: just tell me which
ones failed - correct.

SO the best would be a flag which says "error on map exists".

Cheers,

Rainer

Greets, Nikos

--
Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany)

Centre of Excellence for Invasion Biology
Stellenbosch University
South Africa

Tel : +33 - (0)9 53 10 27 44
Cell: +33 - (0)6 85 62 59 98
Fax : +33 - (0)9 58 10 27 44

Fax (D): +49 - (0)3 21 21 25 22 44

email: Rainer@krugs.de

Skype: RMkrug

On Thu, Jul 18, 2013 at 1:57 PM, Rainer M Krug <Rainer@krugs.de> wrote:

Nikos Alexandris <nik@nikosalexandris.net> writes:

Rainer MK wrote:

>> I am a bit irritated, ut maybe I don't dee the reasoning behind this:'

>> ,----
>> | RASS 7.0.svn (grass):~ > g.copy rast=MASK,tmp
>> | WARNING: <tmp> already exists
>> | [Raster MASK present]
>> | GRASS 7.0.svn (grass):~ >
>> `----

>> If the layer already exists, shouldn't the command give actually an
>> error and not only a warning?

>> A warning implies for me that the command worked, but maybe something
>> unexpected could have happened (or happened) - but this one clearly did
>> not work, as the layer has not been copied?

Glynn Clements:

> In GRASS, errors are fatal; the program will be terminated as soon as
> the error message has been printed.

Rainer MK:

Exactly - if e.g. in r.mapcalc an invalid expression is entered,
r.mapcalc issues the error message and quits.

> Each of g.copy's options accept an arbitray number of
> source+destination pairs, and the various options aren't mutually
> exclusive (e.g. a single invocation can copy both raster and vector
> maps).

True.

> If it can't perform a particular copy for any reason, it generates a
> warning then moves on to the next item.

True - but this does not answer my question. But I looked at cp in bash,
and it behaves in the same way.
So I think I have to live with this.

Just sharing my thoughts about: Imagine copying 1000 maps. And one is meant
to fail, say the 1st one of them. You wouldn't, probably, like the copy
process to be interrupted just for one map that failed. Right?

Depends: when using in a script, I would like it to fail, as the
following commands might give wrong resuls as they would be based on the
previous map and not the copied one.

Also, in a script this could mean that previous commands did not clean
their temporary files properly - other cause for an interruption of the
script.

When doing it from the command prompt, I would say: just tell me which
ones failed - correct.

SO the best would be a flag which says "error on map exists".

The other way around: you can enforce copying (overwrite existing
maps) with g.copy --o

Markus M

Since we're talking about grass errors, is there a way to redirect the
warnings/errors ?

e.g. r.mapcalc "..." 2>error.log

On Fri, Jul 19, 2013 at 10:14 AM, Markus Metz
<markus.metz.giswork@gmail.com> wrote:

On Thu, Jul 18, 2013 at 1:57 PM, Rainer M Krug <Rainer@krugs.de> wrote:

Nikos Alexandris <nik@nikosalexandris.net> writes:

Rainer MK wrote:

>> I am a bit irritated, ut maybe I don't dee the reasoning behind this:'

>> ,----
>> | RASS 7.0.svn (grass):~ > g.copy rast=MASK,tmp
>> | WARNING: <tmp> already exists
>> | [Raster MASK present]
>> | GRASS 7.0.svn (grass):~ >
>> `----

>> If the layer already exists, shouldn't the command give actually an
>> error and not only a warning?

>> A warning implies for me that the command worked, but maybe something
>> unexpected could have happened (or happened) - but this one clearly did
>> not work, as the layer has not been copied?

Glynn Clements:

> In GRASS, errors are fatal; the program will be terminated as soon as
> the error message has been printed.

Rainer MK:

Exactly - if e.g. in r.mapcalc an invalid expression is entered,
r.mapcalc issues the error message and quits.

> Each of g.copy's options accept an arbitray number of
> source+destination pairs, and the various options aren't mutually
> exclusive (e.g. a single invocation can copy both raster and vector
> maps).

True.

> If it can't perform a particular copy for any reason, it generates a
> warning then moves on to the next item.

True - but this does not answer my question. But I looked at cp in bash,
and it behaves in the same way.
So I think I have to live with this.

Just sharing my thoughts about: Imagine copying 1000 maps. And one is meant
to fail, say the 1st one of them. You wouldn't, probably, like the copy
process to be interrupted just for one map that failed. Right?

Depends: when using in a script, I would like it to fail, as the
following commands might give wrong resuls as they would be based on the
previous map and not the copied one.

Also, in a script this could mean that previous commands did not clean
their temporary files properly - other cause for an interruption of the
script.

When doing it from the command prompt, I would say: just tell me which
ones failed - correct.

SO the best would be a flag which says "error on map exists".

The other way around: you can enforce copying (overwrite existing
maps) with g.copy --o

Markus M
_______________________________________________
grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user

Nick wrote:

Since we're talking about grass errors, is there a way to redirect the
warnings/errors ?

e.g. r.mapcalc "..." 2>error.log

see the GIS_ERROR_LOG file and/or environment variable.

http://grass.osgeo.org/grass64/manuals/variables.html#enviro

simply "touch ~/GIS_ERROR_LOG" and it will start keeping a log of
all warnings and errors.

I am slightly suspicious that some recent changes may have broken
that, but give it a try.

Hamish

Nick wrote:

> Since we're talking about grass errors, is there a way to redirect the
> warnings/errors ?
> e.g. r.mapcalc "..." 2>error.log

Hamish:

see the GIS_ERROR_LOG file and/or environment variable.
http://grass.osgeo.org/grass64/manuals/variables.html#enviro

simply "touch ~/GIS_ERROR_LOG" and it will start keeping a log of
all warnings and errors.

I am slightly suspicious that some recent changes may have broken
that, but give it a try.

Don't forget to remove it! I have a GIS_ERROR_LOG file, 186.6MiB dated back
in 09. 04. 2009 :D. It's nice to have some reference that/on what I was
messing around with GRASS-GIS back then...

Nikos