[GRASS-dev] Re: [GRASSGUI] silly question - running a python script

Michael Barton michael.barton at asu.edu
Sun Jun 10 14:21:42 EDT 2007


Glynn,

I went in to change the WIKI, but don't quite have enough information to
make sure that I'm doing it correctly


On 6/10/07 6:57 AM, "Glynn Clements" <glynn at gclements.plus.com> wrote:

> Oh no:
> 
>     for arg in sys.argv:
>         args += arg+" "
> 
> Jesus H %$&%*ing Christ, has no-one read anything I've said over the
> past however-many years about argv[] being an array/list, and not a
> string?
> 
>         os.system("g.parser %s" % (args))


Here is what is currently there...

 if __name__ == "__main__":
     args = ""
     for arg in sys.argv:
         args += arg+" "

     try:
         if ( sys.argv[1] != "@ARGS_PARSED@" ):
             os.system("g.parser %s " % (args))
     except IndexError:
         os.system("g.parser %s" % (args))

     if sys.argv[1] == "@ARGS_PARSED@":
         main();

I found an old email of yours I'd been saving (and couldn't initially find)
that covers part of what needs to be done. Following that, I think it would
change to...

 if __name__ == "__main__":
#     No need to make a string here, right?
#     args = ""
#     for arg in sys.argv:
#         args += arg+" "

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

     if sys.argv[1] == "@ARGS_PARSED@":
         main();

Is this correct or is it still missing something?

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





More information about the grass-dev mailing list