python scripting support?

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

python scripting support?

Michael Barton
python scripting support? 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


_______________________________________________
grassgui mailing list
[hidden email]
http://grass.itc.it/mailman/listinfo/grassgui
Reply | Threaded
Open this post in threaded view
|

Re: python scripting support?

Glynn Clements

Michael Barton wrote:

> 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 <[hidden email]>

_______________________________________________
grassgui mailing list
[hidden email]
http://grass.itc.it/mailman/listinfo/grassgui
Reply | Threaded
Open this post in threaded view
|

Re: python scripting support?

Michael Barton
That's great. So it's already built in.

Michael


On 4/8/07 4:33 AM, "Glynn Clements" <[hidden email]> wrote:

>
> Michael Barton wrote:
>
>> 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


_______________________________________________
grassgui mailing list
[hidden email]
http://grass.itc.it/mailman/listinfo/grassgui
Reply | Threaded
Open this post in threaded view
|

Re: python scripting support?

Michael Barton
In reply to this post by Glynn Clements
Any idea what would be the python equivalent of the bash lines...

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

Michael

On 4/8/07 4:33 AM, "Glynn Clements" <[hidden email]> wrote:

>
> Michael Barton wrote:
>
>> 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


_______________________________________________
grassgui mailing list
[hidden email]
http://grass.itc.it/mailman/listinfo/grassgui
Reply | Threaded
Open this post in threaded view
|

Re: python scripting support?

Glynn Clements

Michael Barton wrote:

> Any idea what would be the python equivalent of the bash lines...
>
> if [ "$1" != "@ARGS_PARSED@" ] ; then
>   exec g.parser "$0" "$@"
> fi

AFAICT:

        if ( sys.argv[1] != "@ARGS_PARSED@" ):
                os.execv("g.parser", [sys.argv[0]] + sys.argv)

--
Glynn Clements <[hidden email]>

_______________________________________________
grassgui mailing list
[hidden email]
http://grass.itc.it/mailman/listinfo/grassgui
Reply | Threaded
Open this post in threaded view
|

Re: python scripting support?

Michael Barton
Thanks.

I'll play around and see if it works.

Michael


On 4/9/07 8:10 AM, "Glynn Clements" <[hidden email]> wrote:

>
> Michael Barton wrote:
>
>> Any idea what would be the python equivalent of the bash lines...
>>
>> if [ "$1" != "@ARGS_PARSED@" ] ; then
>>   exec g.parser "$0" "$@"
>> fi
>
> AFAICT:
>
> if ( sys.argv[1] != "@ARGS_PARSED@" ):
> 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
[hidden email]
http://grass.itc.it/mailman/listinfo/grassgui
Reply | Threaded
Open this post in threaded view
|

Re: python scripting support?

Jachym Cepicky
g.manual g.parser ;-)

j

2007/4/9, Michael Barton <[hidden email]>:

> Thanks.
>
> I'll play around and see if it works.
>
> Michael
>
>
> On 4/9/07 8:10 AM, "Glynn Clements" <[hidden email]> wrote:
>
> >
> > Michael Barton wrote:
> >
> >> Any idea what would be the python equivalent of the bash lines...
> >>
> >> if [ "$1" != "@ARGS_PARSED@" ] ; then
> >>   exec g.parser "$0" "$@"
> >> fi
> >
> > AFAICT:
> >
> > if ( sys.argv[1] != "@ARGS_PARSED@" ):
> > 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
> [hidden email]
> 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

_______________________________________________
grassgui mailing list
[hidden email]
http://grass.itc.it/mailman/listinfo/grassgui
Reply | Threaded
Open this post in threaded view
|

Re: python scripting support?

Glynn Clements

Jachym Cepicky wrote:

> > >> Any idea what would be the python equivalent of the bash lines...
> > >>
> > >> if [ "$1" != "@ARGS_PARSED@" ] ; then
> > >>   exec g.parser "$0" "$@"
> > >> fi
> > >
> > > AFAICT:
> > >
> > > if ( sys.argv[1] != "@ARGS_PARSED@" ):
> > > 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 <[hidden email]>

_______________________________________________
grassgui mailing list
[hidden email]
http://grass.itc.it/mailman/listinfo/grassgui
Reply | Threaded
Open this post in threaded view
|

Re: python scripting support?

Jachym Cepicky
thanks, glynn, I'll try to update

j

2007/4/10, Glynn Clements <[hidden email]>:

>
> Jachym Cepicky wrote:
>
> > > >> Any idea what would be the python equivalent of the bash lines...
> > > >>
> > > >> if [ "$1" != "@ARGS_PARSED@" ] ; then
> > > >>   exec g.parser "$0" "$@"
> > > >> fi
> > > >
> > > > AFAICT:
> > > >
> > > > if ( sys.argv[1] != "@ARGS_PARSED@" ):
> > > > 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 <[hidden email]>
>


--
Jachym Cepicky
e-mail: jachym.cepicky gmail com
URL: http://les-ejk.cz
GPG: http://www.les-ejk.cz/pgp/jachym_cepicky-gpg.pub

_______________________________________________
grassgui mailing list
[hidden email]
http://grass.itc.it/mailman/listinfo/grassgui