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/detrend_stack.pl

    r21371 r22430  
    2323use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt );
    2424use Pod::Usage qw( pod2usage );
     25
     26# Look for programs we need
     27my $missing_tools;
     28my $dettool = can_run('dettool') or (warn "Can't find dettool" and $missing_tools = 1);
     29my $ppMerge = can_run('ppMerge') or (warn "Can't find ppMerge" and $missing_tools = 1);
     30my $ppStatsFromMetadata = can_run('ppStatsFromMetadata') or (warn "Can't find ppStatsFromMetadata" and $missing_tools = 1);
     31if ($missing_tools) {
     32    warn("Can't find required tools.");
     33    exit($PS_EXIT_CONFIG_ERROR);
     34}
    2535
    2636my ( $det_id, $iter, $class_id, $det_type, $camera, $outroot, $dbname, $reduction, $threads, $verbose, $save_temps,
     
    5969    or &my_die("Missing entry in file rules", $det_id, $iter, $class_id, $PS_EXIT_CONFIG_ERROR);
    6070
     71# Unhandled exceptions should be passed on to my_die so they get pushed into the database
     72$SIG{__DIE__} = sub { die @_ if $^S;
     73                      my_die( $_[0], $det_id, $iter, $class_id, $PS_EXIT_UNKNOWN_ERROR ); };
     74
    6175# optionally redirect the outputs from this script to LOG.IMFILE
    6276$ipprc->redirect_output($logDest) if $redirect;
     
    6579$reduction = "DETREND" unless defined $reduction;
    6680my $recipe = $ipprc->reduction($reduction, $det_type . '_STACK'); # Recipe name to use
    67 
    68 # Look for programs we need
    69 my $missing_tools;
    70 my $dettool = can_run('dettool') or (warn "Can't find dettool" and $missing_tools = 1);
    71 my $ppMerge = can_run('ppMerge') or (warn "Can't find ppMerge" and $missing_tools = 1);
    72 my $ppStatsFromMetadata = can_run('ppStatsFromMetadata') or (warn "Can't find ppStatsFromMetadata" and $missing_tools = 1);
    73 if ($missing_tools) {
    74     warn("Can't find required tools.");
    75     exit($PS_EXIT_CONFIG_ERROR);
    76 }
    7781
    7882# The output file rule name depends on the detrend type
     
    219223    }
    220224    foreach my $line (@$stdout_buf) {
    221         $cmdflags .= " $line";
     225        $cmdflags .= " $line";
    222226    }
    223227    chomp $cmdflags;
     
    261265        $command .= " -iteration $iter";
    262266        $command .= " -class_id $class_id";
    263         # XXX EAM : we should add this to the db : $command .= " -path_base $outroot";
     267        # XXX EAM : we should add this to the db : $command .= " -path_base $outroot";
    264268        $command .= " -code $exit_code";
    265269        $command .= " -dbname $dbname" if defined $dbname;
Note: See TracChangeset for help on using the changeset viewer.