[GRASSGUI] Re: [GRASS-dev] d.rast.edit in wxgrass

Glynn Clements glynn at gclements.plus.com
Fri Jun 15 12:09:02 EDT 2007


Michael Barton wrote:

> >> GRASS command parsing from the wxgrass CLI:
> >> 
> >> Split the command into a list by spaces. I realize that this is a problem
> >> for any command with spaces in the arguments, but I know of no better way to
> >> do this in this context outside of making users type any command as a Python
> >> list. If we made people type ['g.region', 'rast=mymap', 'res=30'] instead of
> >> g.region rast=mymap res=30, I don't think anyone would want to use the CLI.
> > 
> > This is one case where shell=True *is* legitimate. At least with a
> > shell, the user can use quotes or backslashes to include spaces in
> > arguments. Or you could implement equivalent functionality yourself.
> 
> IIUC, if I keep these as strings, I don't think I can use the cmd.Command
> class and would have to do a custom version of Popen. Then I'd have to send
> them through a different processing path rather than the RunCmd method that
> everything else uses.

One option is to call the shell explicitly, i.e.:

	cmd.Command(['/bin/sh', '-c', cmdstr], ....)

or (on Windows):

	cmd.Command(['cmd', '/c', cmdstr], ...)

Simply adding quoting to the existing implementation would probably be
preferable, though.

-- 
Glynn Clements <glynn at gclements.plus.com>




More information about the grass-dev mailing list