[GRASS-dev] how to work around "Arument list too long" error in a GRASS python script ?

Anna Petrášová kratochanna at gmail.com
Thu Jun 11 11:05:00 PDT 2015


On Thu, Jun 11, 2015 at 1:46 PM, Moritz Lennert <
mlennert at club.worldonline.be> wrote:

> On 11/06/15 19:02, Nikos Alexandris wrote:
>
>> * Moritz Lennert <mlennert at club.worldonline.be> [2015-06-11 18:37:36
>> +0200]:
>>
>>  Hello,
>>>
>>> In a python script I have the following call:
>>>
>>> grass.run_command('r.series',
>>>                      input = rate_maps,
>>>                      output = sum_rates,
>>>                      method = 'sum',
>>>                      overwrite = True,
>>>                      quiet=True)
>>>
>>> rate_maps is a list which in one instance contains 8559 map names,
>>> leading to an "OSError: [Errno 7] Argument list too long".
>>>
>>> I know that in the shell I could use xargs to work around such a
>>> problem. But how to do this in python ?
>>>
>>
>> What it the OS limit for it?
>>
>
> I suppose this is ARG_MAX ?
>
> getconf ARG_MAX
> 2097152
>
> A text file with all file names only uses 144551 bytes.
>
> Or is there another limit I should look at ?
>
>
>
>>> I could obviously loop through all maps and thus sum them individually,
>>> but this just seems horribly inefficient.
>>>
>>> Does anyone have a better solution ?
>>>
>>
>> - Maybe split in two or three sessions (instead of looping over all)?
>>
>
> Yes, thanks, I can do that. I'll also try the file option mentioned by
> Anna (r.series actually has one). Didn't think of that.
>

Oh, I didn't know that it already has it. Good to know!

>
> Thanks to both of you !
>
> Moritz
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/grass-dev/attachments/20150611/56fad2ee/attachment.html>


More information about the grass-dev mailing list