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

Nikos Alexandris nik at nikosalexandris.net
Mon Oct 9 05:37:26 PDT 2017


* Moritz Lennert <mlennert at club.worldonline.be> [2017-10-09 13:05:45 +0200]:

>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'
>
But of course it works!  Don't know why I got stuck with env instead
os.environ.

Thanks, Nikos
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 228 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/grass-dev/attachments/20171009/87f52f9d/attachment.sig>


More information about the grass-dev mailing list