[GRASS-dev] [GRASS GIS] #3200: r.colors is lacking color bars for all predefined colortables

#3200: r.colors is lacking color bars for all predefined colortables
--------------------------------+-------------------------
Reporter: milenan | Owner: grass-dev@…
     Type: defect | Status: new
Priority: normal | Milestone: 7.0.6
Component: Default | Version: 7.0.5
Keywords: r.colors, v.colors | CPU: x86-64
Platform: MSWindows 8 |
--------------------------------+-------------------------
In wxGUI dialog of r.colors drop down list the color bars are missing
under Windows

I discovered in
https://wingrass.fsv.cvut.cz/grass72/x86_64/logs/log-r69771-56/package.log
the following bug:
{{{
mingw32/lib:/usr/bin:/mingw64/bin/:/c/OSGeo4W64/bin:/c/msys64/usr/src/grass72_release/mswindows/osgeo4w/lib"
LC_ALL=C /c/msys64/usr/src/grass72_release/tools/thumbnails.py
WARNING: No data base element files found
Traceback (most recent call last):
   File "C:/msys64/usr/src/grass72_release/tools/thumbnails.py", line 206,
in <module>
     main()
   File "C:/msys64/usr/src/grass72_release/tools/thumbnails.py", line 198,
in main
     make_image(output_dir, table, grad)
   File "C:/msys64/usr/src/grass72_release/tools/thumbnails.py", line 157,
in make_image
     convert_and_rotate(tmp_img, outfile, discrete)
   File "C:/msys64/usr/src/grass72_release/tools/thumbnails.py", line 105,
in convert_and_rotate
     ppmtopng(dst, tmp_img)
   File "C:/msys64/usr/src/grass72_release/tools/thumbnails.py", line 89,
in ppmtopng
     grass.run_command('g.ppmtopng', input = src, output = dst, quiet =
True)
   File
"C:\msys64\usr\src\grass72_release\dist.x86_64-w64-mingw32\etc\python/grass/script/core.py",
line 410, in run_command
     return handle_errors(returncode, returncode, args, kwargs)
   File
"C:\msys64\usr\src\grass72_release\dist.x86_64-w64-mingw32\etc\python/grass/script/core.py",
line 329, in handle_errors
     returncode=returncode)
grass.exceptions.CalledModuleError: Module run None ['g.ppmtopng', '--q',
'input=C:/msys64/usr/src/grass72_release/dist.x86_64-w64-mingw32\\demolocation\\PERMANENT\\.tmp/unknown\\4072.0.ppm',
'output=C:/msys64/usr/src/grass72_release/dist.x86_64-w64-mingw32\\docs\\html\\colortables\\aspect.png']
ended with error
Process ended with non-zero return code -1073741819. See errors in the
(error) output.
Makefile:16: recipe for target 'thumbnails' failed
make[4]: [thumbnails] Error 1 (ignored)
}}}

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

#3200: r.colors is lacking color bars for all predefined colortables
----------------------+--------------------------------
  Reporter: milenan | Owner: grass-dev@…
      Type: defect | Status: new
  Priority: normal | Milestone: 7.0.6
Component: Default | Version: 7.0.5
Resolution: | Keywords: r.colors, v.colors
       CPU: x86-64 | Platform: MSWindows 8
----------------------+--------------------------------

Comment (by mlennert):

A bit of a wild guess, but in thumbnails.py I see that the ppm files are
created with:

{{{
def write_ppm(dst, data):
     w = height
     h = width
     fh = open(dst, "wb")
     fh.write("P6\n%d %d\n%d\n" % (w, h, 255))
     data.tofile(fh)
     fh.close()
}}}

Could it be that the '\n' are causing problems on Windows ?

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

#3200: r.colors is lacking color bars for all predefined colortables
----------------------+--------------------------------
  Reporter: milenan | Owner: grass-dev@…
      Type: defect | Status: new
  Priority: normal | Milestone: 7.0.6
Component: Default | Version: 7.0.5
Resolution: | Keywords: r.colors, v.colors
       CPU: x86-64 | Platform: MSWindows 8
----------------------+--------------------------------

Comment (by annakrat):

The ppm is created, the problem is in g.ppmtopng, it crashed on windows
during writing the png.

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

#3200: r.colors is lacking color bars for all predefined colortables
----------------------+--------------------------------
  Reporter: milenan | Owner: grass-dev@…
      Type: defect | Status: new
  Priority: normal | Milestone: 7.0.6
Component: Default | Version: 7.0.5
Resolution: | Keywords: r.colors, v.colors
       CPU: x86-64 | Platform: MSWindows 8
----------------------+--------------------------------

Comment (by annakrat):

Replying to [comment:2 annakrat]:
> The ppm is created, the problem is in g.ppmtopng, it crashed on windows
during writing the png.

The script generating thumbnails could be rewritten with PIL for example,
instead of using g.ppmtopng. Or, ideally the functionality would be added
to d.colortable to flip and rotate the table. Then the script would become
quite short.

Related ticket: #3156

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

#3200: r.colors is lacking color bars for all predefined colortables
----------------------+--------------------------------
  Reporter: milenan | Owner: grass-dev@…
      Type: defect | Status: new
  Priority: normal | Milestone: 7.0.6
Component: Default | Version: 7.0.5
Resolution: | Keywords: r.colors, v.colors
       CPU: x86-64 | Platform: MSWindows 8
----------------------+--------------------------------

Comment (by mlennert):

Replying to [comment:2 annakrat]:
> The ppm is created, the problem is in g.ppmtopng, it crashed on windows
during writing the png.

Yes, my question was whether the fact of writing the file with '\n' line
endings could cause issues in reading it in g.ppmtopng. But as I said:
wild guess. I suppose this worked before with these same line endings ?

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

#3200: r.colors is lacking color bars for all predefined colortables
----------------------+--------------------------------
  Reporter: milenan | Owner: grass-dev@…
      Type: defect | Status: new
  Priority: normal | Milestone: 7.0.6
Component: Default | Version: 7.0.5
Resolution: | Keywords: r.colors, v.colors
       CPU: x86-64 | Platform: MSWindows 8
----------------------+--------------------------------

Comment (by annakrat):

Replying to [comment:4 mlennert]:
> Replying to [comment:2 annakrat]:
> > The ppm is created, the problem is in g.ppmtopng, it crashed on
windows during writing the png.
>
> Yes, my question was whether the fact of writing the file with '\n' line
endings could cause issues in reading it in g.ppmtopng. But as I said:
wild guess. I suppose this worked before with these same line endings ?

I think Python takes care of that automatically. The generated ppm looks
fine, so I think it's really about writing the png.

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

#3200: r.colors is lacking color bars for all predefined colortables
-------------------------+-------------------------------------------------
  Reporter: milenan | Owner: wenzeslaus
      Type: defect | Status: new
  Priority: normal | Milestone: 7.2.1
Component: Docs | Version: 7.0.5
Resolution: | Keywords: r.colors, v.colors, g.ppmtopng,
                         | d.colortable, doc, man, wxGUI
       CPU: x86-64 | Platform: MSWindows 8
-------------------------+-------------------------------------------------
Changes (by wenzeslaus):

* owner: grass-dev@… => wenzeslaus
* keywords: r.colors, v.colors => r.colors, v.colors, g.ppmtopng,
     d.colortable, doc, man, wxGUI
* component: Default => Docs
* milestone: 7.0.6 => 7.2.1

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