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_norm_apply.pl

    r19942 r22430  
    2222use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt );
    2323use Pod::Usage qw( pod2usage );
     24
     25# Look for programs we need
     26my $missing_tools;
     27my $dettool = can_run('dettool') or (warn "Can't find dettool" and $missing_tools = 1);
     28my $ppImage = can_run('ppImage') or (warn "Can't find ppImage" and $missing_tools = 1);
     29my $ppStatsFromMetadata = can_run('ppStatsFromMetadata') or (warn "Can't find ppStatsFromMetadata" and $missing_tools = 1);
     30if ($missing_tools) {
     31    warn("Can't find required tools.");
     32    exit($PS_EXIT_CONFIG_ERROR);
     33}
    2434
    2535# Parse the command-line
     
    5464    defined $outroot;
    5565
     66# Unhandled exceptions should be passed on to my_die so they get pushed into the database
     67$SIG{__DIE__} = sub { die @_ if $^S;
     68                      my_die( $_[0], $det_id, $iter, $class_id, $PS_EXIT_UNKNOWN_ERROR ); };
     69
    5670$ipprc->define_camera($camera);
    5771
    58 my $logDest = $ipprc->filename("LOG.IMFILE", $outroot, $class_id) 
     72my $logDest = $ipprc->filename("LOG.IMFILE", $outroot, $class_id)
    5973        or &my_die("Missing entry from camera config", $det_id, $iter, $class_id, $PS_EXIT_CONFIG_ERROR);
    6074$ipprc->redirect_output($logDest) if $redirect;
     
    6478# Define which detrend types we normalise
    6579use constant DETTYPE => {
    66     'bias'             => 'bias',
    67     'dark'             => 'dark',   
     80    'bias'             => 'bias',
     81    'dark'             => 'dark',
    6882    'dark_premask'     => 'dark',
    69     'shutter'          => 'shutter',
     83    'shutter'          => 'shutter',
    7084    'flat_premask'     => 'flat',
    7185    'domeflat_premask' => 'flat',
     
    7387    'flat_raw'         => 'flat',
    7488    'domeflat_raw'     => 'flat',
    75     'skyflat_raw'      => 'flat',   
    76     'flat'             => 'flat',
    77     'domeflat'         => 'flat',
    78     'skyflat'          => 'flat',   
    79     'fringe'           => 'fringe',   
    80     'mask'             => 'mask',
    81     'darkmask'         => 'mask',
    82     'flatmask'         => 'mask',
    83     }; 
     89    'skyflat_raw'      => 'flat',
     90    'flat'             => 'flat',
     91    'domeflat'         => 'flat',
     92    'skyflat'          => 'flat',
     93    'fringe'           => 'fringe',
     94    'mask'             => 'mask',
     95    'darkmask'         => 'mask',
     96    'flatmask'         => 'mask',
     97    };
    8498
    8599# convert supplied detrend type to a controlled namespace
    86100&my_die("Unrecognised detrend type: $det_type", $det_id, $iter, $class_id, $PS_EXIT_PROG_ERROR) unless exists DETTYPE()->{lc($det_type)};
    87101my $det_type_real = DETTYPE()->{lc($det_type)};
    88 
    89 # Look for programs we need
    90 my $missing_tools;
    91 my $dettool = can_run('dettool') or (warn "Can't find dettool" and $missing_tools = 1);
    92 my $ppImage = can_run('ppImage') or (warn "Can't find ppImage" and $missing_tools = 1);
    93 my $ppStatsFromMetadata = can_run('ppStatsFromMetadata') or (warn "Can't find ppStatsFromMetadata" and $missing_tools = 1);
    94 if ($missing_tools) {
    95     warn("Can't find required tools.");
    96     exit($PS_EXIT_CONFIG_ERROR);
    97 }
    98102
    99103&my_die("Couldn't find input file: $input_uri\n", $det_id, $iter, $class_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($input_uri);
     
    124128    # we cannot use ppImage to load a normalized mask : just copy it and build the jpeg images
    125129    if ($det_type_real eq 'mask') {
    126         $RECIPE_PPIMAGE = 'PPIMAGE_BIN';
    127         my $input_real = $ipprc->file_resolve($input_uri, 0);
    128         my $output_real = $ipprc->file_resolve($output, 1);
    129         system ("cp $input_real $output_real");
     130        $RECIPE_PPIMAGE = 'PPIMAGE_BIN';
     131        my $input_real = $ipprc->file_resolve($input_uri, 0);
     132        my $output_real = $ipprc->file_resolve($output, 1);
     133        system ("cp $input_real $output_real");
    130134    }
    131135
     
    162166    }
    163167    foreach my $line (@$stdout_buf) {
    164         $cmdflags .= " $line";
     168        $cmdflags .= " $line";
    165169    }
    166170    chomp $cmdflags;
     
    204208        $command .= " -iteration $iter";
    205209        $command .= " -class_id $class_id";
    206         $command .= " -path_base $outroot";
     210        $command .= " -path_base $outroot";
    207211        $command .= " -code $exit_code";
    208212        $command .= " -dbname $dbname" if defined $dbname;
Note: See TracChangeset for help on using the changeset viewer.