[GRASS-dev] G.region bug when setting 3d resolution??? Maybe not

Glynn Clements glynn at gclements.plus.com
Fri Jan 5 07:41:34 EST 2007


Michael Barton wrote:

> > 1. Merge the output of stdout and stderr for any commands called like
> > this, by adding "|& $env(GISBASE)/etc/grocat" to the end of the command
> > line.
> > Reason: This will stop Tcl bombing out completely if anything is written
> > to stderr (a warning or message, for example).
> 
> I think some other solution would be better for two reasons. First, this
> construction calls a *nix command from within TclTk. This is problematic for
> Windows. A pure TclTk construction would be better. Second, in the most
> recent set of problems with g.region, I'm not sure if this would help all
> that much anyway. The GUI was reading the text output from g.region -g OK,
> the problem is that it was the wrong output. It was expecting [key]=[value].
> The first [key] included the warning message. This gave a key that was not
> recognizable by the subsequent routine that tried to process the key to get
> region values. For this particular routine, a 'catch' command is already in
> place to trap real errors and move on. In fact, an error will cause the GUI
> to quit relatively gracefully with the GRASS error printed to the terminal.
> I implemented this, working with Hamish to solve a recurrent problem that
> caused the GUI to give somewhat misleading error messages when GRASS was
> improperly installed (usually a gdal installation problem).

Part of the problem here is that you're running into the limitations
of Tcl/Tk's process management.

AFAICT, Python provides more powerful process management, e.g. 
os.popen3 returns separate pipes for each of stdin, stdout, and
stderr, so you don't have to merge or discard stderr.

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




More information about the grass-dev mailing list