[GRASS-dev] Force --v flag whenever -l is instructed

Moritz Lennert mlennert at club.worldonline.be
Mon Oct 9 04:05:45 PDT 2017


On 09/10/17 12:49, Nikos Alexandris wrote:
> * Nikos Alexandris <nik at nikosalexandris.net> [2017-10-09 12:18:29 +0200]:
> 
>> * Moritz Lennert <moritz.lennert at ulb.ac.be> [2017-10-09 10:59:25 +0200]:
>>
>>> On 07/10/17 10:39, Nikos Alexandris wrote:
>>>> In a grassy script, how can I force verbosity, i.e. --v whenever a flag
>>>> -l is instructed? Which will lead to
>>>>
>>>> env['GRASS_VERBOSE'] = '3'
>>>>
>>>> ?
>>>>
>>>>
>>>> i.some.module input=some_input -l
>>>>
>>>> should be identical to
>>>>
>>>> i.some.module input=some_input -l --v
>>>>
>>>>
>>>> The following is, of course, not working:
>>>>
>>>> #%rules
>>>> #% requires_all: -l,--v
>>>> #%end
>>>>
>>>
>>> I don't think the -- flags are covered by the rules, so I think you
>>> have to do this in the code, i.e. something like this:
>>>
>>> if flags['l']:
>>> 	env['GRASS_VERBOSE'] = '3'
>>
>> Merci Moritz,
>>
>> I tested already (before asking)
>>
>> env = os.environ.copy()
>> if list_only:
>>    env['GRASS_VERBOSE'] = '3'
>>
>> but it does not work.

Yes, sorry, I just copied your line without thinking.

>>
>> Aren't there other ways?
>>
>> Thank you again, N
> 
> I guess simply
> 
> GRASS_VERBOSE=3
> export GRASS_VERBOSE
> 
> It works!

Yes, but that's in a shell, not in Python, or ?

In Python, something like this should work IIRC:

import os
os.environ['GRASS_VERBOSE'] = '3'

Moritz


More information about the grass-dev mailing list