[GRASS-dev] grass and python

Michael Barton michael.barton at asu.edu
Sat Aug 12 13:45:17 EDT 2006


William,

Glynn et al have already answered some of this. I'll add a few more
comments.

I've been through some of this recently working with the agent modeling
group in my research team.

GRASS doesn't run (in the sense of running a process). That is, when you run
init.sh, it doesn't really do anything except set up a number of
environmental variables to let you run (in the sense of starting a process)
GRASS modules. 

In this respect, you can "start" GRASS in pretty near anything. You need
some kind of shell to process the commands, but that's about it. We're now
running GRASS commands from within a DEVS JAVA agent modeling environment.
(This is very cool by the way)

So yes, you can run GRASS from within Python. The current wxPython prototype
takes a somewhat different approach and sends GRASS commands to the default
shell (whatever it is).

Glynn's and Trevor's comments about GRASS and the BASH shell are apropos.
Currently it is a good common denominator on most systems with GRASS today,
but difficult from a programming perspective and problematic for Widows.

But what can we replace it with? Right now there is no good answer. If the
wxPython UI takes off, we might be able to revisit Python as a default shell
in the future, but I don't think we're there yet.

In order to support multiple sessions, I think you simply need to start
multiple shells (i.e., command parser with environment settings) for GRASS
commands to run in. Lorenzo's binaries will do that now. The biggest
convenience for me of multiple GRASS sessions is being able to work in
multiple locations simultaneously (though only for brief times or I get
confused). 

I've only messed with the app building a couple of times--and didn't get it
right yet.

Michael
__________________________________________
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: Fri, 11 Aug 2006 11:19:48 -0500
> To: Michael Barton <michael.barton at asu.edu>
> Cc: <grass-dev at grass.itc.it>
> Subject: [GRASS-dev] grass and python
> 
> I've been working on an alternative Mac GRASS.app startup - currently
> it uses the OnMyCommand droplet as an app template, but I'm looking
> for a more open source, buildable kind of startup, and found py2app.
> (Lorenzo's AppleScript Studio method could work, but I don't want to
> have to deal with Xcode.)
> 
> I have something that works, but it got me thinking about the
> wxpython gui developments.  I haven't been paying much attention to
> that and haven't had a chance to try it yet.  So, py2app offers a
> cool possibility - a completely selfcontained Mac application, and
> its cousin py2exe might do the same for Windows.
> 
> My question is, does, or is it possible in the future for, wxpython
> grass to start directly from python?  Or like the tcltk GUI, does it
> need the GRASS shell running first for the initial environment
> setup?  It would be nice for the wxpython GUI to setup and maintain
> the environment that init.sh does.  Then it could let the user open a
> Terminal or other shell (maybe a pseudo-terminal within python?) to
> run commands the old fashioned way if desired, but not require that.
> Also, it would keep a persistent 'GRASS.app' application in the Dock
> while 'GRASS' is running.
> 
> My current python startup app just fires up the normal init.sh
> startup and quits, leaving GRASS running in the Terminal and the GUI
> in TclTk X11, and disappears from the Dock.  While the OnMyCommand
> method at least stays around in the Dock until GRASS is quit from the
> Terminal (even tho it doesn't do anything after starting GRASS, it's
> nice to have that visual clue in the Dock that GRASS is running).
> 
> Another question about the wxpython GUI - does or will it handle
> multiple GRASS sessions at once, kind of like having multiple
> documents (ie mapsets) open in an application?  A Mac application
> normally can only open in one instance, unlike running different
> instances from multiple Terminal windows.  I just realized that my
> current OMC app can only run one at a time, since the app stays open,
> yet the python method I'm working on can open multiple instances of
> GRASS, since the app itself quits right away, leaving GRASS running
> (a bit confusing for a Mac user, and especially so since there is no
> hard connection between the GUI and the Terminal shell that opened it).
> 
> One nice thing about the py2app setup is that it can locate and
> create local copies of all dependencies (python modules and dynamic
> libraries and frameworks) needed plus a minimal copy of the python
> runtime environment.  Then the user doesn't have to worry about which
> Python they have installed, that might be too old or too new, or
> having all the needed modules installed.  With the current init.sh
> startup, it would have a hard time locating dependencies for this
> since it doesn't really 'see' the internals of the wxpython grass
> gui, though it might since it seems to be pretty rigourous in
> identifying stuff like that.
> 
> -----
> William Kyngesburye <kyngchaos at kyngchaos.com>
> http://www.kyngchaos.com/
> 
> [Trillian]  What are you supposed to do WITH a maniacally depressed
> robot?
> 
> [Marvin]  You think you have problems?  What are you supposed to do
> if you ARE a maniacally depressed robot?  No, don't try and answer,
> I'm 50,000 times more intelligent than you and even I don't know the
> answer...
> 
> - HitchHiker's Guide to the Galaxy
> 
> 




More information about the grass-dev mailing list