[GRASS-dev] [GRASS GIS] #1198: Error while parsing file paths in WiNGRASS with Python Script

#1198: Error while parsing file paths in WiNGRASS with Python Script
----------------------------+-----------------------------------------------
Reporter: luislisboa1975 | Owner: grass-dev@…
     Type: defect | Status: new
Priority: major | Milestone: 6.4.1
Component: wxGUI | Version: svn-releasebranch64
Keywords: | Platform: MSWindows XP
      Cpu: Unspecified |
----------------------------+-----------------------------------------------
In a Python Script, in WinGRASS6.4.1(svn) all "\" in file paths are
eliminated.
It only runs if users use "/"

This topic is related with:
http://lists.osgeo.org/pipermail/grass-user/2010-October/058320.html
http://lists.osgeo.org/pipermail/grass-user/2010-October/058322.html
http://lists.osgeo.org/pipermail/grass-dev/2010-October/052396.html

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/1198&gt;
GRASS GIS <http://grass.osgeo.org>

#1198: Error while parsing file paths in WiNGRASS with Python Script
----------------------------+-----------------------------------------------
Reporter: luislisboa1975 | Owner: grass-dev@…
     Type: defect | Status: new
Priority: major | Milestone: 6.4.1
Component: wxGUI | Version: svn-releasebranch64
Keywords: wingrass | Platform: MSWindows XP
      Cpu: Unspecified |
----------------------------+-----------------------------------------------
Changes (by hellik):

  * keywords: => wingrass

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/1198#comment:1&gt;
GRASS GIS <http://grass.osgeo.org>

#1198: Error while parsing file paths in WiNGRASS with Python Script
----------------------------+-----------------------------------------------
Reporter: luislisboa1975 | Owner: grass-dev@…
     Type: defect | Status: new
Priority: major | Milestone: 6.4.1
Component: wxGUI | Version: svn-releasebranch64
Keywords: wingrass | Platform: MSWindows XP
      Cpu: Unspecified |
----------------------------+-----------------------------------------------

Comment(by hamish):

is this from within a specific grass module, from the wxGUI command entry
box, or from a self-written script?

the `\` is used to quote the character which follows it verbatim.

so `C:\Program Files\GRASS\scripts` reduces to `C:Program
FilesGRASSscripts`.

one solution as pointed out is to use `/` instead. Another way is to use
two of them, so that the second one gets quoted verbatim: `\\`.

ISTR that some OS-specific magic was added to the wxGUI command parser,
but I suspect the solution to this will ultimately be education:
gratuitous tooltips and inset Caution-boxes in the wxGUI help pages.

Hamish

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/1198#comment:2&gt;
GRASS GIS <http://grass.osgeo.org>

#1198: Error while parsing file paths in WiNGRASS with Python Script
----------------------------+-----------------------------------------------
Reporter: luislisboa1975 | Owner: grass-dev@…
     Type: defect | Status: new
Priority: major | Milestone: 6.4.1
Component: wxGUI | Version: svn-releasebranch64
Keywords: wingrass | Platform: MSWindows XP
      Cpu: Unspecified |
----------------------------+-----------------------------------------------

Comment(by benducke):

Actually, the problem goes deeper than the wxGUI. I have experienced it
(Windows only) with shell scripts. Basically, g.parser seems to remove all
occurrences of "\" from a file type input or output option. I think this
should be fixed in g.parser, not by forcing Windows users to adopt a
notation that is strange on their system. In addition, the option value
may come from a Windows file browser, which will certainly produce the "\"
Windows notation.

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/1198#comment:3&gt;
GRASS GIS <http://grass.osgeo.org>

#1198: Error while parsing file paths in WinGRASS with Scripts
----------------------------+-----------------------------------------------
Reporter: luislisboa1975 | Owner: grass-dev@…
     Type: defect | Status: new
Priority: major | Milestone: 6.4.1
Component: wxGUI | Version: svn-releasebranch64
Keywords: wingrass | Platform: MSWindows XP
      Cpu: Unspecified |
----------------------------+-----------------------------------------------

Comment(by hamish):

see also #1280

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/1198#comment:4&gt;
GRASS GIS <http://grass.osgeo.org>

#1198: Error while parsing file paths in WinGRASS with Scripts
----------------------------+-----------------------------------------------
Reporter: luislisboa1975 | Owner: grass-dev@…
     Type: defect | Status: new
Priority: major | Milestone: 6.4.1
Component: wxGUI | Version: svn-releasebranch64
Keywords: wingrass | Platform: MSWindows XP
      Cpu: Unspecified |
----------------------------+-----------------------------------------------

Comment(by glynn):

Replying to [comment:3 benducke]:
> Actually, the problem goes deeper than the wxGUI. I have experienced it
(Windows only) with shell scripts. Basically, g.parser seems to remove all
occurrences of "\" from a file type input or output option. I think this
should be fixed in g.parser, not by forcing Windows users to adopt a
notation that is strange on their system. In addition, the option value
may come from a Windows file browser, which will certainly produce the "\"
Windows notation.

It isn't g.parser doing this. It's either wxGUI (e.g. shlex.split) or the
shell.

In any case, this ticket contains insufficient information to attempt
reproduction. At a minimum, we require the exact command entered, the
means by which it was entered (cmd.exe, bash, wxGUI, etc), the GRASS
version, and the result.

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/1198#comment:5&gt;
GRASS GIS <http://grass.osgeo.org>

#1198: Error while parsing file paths in WinGRASS with Scripts
----------------------------+-----------------------------------------------
Reporter: luislisboa1975 | Owner: grass-dev@…
     Type: defect | Status: new
Priority: major | Milestone: 6.4.1
Component: wxGUI | Version: svn-releasebranch64
Keywords: wingrass | Platform: MSWindows XP
      Cpu: Unspecified |
----------------------------+-----------------------------------------------

Comment(by mmetz):

Replying to [comment:5 glynn]:
> Replying to [comment:3 benducke]:
> > Actually, the problem goes deeper than the wxGUI. I have experienced
it (Windows only) with shell scripts. Basically, g.parser seems to remove
all occurrences of "\" from a file type input or output option. I think
this should be fixed in g.parser, not by forcing Windows users to adopt a
notation that is strange on their system. In addition, the option value
may come from a Windows file browser, which will certainly produce the "\"
Windows notation.
>
> It isn't g.parser doing this. It's either wxGUI (e.g. shlex.split) or
the shell.

> In any case, this ticket contains insufficient information to attempt
reproduction. At a minimum, we require the exact command entered, the
means by which it was entered (cmd.exe, bash, wxGUI, etc), the GRASS
version, and the result.

I think #1447 is related, and complete with an example and a detailed
description.

Markus M

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/1198#comment:6&gt;
GRASS GIS <http://grass.osgeo.org>

#1198: Error while parsing file paths in WinGRASS with Scripts
----------------------------+-----------------------------------------------
Reporter: luislisboa1975 | Owner: grass-dev@…
     Type: defect | Status: new
Priority: major | Milestone: 6.4.1
Component: wxGUI | Version: svn-releasebranch64
Keywords: wingrass | Platform: MSWindows XP
      Cpu: Unspecified |
----------------------------+-----------------------------------------------

Comment(by hamish):

continued in #1447 ...

closing this one.

Hamish

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/1198#comment:7&gt;
GRASS GIS <http://grass.osgeo.org>

#1198: Error while parsing file paths in WinGRASS with Scripts
-----------------------------+----------------------------------------------
  Reporter: luislisboa1975 | Owner: grass-dev@…
      Type: defect | Status: closed
  Priority: major | Milestone: 6.4.1
Component: wxGUI | Version: svn-releasebranch64
Resolution: duplicate | Keywords: wingrass
  Platform: MSWindows XP | Cpu: Unspecified
-----------------------------+----------------------------------------------
Changes (by hamish):

  * status: new => closed
  * resolution: => duplicate

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/1198#comment:8&gt;
GRASS GIS <http://grass.osgeo.org>