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

Anna Petrášová kratochanna at gmail.com
Mon Oct 9 06:58:31 PDT 2017


On Oct 9, 2017 3:17 AM, "Nikos Alexandris" <nik at nikosalexandris.net> wrote:

* 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.


It shouldn't, you copied the environment, you didn't change the environment
used. You would have to take the copied env and pass it to run_command,
then it would work. Or of course, modify the actual environment, not the
copied one. Hope this clarifies it a bit.

Anna


Aren't there other ways?

Thank you again, N

_______________________________________________
grass-dev mailing list
grass-dev at lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/grass-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/grass-dev/attachments/20171009/759c31d7/attachment-0001.html>


More information about the grass-dev mailing list