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

Glynn Clements glynn at gclements.plus.com
Fri Oct 15 13:08:36 EDT 2010


[CC to grass-dev]

Luis Lisboa wrote:

> > > I'm running a Python script in WinGRASS6.4 but when I insert as the input
> > > C:\Data\L5216065_06520070405_B70.TIF
> > >
> > > inside Python Script, the input is:
> > > C:DataL5216065_06520070405_B10.TIF
> > >
> > > I realized that, if I, by-hand, i change the \ by / it runs ok.
> > >
> > > is it possible to have an automatic process to change this instead of
> > having
> > > the users doing this by-hand?
> >
> > How are you running the script? If you run it via bash, any
> > backslashes will be interpreted before the script is executed. There
> > isn't anything the script can do about this.
> 
> I'm running via WxGUI's modules. I use the browse button to find the file
> and it automatically places the path tot the file. Is this via Bash?

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']

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


More information about the grass-dev mailing list