[GRASS-dev] [GRASS-SVN] r60679 - grass/trunk/lib/python/script

Glynn Clements glynn at gclements.plus.com
Thu Jun 5 23:52:23 PDT 2014


Markus Neteler wrote:

> > 1. GRASS 7 will need .bat wrappers for Python scripts on Windows. That
> > has the same issues as using shell=True, but at least it only applies
> > in the case where we're executing a script.
> 
> ... this would follow the apparently working method in GRASS 6.
> Maybe worth a try also in GRASS 7 at this point.
> 
> > 2. If we know that the "program" is a script, the interpreter can be
> > specified explicitly (i.e. "python path/to/script.py"). This keeps the
> > shell out of the picture.
> 
> ... how much effort is the latter? Check file type and path to file?

No. The latter involves the caller knowing that it's invoking a script
and explcitly invoking it via the interpreter.

Attempting to determine this within the library is problematic, as we
would need to mimic the mechanisms which the platform uses for
invoking scripts. E.g.

* If the "program" argument isn't a full path, we need to scan %PATH%
for it.

* If it lacks an extension, we also need to scan %PATHEXT%.

* There's also the question of whether such treatment should be
applied for any script, or just those which are part of GRASS.

Using batch files has the advantage that we can just execute the
command without worrying about any of this.

-- 
Glynn Clements <glynn at gclements.plus.com>


More information about the grass-dev mailing list