Changeset 11316 for trunk/ippScripts/scripts/detrend_resid.pl
- Timestamp:
- Jan 25, 2007, 7:10:31 PM (19 years ago)
- File:
-
- 1 edited
-
trunk/ippScripts/scripts/detrend_resid.pl (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippScripts/scripts/detrend_resid.pl
r11298 r11316 12 12 use Data::Dumper; 13 13 14 use PS::IPP::Config; 14 use PS::IPP::Config qw( 15 $PS_EXIT_SUCCESS 16 $PS_EXIT_UNKNOWN_ERROR 17 $PS_EXIT_SYS_ERROR 18 $PS_EXIT_CONFIG_ERROR 19 $PS_EXIT_PROG_ERROR 20 $PS_EXIT_DATA_ERROR 21 $PS_EXIT_TIMEOUT_ERROR 22 ); 15 23 my $ipprc = PS::IPP::Config->new(); # IPP configuration 16 24 use File::Spec; … … 92 100 my $dettool = can_run('dettool') or (warn "Can't find dettool" and $missing_tools = 1); 93 101 my $ppImage = can_run('ppImage') or (warn "Can't find ppImage" and $missing_tools = 1); 94 die "Can't find required tools.\n" if $missing_tools; 102 if ($missing_tools) { 103 warn("Can't find required tools."); 104 exit($PS_EXIT_CONFIG_ERROR); 105 } 95 106 96 107 # Recipe to use in processing 97 die "Unrecognised mode: $mode\n" if notdefined RECIPES->{$mode};108 &my_die("Unrecognised mode: $mode", $det_id, $iter, $exp_tag, $class_id, $PS_EXIT_PROG_ERROR) unless defined RECIPES->{$mode}; 98 109 my $recipe = RECIPES->{$mode}->{lc($det_type)}; 99 die "Unrecognised detrend type: $det_type\n" if notdefined $recipe;110 &my_die("Unrecognised detrend type: $det_type", $det_id, $iter, $exp_tag, $class_id, $PS_EXIT_PROG_ERROR) unless defined $recipe; 100 111 101 112 ### Output file names --- must match camera configuration! … … 124 135 if (lc($mode) ne 'verify') { 125 136 my $detFlag = DETRENDS->{lc($det_type)}; 126 die "Unrecognised detrend type: $det_type\n" if notdefined $detFlag;137 &my_die("Unrecognised detrend type: $det_type", $det_id, $iter, $exp_tag, $class_id, $PS_EXIT_PROG_ERROR) unless defined $detFlag; 127 138 $command .= "$detFlag $detrend"; 128 139 } … … 130 141 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 131 142 run(command => $command, verbose => 1); 132 die "Unable to perform ppImage on $input_uri: $error_code\n" if not $success; 133 die "Couldn't find expected output file: $outputName\n" if not -f $outputName; 134 die "Couldn't find expected output file: $outputStats\n" if not -f $outputStats; 135 die "Couldn't find expected output file: $bin1Name\n" if not -f $bin1Name; 136 die "Couldn't find expected output file: $bin2Name\n" if not -f $bin2Name; 143 unless ($success) { 144 $error_code >> 8; 145 &my_die("Unable to perform ppImage: $error_code", $det_id, $iter, $exp_tag, $class_id, $error_code); 146 } 147 &my_die("Couldn't find expected output file: $outputName", $det_id, $iter, $exp_tag, $class_id, $PS_EXIT_SYS_ERROR) unless -f $outputName; 148 &my_die("Couldn't find expected output file: $outputStats", $det_id, $iter, $exp_tag, $class_id, $PS_EXIT_SYS_ERROR) unless -f $outputStats; 149 &my_die("Couldn't find expected output file: $bin1Name", $det_id, $iter, $exp_tag, $class_id, $PS_EXIT_SYS_ERROR) unless -f $bin1Name; 150 &my_die("Couldn't find expected output file: $bin2Name", $det_id, $iter, $exp_tag, $class_id, $PS_EXIT_SYS_ERROR) unless -f $bin2Name; 137 151 } 138 152 … … 141 155 { 142 156 my $statsFile; # File handle 143 open $statsFile, $outputStats or die "Can't open statistics file $outputStats: $!\n";157 open $statsFile, $outputStats or &my_die("Can't open statistics file $outputStats: $!", $det_id, $iter, $exp_tag, $class_id, $PS_EXIT_SYS_ERROR); 144 158 my @contents = <$statsFile>; # Contents of file 145 159 close $statsFile; 146 160 my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files 147 my $metadata = $mdcParser->parse(join "", @contents) 148 or die "unable to parse metadata config doc";161 my $metadata = $mdcParser->parse(join "", @contents) or 162 &my_die("Unable to parse metadata config doc", $det_id, $iter, $exp_tag, $class_id, $PS_EXIT_PROG_ERROR); 149 163 $stats = PS::IPP::Metadata::Stats->new(); # Stats parser 150 $stats->parse($metadata) or die "Unable to find all values in statistics output.\n";164 $stats->parse($metadata) or &my_die("Unable to find all values in statistics output.", $det_id, $iter, $exp_tag, $class_id, $PS_EXIT_PROG_ERROR); 151 165 } 152 166 … … 173 187 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 174 188 run(command => $command, verbose => 1); 175 die "Unable to perform dettool -addprocessed for $det_id/$exp_tag/$class_id: $error_code\n" 176 if not $success; 189 unless ($success) { 190 $error_code >> 8; 191 warn("Unable to perform dettool -addresidimfile: $error_code\n"); 192 exit($error_code); 193 } 177 194 178 195 unlink $outputStats; 196 } 197 198 199 200 sub my_die 201 { 202 my $msg = shift; # Warning message on die 203 my $det_id = shift; # Detrend identifier 204 my $iter = shift; # Iteration 205 my $exp_tag = shift; # Exposure tag 206 my $class_id = shift; # Class identifier 207 my $exit_code = shift; # Exit code to add 208 209 warn($msg); 210 if ($det_id and $iter and $exp_tag) { 211 my $command = "$dettool -addresidimfile -det_id $det_id -iteration $iter -exp_tag $exp_tag -class_id $class_id -code $exit_code"; 212 $command .= " -dbname $dbname" if defined $dbname; 213 system ($command); 214 } 215 exit $exit_code; 179 216 } 180 217
Note:
See TracChangeset
for help on using the changeset viewer.
