IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 11831


Ignore:
Timestamp:
Feb 15, 2007, 10:45:58 AM (19 years ago)
Author:
Paul Price
Message:

Adding die function to add error code.

File:
1 edited

Legend:

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

    r11492 r11831  
    7777}
    7878
    79 unless (exists NORMALIZE()->{lc($detType)}) {
    80     warn("Unrecognised detrend type: $detType");
    81     exit($PS_EXIT_CONFIG_ERROR);
    82 }
     79&my_die("Unrecognised detrend type: $detType", $det_id, $iter, $PS_EXIT_PROG_ERROR) unless
     80    exists NORMALIZE()->{lc($detType)};
    8381
    8482my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files
     
    9391    print "Running [$command]...\n";
    9492    if (not run(\@command, \$stdin, \$stdout, \$stderr)) {
    95         warn("Unable to perform dettool -processedimfile on detrend $detId/$iter: $?");
    96         exit($PS_EXIT_SYS_ERROR);
     93        &my_die("Unable to perform dettool -processedimfile on detrend $detId/$iter: $?",
     94                $det_id, $iter, $PS_EXIT_SYS_ERROR);
    9795    }
    9896#    print $stdout . "\n";
     
    108106
    109107            my $list = parse_md_list( $mdcParser->parse( join( "\n", @single ) ) );
    110             unless (defined $list) {
    111                 warn("Unable to parse output from dettool.");
    112                 exit($PS_EXIT_PROG_ERROR);
    113             }
     108            &my_die("Unable to parse output from dettool", $det_id, $iter, $PS_EXIT_PROG_ERROR) unless
     109                defined $list;
    114110            push @files, @$list;
    115111            @single = ();
     
    148144        print "Running [$ppNormCalc]...\n";
    149145        if (not run(\@command, \$normData, \$stdout, \$stderr)) {
    150             warn("Unable to perform ppNormCalc: $?");
    151             exit($PS_EXIT_SYS_ERROR);
     146            &my_die("Unable to perform ppNormCalc: $?", $det_id, $iter, $PS_EXIT_SYS_ERROR);
    152147        }
    153148        print $stdout . "\n";
     
    155150        # Parse the output
    156151        $norms = $mdcParser->parse($stdout);
    157         unless ($norms) {
    158             warn("Unable to parse metadata config doc");
    159             exit($PS_EXIT_PROG_ERROR);
    160         }
     152        &my_die("Unable to parse metadata config doc", $det_id, $iter, $PS_EXIT_PROG_ERROR) unless $norms;
    161153    }
    162154
     
    199191}
    200192
     193sub my_die
     194{
     195    my $msg = shift;            # Warning message on die
     196    my $det_id = shift;         # Detrend identifier
     197    my $iter = shift;           # Iteration
     198    my $exit_code = shift;      # Exit code to add
     199
     200    warn($msg);
     201    if ($det_id and $iter and $class_id and not $no_update) {
     202        my $command = "$dettool -addnormalizedstat -det_id $det_id -iteration $iter -code $exit_code";
     203        $command .= " -dbname $dbname" if defined $dbname;
     204        system ($command);
     205    }
     206    exit $exit_code;
     207}
     208
     209
    201210END {
    202211    my $status = $?;
Note: See TracChangeset for help on using the changeset viewer.