[GRASS-dev] Re: [GRASS-CVS] michael: grass6/gui/tcltk/gis.m mapcanvas.tcl, 1.52, 1.53

Hamish hamish_nospam at yahoo.com
Thu Nov 30 01:45:56 EST 2006


Hamish:
> > I was making it fail by renaming /usr/lib/libgdal.* to something
> > else.

Michael:
> I got the GIS Manager to fail differently when I messed with GDAL
> instead of messing with g.region. The place to trap this seems to be
> the line.
> 
> catch {close $input}
> 
> Replace this line with...
> 
>         if {[catch {close $input} error]} {
>             puts $error
>             exit
>         }
> 
> We still need to keep the other else clause with 'puts $input' to
> catch cases where there is a different problem with g.region.


Great work. For me the latest version in CVS fails nicely for both the
missing libgdal.so and missing g.region cases. (I only tested 6.3-cvs)

I made a slight change in 6.3-cvs: exit with return code of "1" on
error. (unlike bash, tcl's "exit" defaults to "0" if not given; bash
defaults to the return code of the last command run if not given)

As the gis.m script runs gm.tcl via "exec" this doesn't really have any
effect AFAICT, but it's good practice.



oh, and FWIW I figured out why my tcl exec solution was failing with:
 ERROR: region <> not found
It was trying to run `g.region ""`  (expands to `g.region region=""`)

It's redundant now, but for the record adding a "concat" fixed it:

-set regcmd [list exec "g.region" "-ug" $args]
+set regcmd [list exec "g.region" [concat "-ug " $args]]
 set retval [catch $regcmd result]
 if { $retval } {
    puts "Failed to run command:\n $result"
    exit 1
 }
 puts "result is: $result"



Hamish

ps- always "cvs diff -u" before "cvs commit" !!




More information about the grass-dev mailing list