[GRASS-dev] grass7 addon python script - finishes in normal and --verbose mode, but not in --quiet mode

tested here with:

GRASS Version: 7.1.svn
GRASS SVN Revision: 62712
Erstellungsdatum: 2014-11-12
Build Platform: i686-pc-mingw32
GDAL/OGR: 1.11.0
PROJ.4: 4.8.0
GEOS: 3.4.2
SQLite: 3.7.17
Python: 2.7.4
wxPython: 2.8.12.1
Platform: Windows-7-6.1.7601-SP1 (OSGeo4W)

running the addon script [1] in normal and --verbose mode:

v.fixed.segmentpoints vector=iselflipped@myricaria cat=1
dir=C:\tmp\grassscript distance=25000
Extract vector line for which segment points should be calculated ...
[...]
----
v.fixed.segmentpoints done!
(Thu Nov 13 21:36:52 2014) Befehl ausgeführt (43 Sek)

v.fixed.segmentpoints --verbose vector=iselflipped@myricaria cat=1
dir=C:\tmp\grassscript distance=25000
Extract vector line for which segment points should be calculated ...
[...]
----
v.fixed.segmentpoints done!
(Thu Nov 13 21:39:03 2014) Befehl ausgeführt (35 Sek)

it works.

but in --quiet mode it fails with:

v.fixed.segmentpoints --quiet vector=iselflipped@myricaria cat=1
dir=C:\tmp\grassscript distance=25000
Traceback (most recent call last):
  File "C:\Users\myricaria\AppData\Roaming\GRASS7\addons/scr
ipts/v.fixed.segmentpoints.py", line 226, in <module>
    sys.exit(main())
  File "C:\Users\myricaria\AppData\Roaming\GRASS7\addons/scr
ipts/v.fixed.segmentpoints.py", line 100, in main
    vector_line_length =
float(tmp.split('\n')[1].split('|')[1])
IndexError: list index out of range
(Thu Nov 13 21:40:08 2014) Befehl ausgeführt (2 Sek)

any idea?

thanks

[1]
http://trac.osgeo.org/grass/browser/grass-addons/grass7/vector/v.fixed.segmentpoints

-----
best regards
Helmut
--
View this message in context: http://osgeo-org.1560.x6.nabble.com/grass7-addon-python-script-finishes-in-normal-and-verbose-mode-but-not-in-quiet-mode-tp5172902.html
Sent from the Grass - Dev mailing list archive at Nabble.com.

On Thu, Nov 13, 2014 at 3:44 PM, Helmut Kudrnovsky <hellik@web.de> wrote:

tested here with:

GRASS Version: 7.1.svn
GRASS SVN Revision: 62712
Erstellungsdatum: 2014-11-12
Build Platform: i686-pc-mingw32
GDAL/OGR: 1.11.0
PROJ.4: 4.8.0
GEOS: 3.4.2
SQLite: 3.7.17
Python: 2.7.4
wxPython: 2.8.12.1
Platform: Windows-7-6.1.7601-SP1 (OSGeo4W)

running the addon script [1] in normal and --verbose mode:

v.fixed.segmentpoints vector=iselflipped@myricaria cat=1
dir=C:\tmp\grassscript distance=25000
Extract vector line for which segment points should be calculated ...
[...]
----
v.fixed.segmentpoints done!
(Thu Nov 13 21:36:52 2014) Befehl ausgeführt (43 Sek)

v.fixed.segmentpoints --verbose vector=iselflipped@myricaria cat=1
dir=C:\tmp\grassscript distance=25000
Extract vector line for which segment points should be calculated ...
[...]
----
v.fixed.segmentpoints done!
(Thu Nov 13 21:39:03 2014) Befehl ausgeführt (35 Sek)

it works.

but in --quiet mode it fails with:

v.fixed.segmentpoints --quiet vector=iselflipped@myricaria cat=1
dir=C:\tmp\grassscript distance=25000
Traceback (most recent call last):
  File "C:\Users\myricaria\AppData\Roaming\GRASS7\addons/scr
ipts/v.fixed.segmentpoints.py", line 226, in <module>
    sys.exit(main())
  File "C:\Users\myricaria\AppData\Roaming\GRASS7\addons/scr
ipts/v.fixed.segmentpoints.py", line 100, in main
    vector_line_length =
float(tmp.split('\n')[1].split('|')[1])
IndexError: list index out of range
(Thu Nov 13 21:40:08 2014) Befehl ausgeführt (2 Sek)

any idea?

Could you try to print tmp with and without quiet?

thanks

[1]

http://trac.osgeo.org/grass/browser/grass-addons/grass7/vector/v.fixed.segmentpoints

-----
best regards
Helmut
--
View this message in context:
http://osgeo-org.1560.x6.nabble.com/grass7-addon-python-script-finishes-in-normal-and-verbose-mode-but-not-in-quiet-mode-tp5172902.html
Sent from the Grass - Dev mailing list archive at Nabble.com.
_______________________________________________
grass-dev mailing list
grass-dev@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-dev

On 13/11/14 21:44, Helmut Kudrnovsky wrote:

tested here with:

GRASS Version: 7.1.svn
GRASS SVN Revision: 62712
Erstellungsdatum: 2014-11-12
Build Platform: i686-pc-mingw32
GDAL/OGR: 1.11.0
PROJ.4: 4.8.0
GEOS: 3.4.2
SQLite: 3.7.17
Python: 2.7.4
wxPython: 2.8.12.1
Platform: Windows-7-6.1.7601-SP1 (OSGeo4W)

running the addon script [1] in normal and --verbose mode:

v.fixed.segmentpoints vector=iselflipped@myricaria cat=1
dir=C:\tmp\grassscript distance=25000
Extract vector line for which segment points should be calculated ...
[...]
----
v.fixed.segmentpoints done!
(Thu Nov 13 21:36:52 2014) Befehl ausgeführt (43 Sek)

v.fixed.segmentpoints --verbose vector=iselflipped@myricaria cat=1
dir=C:\tmp\grassscript distance=25000
Extract vector line for which segment points should be calculated ...
[...]
----
v.fixed.segmentpoints done!
(Thu Nov 13 21:39:03 2014) Befehl ausgeführt (35 Sek)

it works.

but in --quiet mode it fails with:

v.fixed.segmentpoints --quiet vector=iselflipped@myricaria cat=1
dir=C:\tmp\grassscript distance=25000
Traceback (most recent call last):
   File "C:\Users\myricaria\AppData\Roaming\GRASS7\addons/scr
ipts/v.fixed.segmentpoints.py", line 226, in <module>
     sys.exit(main())
   File "C:\Users\myricaria\AppData\Roaming\GRASS7\addons/scr
ipts/v.fixed.segmentpoints.py", line 100, in main
     vector_line_length =
float(tmp.split('\n')[1].split('|')[1])
IndexError: list index out of range
(Thu Nov 13 21:40:08 2014) Befehl ausgeführt (2 Sek)

any idea?

I don't understand the details, but I think that --quiet somehow suppresses the access to the output of your grass.read_command('v.to.db', ...).

I've had similar issues with pipe_command for v.centerline. So I played with the GRASS_VERBOSE env variable. See [1].

Moritz

[1] http://trac.osgeo.org/grass/browser/grass-addons/grass7/vector/v.centerline/v.centerline.py#L228

Anna Petrášová wrote

but in --quiet mode it fails with:

v.fixed.segmentpoints --quiet vector=iselflipped@myricaria cat=1
dir=C:\tmp\grassscript distance=25000
Traceback (most recent call last):
  File "C:\Users\myricaria\AppData\Roaming\GRASS7\addons/scr
ipts/v.fixed.segmentpoints.py", line 226, in

<module>

    sys.exit(main())
  File "C:\Users\myricaria\AppData\Roaming\GRASS7\addons/scr
ipts/v.fixed.segmentpoints.py", line 100, in main
    vector_line_length =
float(tmp.split('\n')[1].split('|')[1])
IndexError: list index out of range
(Thu Nov 13 21:40:08 2014) Befehl ausgeführt (2 Sek)

any idea?

Could you try to print tmp with and without quiet?

http://trac.osgeo.org/grass/browser/grass-addons/grass7/vector/v.fixed.segmentpoints/v.fixed.segmentpoints.py#L102

102 # Read length
103 tmp = grass.read_command('v.to.db', map = voutline,
104 type = 'line',
105 layer = 1,
106 qlayer = 1,
107 option = 'length',
108 units = 'meters',
109 column = 'vlength',
110 flags = 'p')
111 vector_line_length = float(tmp.split('\n')[1].split('|')[1])
112
113 # Print vector line length
114 grass.message( "Vector line length in meter:" )
115 grass.message( vector_line_length )
116 grass.message( "----" )

it's just to get the length of the vector line for further calculations:

in normal and verbose mode:

----
Lese Objekte...
Vector line length in meter:
58858.3366368
----

as Moritz points out, it seems quiet mode suppresses the access to the
output of grass.read_command; his solution/workaround with GRASS_VERBOSE env
variable seems not to work here on my side.

-----
best regards
Helmut
--
View this message in context: http://osgeo-org.1560.x6.nabble.com/grass7-addon-python-script-finishes-in-normal-and-verbose-mode-but-not-in-quiet-mode-tp5172902p5172966.html
Sent from the Grass - Dev mailing list archive at Nabble.com.

On 14/11/14 10:25, Helmut Kudrnovsky wrote:

Anna Petrášová wrote

but in --quiet mode it fails with:

v.fixed.segmentpoints --quiet vector=iselflipped@myricaria cat=1
dir=C:\tmp\grassscript distance=25000
Traceback (most recent call last):
   File "C:\Users\myricaria\AppData\Roaming\GRASS7\addons/scr
ipts/v.fixed.segmentpoints.py", line 226, in

<module>

     sys.exit(main())
   File "C:\Users\myricaria\AppData\Roaming\GRASS7\addons/scr
ipts/v.fixed.segmentpoints.py", line 100, in main
     vector_line_length =
float(tmp.split('\n')[1].split('|')[1])
IndexError: list index out of range
(Thu Nov 13 21:40:08 2014) Befehl ausgeführt (2 Sek)

any idea?

Could you try to print tmp with and without quiet?

http://trac.osgeo.org/grass/browser/grass-addons/grass7/vector/v.fixed.segmentpoints/v.fixed.segmentpoints.py#L102

102 # Read length
103 tmp = grass.read_command('v.to.db', map = voutline,
104 type = 'line',
105 layer = 1,
106 qlayer = 1,
107 option = 'length',
108 units = 'meters',
109 column = 'vlength',
110 flags = 'p')
111 vector_line_length = float(tmp.split('\n')[1].split('|')[1])
112
113 # Print vector line length
114 grass.message( "Vector line length in meter:" )
115 grass.message( vector_line_length )
116 grass.message( "----" )

it's just to get the length of the vector line for further calculations:

in normal and verbose mode:

----
Lese Objekte...
Vector line length in meter:
58858.3366368
----

as Moritz points out, it seems quiet mode suppresses the access to the
output of grass.read_command; his solution/workaround with GRASS_VERBOSE env
variable seems not to work here on my side.

I'm afraid that --quiet supersedes any settings in the code, but am not sure.

Moritz

On Fri, Nov 14, 2014 at 6:37 AM, Moritz Lennert <
mlennert@club.worldonline.be> wrote:

On 14/11/14 10:25, Helmut Kudrnovsky wrote:

Anna Petrášová wrote

but in --quiet mode it fails with:

v.fixed.segmentpoints --quiet vector=iselflipped@myricaria cat=1
dir=C:\tmp\grassscript distance=25000
Traceback (most recent call last):
   File "C:\Users\myricaria\AppData\Roaming\GRASS7\addons/scr
ipts/v.fixed.segmentpoints.py", line 226, in

<module>

     sys.exit(main())
   File "C:\Users\myricaria\AppData\Roaming\GRASS7\addons/scr
ipts/v.fixed.segmentpoints.py", line 100, in main
     vector_line_length =
float(tmp.split('\n')[1].split('|')[1])
IndexError: list index out of range
(Thu Nov 13 21:40:08 2014) Befehl ausgeführt (2 Sek)

any idea?

Could you try to print tmp with and without quiet?

http://trac.osgeo.org/grass/browser/grass-addons/grass7/
vector/v.fixed.segmentpoints/v.fixed.segmentpoints.py#L102

102 # Read length
103 tmp = grass.read_command('v.to.db', map = voutline,
104 type = 'line',
105 layer = 1,
106 qlayer = 1,
107 option = 'length',
108 units = 'meters',
109 column = 'vlength',
110 flags = 'p')
111 vector_line_length = float(tmp.split('\n')[1].split('|')[1])
112
113 # Print vector line length
114 grass.message( "Vector line length in meter:" )
115 grass.message( vector_line_length )
116 grass.message( "----" )

it's just to get the length of the vector line for further calculations:

in normal and verbose mode:

----
Lese Objekte...
Vector line length in meter:
58858.3366368
----

as Moritz points out, it seems quiet mode suppresses the access to the
output of grass.read_command; his solution/workaround with GRASS_VERBOSE
env
variable seems not to work here on my side.

I'm afraid that --quiet supersedes any settings in the code, but am not
sure.

So how about setting quiet=False when calling v.to.db? Anyway I don't
think quiet causes read_command to be completely silent, just run

grass.read_command('r.info', map='elevation', flags='g', quiet=True)

and it gives output as expected.

Moritz

_______________________________________________
grass-dev mailing list
grass-dev@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-dev

On Fri, Nov 14, 2014 at 9:47 AM, Anna Petrášová <kratochanna@gmail.com>
wrote:

On Fri, Nov 14, 2014 at 6:37 AM, Moritz Lennert <
mlennert@club.worldonline.be> wrote:

On 14/11/14 10:25, Helmut Kudrnovsky wrote:

Anna Petrášová wrote

but in --quiet mode it fails with:

v.fixed.segmentpoints --quiet vector=iselflipped@myricaria cat=1
dir=C:\tmp\grassscript distance=25000
Traceback (most recent call last):
   File "C:\Users\myricaria\AppData\Roaming\GRASS7\addons/scr
ipts/v.fixed.segmentpoints.py", line 226, in

<module>

     sys.exit(main())
   File "C:\Users\myricaria\AppData\Roaming\GRASS7\addons/scr
ipts/v.fixed.segmentpoints.py", line 100, in main
     vector_line_length =
float(tmp.split('\n')[1].split('|')[1])
IndexError: list index out of range
(Thu Nov 13 21:40:08 2014) Befehl ausgeführt (2 Sek)

any idea?

Could you try to print tmp with and without quiet?

http://trac.osgeo.org/grass/browser/grass-addons/grass7/
vector/v.fixed.segmentpoints/v.fixed.segmentpoints.py#L102

102 # Read length
103 tmp = grass.read_command('v.to.db', map = voutline,
104 type = 'line',
105 layer = 1,
106 qlayer = 1,
107 option = 'length',
108 units = 'meters',
109 column = 'vlength',
110 flags = 'p')
111 vector_line_length = float(tmp.split('\n')[1].split('|')[1])
112
113 # Print vector line length
114 grass.message( "Vector line length in meter:" )
115 grass.message( vector_line_length )
116 grass.message( "----" )

it's just to get the length of the vector line for further calculations:

in normal and verbose mode:

----
Lese Objekte...
Vector line length in meter:
58858.3366368
----

as Moritz points out, it seems quiet mode suppresses the access to the
output of grass.read_command; his solution/workaround with GRASS_VERBOSE
env
variable seems not to work here on my side.

I'm afraid that --quiet supersedes any settings in the code, but am not
sure.

So how about setting quiet=False when calling v.to.db? Anyway I don't
think quiet causes read_command to be completely silent, just run

grass.read_command('r.info', map='elevation', flags='g', quiet=True)

and it gives output as expected.

It's because of the header line:
cat|length
1|572.767146965659

but in quiet mode you get:

1|572.767146965659

so I would suggest set quiet=True for v.to.db and change the code for
parsing to expect just one line.

Anna

Moritz

_______________________________________________
grass-dev mailing list
grass-dev@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-dev

Anna Petrášová wrote

grass.read_command('r.info', map='elevation', flags='g', quiet=True)

and it gives output as expected.

It's because of the header line:
cat|length
1|572.767146965659

but in quiet mode you get:

1|572.767146965659

so I would suggest set quiet=True for v.to.db and change the code for
parsing to expect just one line.

Anna

yes, this works. script adapted.

thanks

-----
best regards
Helmut
--
View this message in context: http://osgeo-org.1560.x6.nabble.com/grass7-addon-python-script-finishes-in-normal-and-verbose-mode-but-not-in-quiet-mode-tp5172902p5173068.html
Sent from the Grass - Dev mailing list archive at Nabble.com.

On Fri, Nov 14, 2014 at 10:05 AM, Anna Petrášová <kratochanna@gmail.com>
wrote:

It's because of the header line:
cat|length
1|572.767146965659

but in quiet mode you get:

1|572.767146965659

so I would suggest set quiet=True for v.to.db and change the code for
parsing to expect just one line.

--quiet and --verbose should change the level of verbosity of messages
(additional info and/or diagnostic). However, if header is included or not
is question of the (output) format which should be same unless explicitly
changed. A flag should be there to include or not include the header. I
think there is a bug in v.to.db.