Discussion:
[GRASSGUI] python scripting support?
Michael Barton
2007-11-14 22:56:49 UTC
Permalink
What would it take to support python scripts like we support bash scripts.
That is, can we have a python script header that is automatically read and
parsed by menuform.py in some structured way to create a nice wxPython GUI
for ad hoc scripts? This could encourage people to start scripting
interesting things in Python, as well as porting existing scripts to Python.

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


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/grass-gui/attachments/20070407/720b0d52/attachment.html
Glynn Clements
2007-11-14 22:56:49 UTC
Permalink
Post by Michael Barton
What would it take to support python scripts like we support bash scripts.
That is, can we have a python script header that is automatically read and
parsed by menuform.py in some structured way to create a nice wxPython GUI
for ad hoc scripts? This could encourage people to start scripting
interesting things in Python, as well as porting existing scripts to Python.
g.parser can be used with any language which supports '#' as a comment
character. See general/g.parser/test.py for an example Python script
which uses g.parser.

The Python GUI can run such scripts with --interface-description to
get module/option/flag information in XML, from which a GUI could be
generated.
--
Glynn Clements <***@gclements.plus.com>
Michael Barton
2007-11-14 22:56:49 UTC
Permalink
That's great. So it's already built in.

Michael
Post by Glynn Clements
Post by Michael Barton
What would it take to support python scripts like we support bash scripts.
That is, can we have a python script header that is automatically read and
parsed by menuform.py in some structured way to create a nice wxPython GUI
for ad hoc scripts? This could encourage people to start scripting
interesting things in Python, as well as porting existing scripts to Python.
g.parser can be used with any language which supports '#' as a comment
character. See general/g.parser/test.py for an example Python script
which uses g.parser.
The Python GUI can run such scripts with --interface-description to
get module/option/flag information in XML, from which a GUI could be
generated.
__________________________________________
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
Michael Barton
2007-11-14 22:56:49 UTC
Permalink
Any idea what would be the python equivalent of the bash lines...

if [ "$1" != "@ARGS_PARSED@" ] ; then
exec g.parser "$0" "$@"
fi

Michael
Post by Glynn Clements
Post by Michael Barton
What would it take to support python scripts like we support bash scripts.
That is, can we have a python script header that is automatically read and
parsed by menuform.py in some structured way to create a nice wxPython GUI
for ad hoc scripts? This could encourage people to start scripting
interesting things in Python, as well as porting existing scripts to Python.
g.parser can be used with any language which supports '#' as a comment
character. See general/g.parser/test.py for an example Python script
which uses g.parser.
The Python GUI can run such scripts with --interface-description to
get module/option/flag information in XML, from which a GUI could be
generated.
__________________________________________
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
Glynn Clements
2007-11-14 22:56:49 UTC
Permalink
Post by Michael Barton
Any idea what would be the python equivalent of the bash lines...
fi
AFAICT:

if ( sys.argv[1] != "@ARGS_PARSED@" ):
os.execv("g.parser", [sys.argv[0]] + sys.argv)
--
Glynn Clements <***@gclements.plus.com>
Michael Barton
2007-11-14 22:56:49 UTC
Permalink
Thanks.

I'll play around and see if it works.

Michael
Post by Glynn Clements
Post by Michael Barton
Any idea what would be the python equivalent of the bash lines...
fi
os.execv("g.parser", [sys.argv[0]] + sys.argv)
__________________________________________
Michael Barton, Professor of Anthropology
School of Human Evolution & Social Change
Center for Social Dynamics and Complexity
Arizona State University

phone: 480-965-6213
fax: 480-965-7671
www: http://www.public.asu.edu/~cmbarton
Jachym Cepicky
2007-11-14 22:56:49 UTC
Permalink
g.manual g.parser ;-)

j
Post by Michael Barton
Thanks.
I'll play around and see if it works.
Michael
Post by Glynn Clements
Post by Michael Barton
Any idea what would be the python equivalent of the bash lines...
fi
os.execv("g.parser", [sys.argv[0]] + sys.argv)
__________________________________________
Michael Barton, Professor of Anthropology
School of Human Evolution & Social Change
Center for Social Dynamics and Complexity
Arizona State University
phone: 480-965-6213
fax: 480-965-7671
www: http://www.public.asu.edu/~cmbarton
_______________________________________________
grassgui mailing list
http://grass.itc.it/mailman/listinfo/grassgui
--
Jachym Cepicky
e-mail: jachym.cepicky gmail com
URL: http://les-ejk.cz
GPG: http://www.les-ejk.cz/pgp/jachym_cepicky-gpg.pub
Glynn Clements
2007-11-14 22:56:49 UTC
Permalink
Post by Jachym Cepicky
Post by Glynn Clements
Post by Michael Barton
Any idea what would be the python equivalent of the bash lines...
fi
os.execv("g.parser", [sys.argv[0]] + sys.argv)
g.manual g.parser ;-)
The example given in the manual page is less than ideal, e.g. using
os.system() instead of os.execv(). This will fail if any of the
arguments contain spaces or other shell metacharacters.
--
Glynn Clements <***@gclements.plus.com>
Jachym Cepicky
2007-11-14 22:56:49 UTC
Permalink
thanks, glynn, I'll try to update

j
Post by Glynn Clements
Post by Jachym Cepicky
Post by Glynn Clements
Post by Michael Barton
Any idea what would be the python equivalent of the bash lines...
fi
os.execv("g.parser", [sys.argv[0]] + sys.argv)
g.manual g.parser ;-)
The example given in the manual page is less than ideal, e.g. using
os.system() instead of os.execv(). This will fail if any of the
arguments contain spaces or other shell metacharacters.
--
--
Jachym Cepicky
e-mail: jachym.cepicky gmail com
URL: http://les-ejk.cz
GPG: http://www.les-ejk.cz/pgp/jachym_cepicky-gpg.pub
Loading...