[GRASS-dev] Re: [GRASS-SVN] r46061 - grass/trunk/lib/python

Glynn Clements glynn at gclements.plus.com
Fri Apr 22 11:47:51 EDT 2011


Martin Landa wrote:

> please can you explain your commit?
> 
> Martin
> 
> 2011/4/21  <svn_grass at osgeo.org>:
> > Author: glynn
> > Date: 2011-04-21 06:37:46 -0700 (Thu, 21 Apr 2011)
> > New Revision: 46061
> >
> > Modified:
> >   grass/trunk/lib/python/core.py
> > Log:
> > Revert raise_on_error fiasco

It just reverted the last two commits.

Whether or not you want an exception to be raised if the command fails
(non-zero exit code) bears no relation to the desired output format or
whether to redirect stderr (stderr isn't just for errors).

Aside from the design, the implementation left a lot to be desired
(almost-identical blocks of code added to several functions).

If you want a global "capture stderr" mechanism (which should be
separate from the exit code check), the "before" part should go into
start_command() and the "after" part should be a separate function, so
that it applies to all of the wrappers equally (with the exception of
exec_command(), all of the other *_command() functions are wrappers
around start_command()).

But even that's getting to the point where it might be better to
create a subclass of Popen() to encapsulate this functionality.

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


More information about the grass-dev mailing list