[GRASS-dev] grass and python

William Kyngesburye woklist at kyngchaos.com
Sat Aug 12 11:15:15 EDT 2006


On Aug 12, 2006, at 12:38 AM, David Finlayson wrote:

> It is quite possible to initialize and run grass without Bash. I  
> have a simi-working python script that fires up GRASS using IPython  
> as it's shell. In fact, since Python abstracts os calls such as  
> creating temp files, setting environment variables, etc, it is  
> actually much easier to write a cross-platform initialization  
> script in Python than in Bash. HOWEVER (and this is big), if you do  
> not have a traditional unix shell running grass, none of the nearly  
> 100 or so scripts that are distributed with GRASS---and that depend  
> on bash---will work.
>
But, as long as the Python app sets up and maintains that shell  
environment, shouldn't the shell scripts work, if run from the Python  
environment? something like (pardon, just getting started with python):

os.environ to set up environment (probably what your experimental  
python startup does)

os.popen to run the shell script - uses os.environ setup, or is that  
where it needs a running shell?  It's possible to start it in a  
shell, like a new Terminal window on OS X, tho a bit messy.  Maybe  
there's a python-driven shell interpreter?

> Many standard GRASS commands are really shell scripts. Every single  
> one of them will need to be ported to your new shell if this isn't  
> compatible with Bash. I stopped working on this when I realized how  
> disruptive this was going to be (and how unlikely this would be  
> supported by the core GRASS community). I don't think the vast  
> majority of GRASS developers want to move to a Python environment  
> (or Ruby or Perl or cmd.exe, etc). So, basically, this is an idea  
> dead-on-arrival. It would amount to a fork of GRASS and new users  
> would have a terrible time figuring out which shell they were  
> supposed to be using for each script.
>
> I think that GRASS is intimately tied to a Posix-compliant shell.  
> There needs to be a standard macro-language for scripting and Bash  
> seems as good as any.
>
Coming from a more object-oriented programming perspective, I find  
unix shell scripting to be a nightmare.

If the wxpython GUI takes off as the main GRASS GUI, there will  
probably be less resistance to moving to Python for all or most GRASS  
scripting.

-----
William Kyngesburye <kyngchaos at kyngchaos.com>
http://www.kyngchaos.com/

"This is a question about the past, is it? ... How can I tell that  
the past isn't a fiction designed to account for the discrepancy  
between my immediate physical sensations and my state of mind?"

- The Ruler of the Universe




More information about the grass-dev mailing list