[GRASS-dev] New wiki page summarising GRASS APIs
Moritz Lennert
mlennert at club.worldonline.be
Sun Feb 1 11:26:04 PST 2015
On 01/02/15 12:29, Glynn Clements wrote:
>
> Pietro wrote:
>
>> {{{
>> import os
>> os.system('g.region rast=elevation')
>> }}}
>>
>> and not subprocess:
>>
>> {{{
>> import subprocess
>> subprocess.call('g.region rast=elevation', shell=True)
>>
>> # or
>>
>> subprocess.Popen('g.region rast=elevation', shell=True)
>> }}}
>>
>> Concerning the pygrass Module API, may be we can use the shortcut version:
>
> Using subprocess.call() with shell=True is no better than using
> os.system(). Both should be avoided at all costs.
>
> The grass.script module provides a number of convenience functions
> which use grass.script.make_command() to generate the command's
> argument list from the function's argument list. Also, they use a
> version of subprocess.Popen() which has been wrapped to deal with some
> of Windows' idiosyncrasies.
>
Just to be clear: the example on this wiki page shows just that it is
possible to call any GRASS module from any language that allows system
calls. It then goes on to introduce the scripting API to show how that
eases things on the script writer since she doesn't have to deal with
any idiosyncrasies.
But if this causes too much opposition I can take it out or at least put
a big warning of likes of "Don't use this ! Example code only."
Moritz
More information about the grass-dev
mailing list