IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Feb 24, 2009, 12:00:25 PM (17 years ago)
Author:
Paul Price
Message:

Adding handling for missed exceptions, similar to register_imfile.pl --- the idea is to have exceptions trigger the my_die functions so that errors are recorded in the database, and don't go on forever.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ippScripts/scripts/magic_tree.pl

    r20762 r22430  
    3131
    3232use constant MAX_FIELDS => 4;   # Maximum number of fields to be in a node
     33
     34# Look for programs we need
     35my $missing_tools;
     36my $magictool = can_run('magictool') or (warn "Can't find magictool" and $missing_tools = 1);
     37my $warptool = can_run('warptool') or (warn "Can't find warptool" and $missing_tools = 1);
     38if ($missing_tools) {
     39    warn("Can't find required tools.");
     40    exit($PS_EXIT_CONFIG_ERROR);
     41}
    3342
    3443# Parse the command-line arguments
     
    6170    defined $outroot;
    6271
     72# Unhandled exceptions should be passed on to my_die so they get pushed into the database
     73$SIG{__DIE__} = sub { die @_ if $^S;
     74                      my_die( $_[0], $magic_id, $PS_EXIT_UNKNOWN_ERROR ); };
     75
    6376$ipprc->define_camera($camera);
    6477
    6578$ipprc->redirect_output($logfile) if $logfile;
    66 
    67 # Look for programs we need
    68 my $missing_tools;
    69 my $magictool = can_run('magictool') or (warn "Can't find magictool" and $missing_tools = 1);
    70 my $warptool = can_run('warptool') or (warn "Can't find warptool" and $missing_tools = 1);
    71 if ($missing_tools) {
    72     warn("Can't find required tools.");
    73     exit($PS_EXIT_CONFIG_ERROR);
    74 }
    7579
    7680my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files
     
    96100        &my_die("Unable to parse metadata list", $magic_id, $PS_EXIT_PROG_ERROR);
    97101
    98     # make a hash indexed by skycell_id 
     102    # make a hash indexed by skycell_id
    99103    foreach my $warp ( @$warps ) {
    100104        my $skycell_id = $warp->{skycell_id};
     
    156160
    157161    my ($header, $status) = (undef, 0);
    158     my $fits =  Astro::FITS::CFITSIO::open_file( $skyfileResolved, READONLY, $status ); 
     162    my $fits =  Astro::FITS::CFITSIO::open_file( $skyfileResolved, READONLY, $status );
    159163    &my_die("failed to open skycell file: $skyfileResolved: $status", $magic_id, $PS_EXIT_SYS_ERROR) if $status;
    160164
    161165    ($header, $status) = Astro::FITS::CFITSIO::fits_read_header( $fits );
    162    
     166
    163167    &my_die("Unable to read skycell header: $status", $magic_id, $PS_EXIT_SYS_ERROR) if $status;
    164168
     
    171175        $naxis2 = $$header{'NAXIS2'} or &my_die("Can't find NAXIS2", $magic_id, $PS_EXIT_SYS_ERROR);
    172176    } else {
    173         # if the skyfile is compressed then the WCS won't be in the primary header, move to the 
     177        # if the skyfile is compressed then the WCS won't be in the primary header, move to the
    174178        # extension
    175179        my $hdutype;
     
    257261    my $node = shift @tasks;
    258262    divide_node($node, \@tasks);
    259 } 
     263}
    260264
    261265### Format tree for magictool
Note: See TracChangeset for help on using the changeset viewer.