<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Dec 1, 2014 at 12:00 PM, Markus Neteler <span dir="ltr"><<a href="mailto:neteler@osgeo.org" target="_blank">neteler@osgeo.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><span class="">On Mon, Dec 1, 2014 at 5:45 PM, Glynn Clements <<a href="mailto:glynn@gclements.plus.com">glynn@gclements.plus.com</a>> wrote:<br>
> Vaclav Petras wrote:<br>
><br>
>> > +    env = grass.gisenv()<br>
>> > +    mon = env.get('MONITOR', None)<br>
>> > +    if not mon:<br>
>> > +        grass.fatal(_("No graphics device selected. Use d.mon to select<br>
>> > graphics device."))<br>
>> ><br>
>><br>
>> Is this correct?<br>
><br>
> Not even remotely.<br>
<br>
</span>ok, sorry for the mess. See below for the reason of this attempt:<br>
<span class=""><br>
> I've removed the MONITOR checks from scripts in<br>
> r63315 (except for the ones which are wxGUI commands pretending to be<br>
> display commands; we still need to decide on a suitable prefix for<br>
> those).<br>
<br>
</span>ok.<br>
<br>
The issue is this:<br>
<br>
GRASS 7.1.svn (nc_spm_08_grass7):~ > g.region rast=lsat7_2002_30<br>
GRASS 7.1.svn (nc_spm_08_grass7):~ > d.correlate map=lsat7_2002_30,lsat7_2002_40<br>
ERROR: No graphics device selected. Use d.mon to select graphics device.<br>
Traceback (most recent call last):<br>
  File "/home/neteler/software/grass71/dist.x86_64-unknown-linux-gnu/scripts/d.correlate",<br>
line 104, in <module><br>
    main()<br>
  File "/home/neteler/software/grass71/dist.x86_64-unknown-linux-gnu/scripts/d.correlate",<br>
line 46, in main<br>
    grass.write_command('d.text', color = 'black', size = 4, line = 1,<br>
stdin = "CORRELATION")<br>
  File "/home/neteler/software/grass71/dist.x86_64-unknown-linux-gnu/etc/python/grass/script/core.py",<br>
line 483, in write_command<br>
    return handle_errors(returncode, returncode, args, kwargs)<br>
  File "/home/neteler/software/grass71/dist.x86_64-unknown-linux-gnu/etc/python/grass/script/core.py",<br>
line 308, in handle_errors<br>
    returncode=returncode)<br>
grass.exceptions.CalledModuleError: Module run None ['d.text',<br>
'color=black', 'line=1', 'stdin=CORRELATION', 'size=4'] ended with<br>
error<br>
Process ended with non-zero return code 1. See errors in the (error) output.<br>
<br></blockquote><div>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).<br><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
... looks rather ugly.<br>
The same happens with several other d.* scripts. That's why I<br>
attempted to catch this error. Please suggest how to do it right.<br>
<span class=""><font color="#888888"><br>
Markus<br>
</font></span></blockquote></div><br></div></div>