[GRASS-dev] [GRASS-SVN] r63227 - in grass/trunk/scripts: d.correlate d.out.file d.rast.leg d.redraw d.shadedmap d.to.rast d.vect.thematic d.what.rast d.what.vect

Vaclav Petras wenzeslaus at gmail.com
Mon Dec 1 09:50:47 PST 2014


On Mon, Dec 1, 2014 at 12:00 PM, Markus Neteler <neteler at osgeo.org> wrote:

> On Mon, Dec 1, 2014 at 5:45 PM, Glynn Clements <glynn at gclements.plus.com>
> wrote:
> > Vaclav Petras wrote:
> >
> >> > +    env = grass.gisenv()
> >> > +    mon = env.get('MONITOR', None)
> >> > +    if not mon:
> >> > +        grass.fatal(_("No graphics device selected. Use d.mon to
> select
> >> > graphics device."))
> >> >
> >>
> >> Is this correct?
> >
> > Not even remotely.
>
> ok, sorry for the mess. See below for the reason of this attempt:
>
> > I've removed the MONITOR checks from scripts in
> > r63315 (except for the ones which are wxGUI commands pretending to be
> > display commands; we still need to decide on a suitable prefix for
> > those).
>
> ok.
>
> The issue is this:
>
> GRASS 7.1.svn (nc_spm_08_grass7):~ > g.region rast=lsat7_2002_30
> GRASS 7.1.svn (nc_spm_08_grass7):~ > d.correlate
> map=lsat7_2002_30,lsat7_2002_40
> ERROR: No graphics device selected. Use d.mon to select graphics device.
> Traceback (most recent call last):
>   File
> "/home/neteler/software/grass71/dist.x86_64-unknown-linux-gnu/scripts/d.correlate",
> line 104, in <module>
>     main()
>   File
> "/home/neteler/software/grass71/dist.x86_64-unknown-linux-gnu/scripts/d.correlate",
> line 46, in main
>     grass.write_command('d.text', color = 'black', size = 4, line = 1,
> stdin = "CORRELATION")
>   File
> "/home/neteler/software/grass71/dist.x86_64-unknown-linux-gnu/etc/python/grass/script/core.py",
> line 483, in write_command
>     return handle_errors(returncode, returncode, args, kwargs)
>   File
> "/home/neteler/software/grass71/dist.x86_64-unknown-linux-gnu/etc/python/grass/script/core.py",
> line 308, in handle_errors
>     returncode=returncode)
> grass.exceptions.CalledModuleError: Module run None ['d.text',
> 'color=black', 'line=1', 'stdin=CORRELATION', 'size=4'] ended with
> error
> Process ended with non-zero return code 1. See errors in the (error)
> output.
>
> The d.correlate script does not check if the modules it is calling were
successful. It is not limited to not set MONITOR problem, the errors can
potentially happen from other reasons too. The standard way how to solve it
is to have all module calls in a try-except (one big or more smaller ones)
and do whatever is necessary in except (e.g. exit). The except should catch
CalledModuleError and perhaps use its message or better module name (not
implemented yet).


> ... looks rather ugly.
> The same happens with several other d.* scripts. That's why I
> attempted to catch this error. Please suggest how to do it right.
>
> Markus
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/grass-dev/attachments/20141201/c9fff09c/attachment.html>


More information about the grass-dev mailing list