> > 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:
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:
> 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?
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.
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.
Ok at utils.py at line 21 I placed:
import shlex
and at the bottom of the file (linhe 424) I placed
def split(s):
return shlex.split(s, posix = (sys.platform != "win32"))
And I still got this error. Did I did something wrong?
It isn't sufficient to add the function; you have to change (some of)
the existing shlex.split() calls to use utils.split() instead.
Hi Glynn
SOrry to bother you and the rest of the people. But when you say that it’sn’t enough, you mean that all shlex.split() shall be substituted by utils.split()? is that it?
Thanks
Luis
Ok at utils.py at line 21 I placed:
import shlex
and at the bottom of the file (linhe 424) I placed
def split(s):
return shlex.split(s, posix = (sys.platform != “win32”))
And I still got this error. Did I did something wrong?
It isn’t sufficient to add the function; you have to change (some of)
the existing shlex.split() calls to use utils.split() instead.
> > Ok at utils.py at line 21 I placed:
> > import shlex
> > and at the bottom of the file (linhe 424) I placed
> > def split(s):
> > return shlex.split(s, posix = (sys.platform != "win32"))
> >
> > And I still got this error. Did I did something wrong?
>
> It isn't sufficient to add the function; you have to change (some of)
> the existing shlex.split() calls to use utils.split() instead.
SOrry to bother you and the rest of the people. But when you say that
it'sn't enough, you mean that all shlex.split() shall be substituted
by utils.split()? is that it?
Yes.
Well, not all of them, but the ones which relate to the command
prompt. Others, e.g. parsing of commands from menudata.xml, shouldn't
depend upon the platform.
Ok at utils.py at line 21 I placed:
import shlex
and at the bottom of the file (linhe 424) I placed
def split(s):
return shlex.split(s, posix = (sys.platform != “win32”))
And I still got this error. Did I did something wrong?
It isn’t sufficient to add the function; you have to change (some of)
the existing shlex.split() calls to use utils.split() instead.
SOrry to bother you and the rest of the people. But when you say that
it’sn’t enough, you mean that all shlex.split() shall be substituted
by utils.split()? is that it?
Yes.
Well, not all of them, but the ones which relate to the command
prompt. Others, e.g. parsing of commands from menudata.xml, shouldn’t
depend upon the platform.
I’m willing to integrate this “fix/work around” in my GRASS installation. I have customized my winGRASS6.4.1 (from early September) with some scripts and some changes in WxGUI. So, I would like to know what you have implemented/changed in the code in order to try to implement in my version. I just need to know what files you have changed/fixed and them using Diff, I can try to spot the differences
and some changes in WxGUI. So, I would like to know what you have
implemented/changed in the code in order to try to implement in my version.
I just need to know what files you have changed/fixed and them using Diff, I
can try to spot the differences