[GRASS-dev] Re: [GRASS-user] Error when importing data in Windows with Python Script

Glynn Clements glynn at gclements.plus.com
Mon Oct 18 09:24:02 EDT 2010


Luis Lisboa wrote:

> > No, but wxGUI's "command prompt" is using shlex.split(), which mimics
> > a typical Unix shell:
> >
> >        >>> shlex.split(r'C:\Data\L5216065_06520070405_B70.TIF')
> >        ['C:DataL5216065_06520070405_B70.TIF']
> >
> > I suspect that it should have "posix = False" on Windows:
> >
> >        >>> shlex.split(r'C:\Data\L5216065_06520070405_B70.TIF', posix =
> > False)
> >        ['C:\\Data\\L5216065_06520070405_B70.TIF']
> 
> About this, What can i do to fix this? Or isn't anything I can do?

I suggest filing a bug report via http://trac.osgeo.org/grass/

In terms of a fix ... in gui_modules/utils.py, add:

	import shlex

	def split(s):
	    return shlex.split(s, posix = (sys.platform != "win32"))

The tricky part is deciding which occurrences of shlex.split() should
be replaced. It's possible that some of them need to retain the POSIX
syntax conventions (where a backslash quotes the following character). 
I suspect that those in prompt.py should be changed, but I'm not sure
about the others.

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


More information about the grass-dev mailing list