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

Helmut Kudrnovsky hellik at web.de
Fri Nov 14 01:25:05 PST 2014


Anna Petrášová wrote
>>
>> but in --quiet mode it fails with:
>>
>> v.fixed.segmentpoints --quiet vector=iselflipped at 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.


More information about the grass-dev mailing list