[GRASS-dev] grass and python

Michael Barton michael.barton at asu.edu
Sat Aug 12 14:01:03 EDT 2006


William,

See additional responses below.

Michal
__________________________________________
Michael Barton, Professor of Anthropology
School of Human Evolution & Social Change
Center for Social Dynamics & Complexity
Arizona State University

phone: 480-965-6213
fax: 480-965-7671
www: http://www.public.asu.edu/~cmbarton



> From: William Kyngesburye <woklist at kyngchaos.com>
> Reply-To: William Kyngesburye <kyngchaos at kyngchaos.com>
> Date: Sat, 12 Aug 2006 10:15:15 -0500
> To: David Finlayson <david.p.finlayson at gmail.com>
> Cc: <grass-dev at grass.itc.it>
> Subject: Re: [GRASS-dev] grass and python
> 
> 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):

Bash scripts will work if it sets up a Bash environment, but not necessarily
if it sets up another shell environment. The command prompt in Unix is
actually a running shell program that provides an interface for shell
commands. There are multiple shells possible, but Bash has become a common
denominator for GRASS and many other programs.

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

It use os.environ to read currently set environmental variables. There is
some cautioning in the Python manual about using it to set environmental
variables on different platforms.

> 
> 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?

The Python cmd module may do this, but I haven't yet experimented with it.
Maybe David knows. 

> 
>> 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.

We'll see. I've done my share of shell scripting and do like what I'm
learning about Python. I'm especially encouraged that so many other people
know something about it too.

Michael




More information about the grass-dev mailing list