[GRASS-dev] [grass-code I][394] scripts using g.message fail if message contains "="

code I item #394, was opened at 2007-05-09 17:43
Status: Open
Priority: 5
Submitted By: Hamish Bowman (hamish)
Assigned to: Nobody (None)
Summary: scripts using g.message fail if message contains "="
Issue type: module bad feature
Issue status: None
GRASS version: CVS HEAD
GRASS component: None
Operating system: None
Operating system version:
GRASS CVS checkout date, if applies (YYMMDD):

Initial Comment:
Hi,

this may be "user error", but g.message will fail if the message contains a "=" char and message= was not given. With message= the parser understands it ok.

This is causing an error in a number of scripts. (I found it in wms.request)

G63 > g.message "foo="
Sorry, <foo> is not a valid parameter

ERROR: Required parameter <message> not set:
    (Text of the message to be printed).

Description:
Prints message, warning or fatal error the GRASS way. This module should be used in scripts for messages served to user.

Keywords:
general

Usage:
g.message [-wed] message=string [--verbose] [--quiet]

Flags:
  -w Print message as GRASS warning
  -e Print message as GRASS fatal error
  -d Print message as GRASS debug message (level 1)
--v Verbose module output
--q Quiet module output

Parameters:
  message Text of the message to be printed

G63> g.message message="foo="
foo=

scripts to check:
$ grep -rI g.message * | grep '='

d.out.png/d.out.png:g.message -d message="width = $curr_width height = $curr_height"

^^^ correct AFAICT.

d.vect.thematic/d.vect.thematic: g.message "Mapped by standard deviation units of $sd (mean =$mean)"
d.vect.thematic/d.vect.thematic: g.message "Mapped by standard deviation units of $sd (mean =$mean)"
d.vect.thematic/d.vect.thematic: g.message "Mapped by quartiles (median =$q2)"
i.fusion.brovey/i.fusion.brovey:g.message "g.region -p rast=$GIS_OPT_OUTPUTPREFIX.red ; d.erase"
i.fusion.brovey/i.fusion.brovey:g.message "d.rgb r=$GIS_OPT_OUTPUTPREFIX.red g=$GIS_OPT_OUTPUTPREFIX.green b=$GIS_OPT_OUTPUTPREFIX.blue"
i.in.spotvgt/i.in.spotvgt: g.message "Note: A snow map can be extracted by category 252 (d.rast $NAME.sm cat=252)"
i.in.spotvgt/.#i.in.spotvgt.1.13: g.message "Note: A snow map can be extracted by category 252 (d.rast $NAME.sm cat=252)"
m.proj/m.proj:g.message "input parameters=[$IN_PROJ]"
m.proj/m.proj:g.message "output parameters=[$OUT_PROJ]"
m.proj/m.proj: g.message "input file=[$infile]"
m.proj/m.proj: g.message "output file=[$outfile]"
r.blend/r.blend:g.message "d.rgb r=${GIS_OPT_OUTPUT}.r g=${GIS_OPT_OUTPUT}.g b=${GIS_OPT_OUTPUT}.b"
r.in.wms/wms.request: g.message "r.tileset -g sourceproj=\$PROJ4_SRS\ sourcescale=\$SRS_SCALE\ overlap=2 maxcols=${MAXCOLS} maxrows=${MAXROWS} $TILE
SET_OPTIONS"
r.mapcalculator/r.mapcalculator: g.message "r.mapcalc \$GIS_OPT_OUTFILE\ = \$command\ "
r.out.gdal/r.out.gdal.sh: g.message -e "(Raster map type is `r.info -t $INPUT | cut -d'=' -f2`)"
r.plane/r.plane:g.message "with dip=$dip degrees and aspect=$az degrees ccw from north"
r3.mapcalculator/r3.mapcalculator:g.message "r3.mapcalc \$GIS_OPT_OUTFILE\ = \$command\" # Show the resulting commandline
v.db.reconnect.all/v.db.reconnect.all: g.message "SCHEMA = $SCHEMA TABLE = $TABLE NEW_SCHEMA_TABLE=$NEW_SCHEMA_TABLE"
v.in.garmin/v.in.garmin: g.message "output=$NAME"
v.in.garmin/v.in.garmin: g.message "port=$GIS_OPT_PORT"
v.in.gpsbabel/v.in.gpsbabel: g.message "output=$NAME"
v.in.gpsbabel/v.in.gpsbabel: g.message "file=$GIS_OPT_INPUT"

Hamish

----------------------------------------------------------------------

You can respond by visiting:
http://wald.intevation.org/tracker/?func=detail&atid=204&aid=394&group_id=21

On Wed, May 09, 2007 at 07:43:27AM +0200, grass-codei@wald.intevation.org wrote:

code I item #394, was opened at 2007-05-09 17:43
Status: Open
Priority: 5
Submitted By: Hamish Bowman (hamish)
Assigned to: Nobody (None)
Summary: scripts using g.message fail if message contains "="
Issue type: module bad feature
Issue status: None
GRASS version: CVS HEAD
GRASS component: None
Operating system: None
Operating system version:
GRASS CVS checkout date, if applies (YYMMDD):

Initial Comment:
Hi,

this may be "user error", but g.message will fail if the message contains a "=" char and message= was not given. With message= the parser understands it ok.

This is causing an error in a number of scripts. (I found it in wms.request)

G63 > g.message "foo="
Sorry, <foo> is not a valid parameter

I observed a similar problem in my new v.in.wfs script
(get from http://mpa.itc.it/markus/grass63/): The WFS URL is
disliked by g.parser. I worked around this with ugly hacks but
I think that we need a new parameter type which accepts chars
such as '=', '&' and so forth. I used file,file,file in v.in.wfs
but would prefer something else.

Markus

Markus Neteler wrote:

On Wed, May 09, 2007 at 07:43:27AM +0200, grass-codei@wald.intevation.org wrote:
> code I item #394, was opened at 2007-05-09 17:43
> Status: Open
> Priority: 5
> Submitted By: Hamish Bowman (hamish)
> Assigned to: Nobody (None)
> Summary: scripts using g.message fail if message contains "="
> Issue type: module bad feature
> Issue status: None
> GRASS version: CVS HEAD
> GRASS component: None
> Operating system: None
> Operating system version:
> GRASS CVS checkout date, if applies (YYMMDD):
>
>
> Initial Comment:
> Hi,
>
> this may be "user error", but g.message will fail if the message contains a "=" char and message= was not given. With message= the parser understands it ok.
>
> This is causing an error in a number of scripts. (I found it in wms.request)
>
>
>
> G63 > g.message "foo="
> Sorry, <foo> is not a valid parameter

I observed a similar problem in my new v.in.wfs script
(get from http://mpa.itc.it/markus/grass63/): The WFS URL is
disliked by g.parser. I worked around this with ugly hacks but
I think that we need a new parameter type which accepts chars
such as '=', '&' and so forth. I used file,file,file in v.in.wfs
but would prefer something else.

If you don't set a gisprompt, the parser will accept any string.

BTW, r.in.wfs suffers from the same bug which Hamish mentions: failure
to specify message= explicitly.

I don't know why you think that you need the "$2" hack.

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

Markus Neteler wrote:

I observed a similar problem in my new v.in.wfs script
(get from http://mpa.itc.it/markus/grass63/): The WFS URL is
disliked by g.parser. I worked around this with ugly hacks but
I think that we need a new parameter type which accepts chars
such as '=', '&' and so forth. I used file,file,file in v.in.wfs
but would prefer something else.

It works fine for me with the attached changes.

* you can't use g.message outside of grass;
   ## g.message "..." >&2 ## is redundant
* be pedantic about quoting

G63> ./v.in.wfs \
wfs="http://mapserver.gdf-hannover.de/cgi-bin/grassuserwfs?REQUEST=GetF\\
eature&SERVICE=WFS&VERSION=1.0.0" out=wfs_test

Over-riding projection check.
Proceeding with import...
Layer: myns:GRASS_users
WARNING: Column name changed: 'myns:ogc_fid' -> 'myns_ogc_fid'
WARNING: Column name changed: 'myns:name' -> 'myns_name'
WARNING: Width for column 'myns_name' set to 255 (was not specified by
         OGR), some strings may be truncated!
WARNING: Column name changed: 'myns:company' -> 'myns_company'
WARNING: Width for column 'myns_company' set to 255 (was not specified
         by OGR), some strings may be truncated!
Importing map 786 features...
-----------------------------------------------------
Building topology ...
786 primitives registered
Building areas: 100%
0 areas built
0 isles built
Attaching islands:
Attaching centroids: 100%
Topology was built.
Number of nodes : 784
Number of primitives: 786
Number of points : 786
Number of lines : 0
Number of boundaries: 0
Number of centroids : 0
Number of areas : 0
Number of isles : 0
Vector points map <wfs_test> imported from WFS.

#silly test
G63> v.db.select wfs_test where="myns_name ~ 'Markus'"
cat|myns_ogc_f|myns_name|myns_compa
676|2|Markus Neteler|ITC-irst (Povo)
722|201|Markus Spring|RGU München
723|202|Markus Spring|RGU München
G63> d.vect wfs_test cat=676 col=green width=2

We should (finally) add a flag to v.db.select to allow output of x,y,z
info, or probably better* add to v.out.ascii where= and column(s)=
options to output DB values. There is my v.out.ascii.db, but it's a
slow hack.

[*] single cat can be linked to multiple vector features

Hamish

(attachments)

v.in.wfs.diff (2.02 KB)
v.in.wfs.NEW (1.69 KB)

I got errors (thousands of them) in r.tileset when trying r.in.wms output=elevation_meters mapserver=http://wms.jpl.nasa.gov/wms.cgi layers=us_ned styles=real -o
For instance
Sorry, <(142585.01085156029416302431 > 143102.29050826436668412227) * 142585.01085156029416302431 + (143102.29050826436668412227 >> is not a valid parameter
/Applications/GRASS-6.3.app/Contents/Resources/scripts/r.tileset: line 436: 26255 Segmentation fault g.message “$2”
In occasion even the g.message gui is launched.

On May 9, 2007, at 1:02 PM, Hamish wrote:

Markus Neteler wrote:

I observed a similar problem in my new v.in.wfs script
(get from http://mpa.itc.it/markus/grass63/): The WFS URL is
disliked by g.parser. I worked around this with ugly hacks but
I think that we need a new parameter type which accepts chars
such as ‘=’, ‘&’ and so forth. I used file,file,file in v.in.wfs
but would prefer something else.

It works fine for me with the attached changes.

  • you can’t use g.message outside of grass;

g.message “…” >&2 ## is redundant

  • be pedantic about quoting

G63> ./v.in.wfs
wfs=“http://mapserver.gdf-hannover.de/cgi-bin/grassuserwfs?REQUEST=GetF
eature&SERVICE=WFS&VERSION=1.0.0” out=wfs_test

Over-riding projection check.
Proceeding with import…
Layer: myns:GRASS_users
WARNING: Column name changed: ‘myns:ogc_fid’ → ‘myns_ogc_fid’
WARNING: Column name changed: ‘myns:name’ → ‘myns_name’
WARNING: Width for column ‘myns_name’ set to 255 (was not specified by
OGR), some strings may be truncated!
WARNING: Column name changed: ‘myns:company’ → ‘myns_company’
WARNING: Width for column ‘myns_company’ set to 255 (was not specified
by OGR), some strings may be truncated!
Importing map 786 features…

Building topology …
786 primitives registered
Building areas: 100%
0 areas built
0 isles built
Attaching islands:
Attaching centroids: 100%
Topology was built.
Number of nodes : 784
Number of primitives: 786
Number of points : 786
Number of lines : 0
Number of boundaries: 0
Number of centroids : 0
Number of areas : 0
Number of isles : 0
Vector points map <wfs_test> imported from WFS.

#silly test
G63> v.db.select wfs_test where=“myns_name ~ ‘Markus’”
cat|myns_ogc_f|myns_name|myns_compa
676|2|Markus Neteler|ITC-irst (Povo)
722|201|Markus Spring|RGU München
723|202|Markus Spring|RGU München
G63> d.vect wfs_test cat=676 col=green width=2

We should (finally) add a flag to v.db.select to allow output of x,y,z
info, or probably better* add to v.out.ascii where= and column(s)=
options to output DB values. There is my v.out.ascii.db, but it’s a
slow hack.

[*] single cat can be linked to multiple vector features

Hamish
<v.in.wfs.diff>

<v.in.wfs.NEW>


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

Agustin Diez Castillo wrote:

I got errors (thousands of them) in r.tileset when trying r.in.wms
output=elevation_meters mapserver=http://wms.jpl.nasa.gov/wms.cgi
layers=us_ned styles=real -o
For instance
Sorry, <(142585.01085156029416302431 > 143102.29050826436668412227) *
142585.01085156029416302431 + (143102.29050826436668412227 >> is not
a valid parameter
/Applications/GRASS-6.3.app/Contents/Resources/scripts/r.tileset:
line 436: 26255 Segmentation fault g.message "$2"
In occasion even the g.message gui is launched.

Please update both r.in.wms and r.tileset script/ dirs from CVS.
All the g.message errors should be fixed now. (in the last hours)

Hamish