[GRASS-dev] [GRASS GIS] #3162: Quote script module path when calling its gui from parser

#3162: Quote script module path when calling its gui from parser
-------------------------+-------------------------
Reporter: marisn | Owner: grass-dev@…
     Type: defect | Status: new
Priority: normal | Milestone: 7.4.0
Component: Parser | Version: svn-trunk
Keywords: | CPU: Unspecified
Platform: Unspecified |
-------------------------+-------------------------
Currently parser will fail if a script module path contains spaces:
{{{
grass_trunk > python /home/maris/nezinatniskie_projekti/Zinatnes\ nakts\
2016/gol.py
Traceback (most recent call last):
   File "/home/maris/soft/grass_trunk/dist.x86_64-pc-linux-
gnu/gui/wxpython/gui_core/forms.py", line 2962, in <module>
     task.set_options(cmd[1:])
   File "/home/maris/soft/grass_trunk/dist.x86_64-pc-linux-
gnu/etc/python/grass/script/task.py", line 299, in set_options
     key, value = opt.split('=', 1)
ValueError: need more than 1 value to unpack
}}}

The problem comes from recreate_command in lib/gis/parser.c invoking
forms.py and passing all args as a single string. Forms.py expect each
space to be an argument separator thus causing failure in option parsing.
Easiest workaround is to quote module path and name while calling
forms.py.

I'm attaching patch that provides required quoting and thus allows to have
script modules to be located in a path with spaces. As parser is quite
sensitive thing (too easy to break something by accident), I haven't it
applied to svn myself to get some feedback first. If it will be considered
to be safe, backport to all 7.x is needed.

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

#3162: Quote script module path when calling its gui from parser
--------------------------+-------------------------
  Reporter: marisn | Owner: grass-dev@…
      Type: defect | Status: new
  Priority: normal | Milestone: 7.4.0
Component: Parser | Version: svn-trunk
Resolution: | Keywords:
       CPU: Unspecified | Platform: Unspecified
--------------------------+-------------------------
Changes (by marisn):

* Attachment "parser_quote_prog_name.patch" added.

lib/gis/parser.c patch quoting program name

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

#3162: Quote script module path when calling its gui from parser
--------------------------+-------------------------
  Reporter: marisn | Owner: grass-dev@…
      Type: defect | Status: new
  Priority: normal | Milestone: 7.4.0
Component: Parser | Version: svn-trunk
Resolution: | Keywords: python
       CPU: Unspecified | Platform: Unspecified
--------------------------+-------------------------
Changes (by marisn):

* keywords: => python

Comment:

Ping Pythonistas. Is it safe to commit this patch or forms.py should be
changed?

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

#3162: Quote script module path when calling its gui from parser
--------------------------+-------------------------
  Reporter: marisn | Owner: grass-dev@…
      Type: defect | Status: new
  Priority: normal | Milestone: 7.4.2
Component: Parser | Version: svn-trunk
Resolution: | Keywords: python
       CPU: Unspecified | Platform: Unspecified
--------------------------+-------------------------

Comment (by neteler):

Replying to [comment:1 marisn]:
> Ping Pythonistas. Is it safe to commit this patch or forms.py should be
changed?

Perhaps apply the patch in trunk? Otherwise feedback does not seem to come
up...

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