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

    r21371 r22430  
    2929use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt );
    3030use Pod::Usage qw( pod2usage );
     31
     32# Look for programs we need
     33my $missing_tools;
     34my $stacktool = can_run('stacktool') or (warn "Can't find stacktool" and $missing_tools = 1);
     35my $ppStack = can_run('ppStack') or (warn "Can't find ppStack" and $missing_tools = 1);
     36my $ppConfigDump = can_run('ppConfigDump') or (warn "Can't find ppConfigDump" and $missing_tools = 1);
     37my $ppStatsFromMetadata = can_run('ppStatsFromMetadata') or (warn "Can't find ppStatsFromMetadata" and $missing_tools = 1);
     38if ($missing_tools) {
     39    warn("Can't find required tools.");
     40    exit($PS_EXIT_CONFIG_ERROR);
     41}
    3142
    3243my ($stack_id, $dbname, $outroot, $debug, $run_state, $threads, $reduction, $verbose, $no_update, $no_op, $redirect, $save_temps);
     
    5566    and defined $run_state;
    5667
     68# Unhandled exceptions should be passed on to my_die so they get pushed into the database
     69$SIG{__DIE__} = sub { die @_ if $^S;
     70                      my_die( $_[0], $stack_id, $PS_EXIT_UNKNOWN_ERROR ); };
     71
    5772# XXX camera is not known here; cannot use filerules...
    5873# my $logDest = $ipprc->filename("LOG.EXP", $outroot);
    59 
    6074my $logDest = "$outroot.log";
    6175
     
    7286my $image_id = $stack_id;
    7387my $source_id = $ipprc->source_id($dbname, $PS_TABLE_ID_STACK);
    74 
    75 # Look for programs we need
    76 my $missing_tools;
    77 my $stacktool = can_run('stacktool') or (warn "Can't find stacktool" and $missing_tools = 1);
    78 my $ppStack = can_run('ppStack') or (warn "Can't find ppStack" and $missing_tools = 1);
    79 my $ppConfigDump = can_run('ppConfigDump') or (warn "Can't find ppConfigDump" and $missing_tools = 1);
    80 my $ppStatsFromMetadata = can_run('ppStatsFromMetadata') or (warn "Can't find ppStatsFromMetadata" and $missing_tools = 1);
    81 if ($missing_tools) {
    82     warn("Can't find required tools.");
    83     exit($PS_EXIT_CONFIG_ERROR);
    84 }
    8588
    8689# Get list of components for stacking
     
    300303
    301304    unless ($my_die_called) {
    302         $my_die_called = 1;
    303         delete_temps() unless ($save_temps);
     305        $my_die_called = 1;
     306        delete_temps() unless ($save_temps);
    304307    }
    305308
     
    324327{
    325328    unless ($temp_images_exist) {
    326         print "No temporary images yet generated\n";
    327         return 1;
     329        print "No temporary images yet generated\n";
     330        return 1;
    328331    }
    329332
     
    334337    unless ($success) {
    335338        $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    336         &my_die("Unable to perform ppConfigDump: $error_code", $stack_id, $error_code);
     339        &my_die("Unable to perform ppConfigDump: $error_code", $stack_id, $error_code);
    337340    }
    338341    my $md = $mdcParser->parse(join "", @$stdout_buf) or
    339         &my_die("Unable to parse metadata config doc", $stack_id, $PS_EXIT_PROG_ERROR);
     342        &my_die("Unable to parse metadata config doc", $stack_id, $PS_EXIT_PROG_ERROR);
    340343
    341344    my $temp_delete = metadataLookupBool($md, 'TEMP.DELETE'); # Delete temporary files?
Note: See TracChangeset for help on using the changeset viewer.