[GRASS-dev] winGRASS: 'g.gui wxpython' fails when installed in "Program Files"

(separating this from locale-related email exchange)

With winGRASS is installed in "Program Files", g.gui wxpython
bails out with this error:

GRASS 6.4.0svn (demolocation)> g.gui wxpython
wxgui: can't open file 'C:/Program': [Errno 2] No such file or directory

Comments:

On Thu, Jan 14, 2010 at 1:22 AM, Glynn Clements
<glynn@gclements.plus.com> wrote:

Glynn Clements wrote:

> > Even if we continue to use _spawn*, the quoting code can be taken from
> > 7.0; see escaped() in lib/gis/spawn.c. The code is actually quite
> > tricky, due to the bizarre quoting rules:
> >
> > http://msdn.microsoft.com/en-us/library/17w5ykft.aspx
>
> Would it be possible for you to suggest a patch?

I'll look into it.

Copying spawn.c from 7.0 seems to work fine. But it's a significant
change, so it should be tested as thoroughly as possible.

Could a developer who has the compile train running, please test this?

Also, fixing
G_spawn() doesn't help with modules which use system() or popen(); I
quite recently replaced most of those in 7.0.

BTW: in looking for test cases, I noticed that neither "g.list -f" nor
"g.mlist -f" work on Windows. E.g.:

sprintf(lister, "%s/etc/lister/%s", G_gisbase(),
list[n].element[0]);

if (access(lister, 1) == 0) { /* execute permission? */
G_spawn(lister, lister, opt.mapset->answer, NULL);
continue;
}

Because the path lacks the .exe suffix, the access() call fails.
G_spawn() itself doesn't need the .exe suffix, but it never gets that
far.

On Thu, Jan 14, 2010 at 7:41 AM, Glynn Clements
<glynn@gclements.plus.com> wrote:

Markus Neteler wrote:

> Because the path lacks the .exe suffix, the access() call fails.
> G_spawn() itself doesn't need the .exe suffix, but it never gets that
> far.

Would this be hell?

#ifndef __MINGW32__
    sprintf(lister, "%s/etc/lister/%s", G_gisbase(),
#else
    sprintf(lister, "%s/etc/lister.exe/%s", G_gisbase(),
#endif

The .exe goes on the end:

#ifndef __MINGW32__
   sprintf(lister, "%s/etc/lister/%s", G_gisbase(),
#else
   sprintf(lister, "%s/etc/lister/%s.exe", G_gisbase(),
#endif

Except ... this requires that the lister is an executable; there's no
fundamental reason why it couldn't be a script, other than the
access() check (well: that, and the fact that G_spawn() etc don't use
the shell currently).

Is that a +/-0 or a -1 for the second patch?

Markus

Markus Neteler wrote:

>> Would this be hell?
>>
>> #ifndef __MINGW32__
>> sprintf(lister, "%s/etc/lister/%s", G_gisbase(),
>> #else
>> sprintf(lister, "%s/etc/lister.exe/%s", G_gisbase(),
>> #endif
>
> The .exe goes on the end:
>
> #ifndef __MINGW32__
> sprintf(lister, "%s/etc/lister/%s", G_gisbase(),
> #else
> sprintf(lister, "%s/etc/lister/%s.exe", G_gisbase(),
> #endif
>
> Except ... this requires that the lister is an executable; there's no
> fundamental reason why it couldn't be a script, other than the
> access() check (well: that, and the fact that G_spawn() etc don't use
> the shell currently).

Is that a +/-0 or a -1 for the second patch?

I'd say +1. Having it only work with a .exe is preferable to it not
working at all.

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

Markus wrote:

With winGRASS is installed in "Program Files", g.gui
wxpython bails out with this error:

GRASS 6.4.0svn (demolocation)> g.gui wxpython
wxgui: can't open file 'C:/Program': [Errno 2] No such file
or directory

try with DEBUG=3

Hamish

On Tue, Jan 19, 2010 at 5:31 AM, Hamish <hamish_b@yahoo.com> wrote:

Markus wrote:

With winGRASS is installed in "Program Files", g.gui
wxpython bails out with this error:

GRASS 6.4.0svn (demolocation)> g.gui wxpython
wxgui: can't open file 'C:/Program': [Errno 2] No such file
or directory

try with DEBUG=3

I think I did but it didn't report anything. Glynn suggested to
substitute spawn.c with the version from GRASS 7.

Markus

Markus Neteler wrote:

>> With winGRASS is installed in "Program Files", g.gui
>> wxpython bails out with this error:
>>
>> GRASS 6.4.0svn (demolocation)> g.gui wxpython
>> wxgui: can't open file 'C:/Program': [Errno 2] No such file
>> or directory
>
> try with DEBUG=3

I think I did but it didn't report anything. Glynn suggested to
substitute spawn.c with the version from GRASS 7.

I've fixed another issue with spawn.c in 7.0 and copied it to 6.5 (not
6.4 yet). I've tested 6.5 on Windows and "g.gui wxpython" works with
spaces in %GISBASE% and/or %GRASS_PYTHON% (all four combinations were
tested).

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

On Tue, Jan 19, 2010 at 12:26 PM, Glynn Clements
<glynn@gclements.plus.com> wrote:

Markus Neteler wrote:

>> With winGRASS is installed in "Program Files", g.gui
>> wxpython bails out with this error:
>>
>> GRASS 6.4.0svn (demolocation)> g.gui wxpython
>> wxgui: can't open file 'C:/Program': [Errno 2] No such file
>> or directory
>
> try with DEBUG=3

I think I did but it didn't report anything. Glynn suggested to
substitute spawn.c with the version from GRASS 7.

I've fixed another issue with spawn.c in 7.0 and copied it to 6.5 (not
6.4 yet). I've tested 6.5 on Windows and "g.gui wxpython" works with
spaces in %GISBASE% and/or %GRASS_PYTHON% (all four combinations were
tested).

For the record: backported to 6.4 and it works as well.

Markus