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 _______________________________________________ grass-dev mailing list [email protected] http://lists.osgeo.org/mailman/listinfo/grass-dev
