Changeset 11316 for trunk/ippScripts/scripts/detrend_reject_imfile.pl
- Timestamp:
- Jan 25, 2007, 7:10:31 PM (19 years ago)
- File:
-
- 1 edited
-
trunk/ippScripts/scripts/detrend_reject_imfile.pl (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippScripts/scripts/detrend_reject_imfile.pl
r11298 r11316 12 12 use Statistics::Descriptive; 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; … … 52 60 my $dettool = can_run('dettool') or (warn "Can't find dettool" and $missing_tools = 1); 53 61 my $ppImage = can_run('ppImage') or (warn "Can't find ppImage" and $missing_tools = 1); 54 die "Can't find required tools.\n" if $missing_tools; 62 if ($missing_tools) { 63 warn("Can't find required tools."); 64 exit($PS_EXIT_CONFIG_ERROR); 65 } 55 66 56 67 my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files … … 63 74 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 64 75 run(command => $command, verbose => 1); 65 die "Unable to perform dettool -residimfile: $error_code\n" if not $success; 66 my $metadata = $mdcParser->parse(join "", @$stdout_buf) 67 or die "unable to parse metadata config doc"; 68 $files = parse_md_list($metadata); 76 unless ($success) { 77 $error_code >> 8; 78 warn("Unable to perform dettool -residimfile: $error_code\n"); 79 exit($error_code); 80 } 81 82 my $metadata = $mdcParser->parse(join "", @$stdout_buf) or 83 &my_die("Unable to parse metadata config doc", $det_id, $iter, $exp_tag, $PS_EXIT_PROG_ERROR); 84 $files = parse_md_list($metadata) or 85 &my_die("Unable to parse metadata list", $det_id, $iter, $exp_tag, $PS_EXIT_PROG_ERROR); 69 86 } 70 87 … … 107 124 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 108 125 run(command => $command, verbose => 1); 109 die "Unable to find expected output file: $jpeg1Name\n" if not -f $jpeg1Name; 126 unless ($success) { 127 $error_code >> 8; 128 &my_die("Unable to run ppImage: $error_code", $det_id, $iter, $exp_tag, $error_code); 129 } 130 &my_die("Unable to find expected output file: $jpeg1Name", $det_id, $iter, $exp_tag, $PS_EXIT_SYS_ERROR) unless -f $jpeg1Name; 110 131 } 111 132 … … 115 136 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 116 137 run(command => $command, verbose => 1); 117 die "Unable to find expected output file: $jpeg2Name\n" if not -f $jpeg2Name; 138 unless ($success) { 139 $error_code >> 8; 140 &my_die("Unable to run ppImage: $error_code", $det_id, $iter, $exp_tag, $error_code); 141 } 142 &my_die("Unable to find expected output file: $jpeg2Name", $det_id, $iter, $exp_tag, $PS_EXIT_SYS_ERROR) unless -f $jpeg2Name; 118 143 } 119 144 … … 131 156 # Reject based on the stats of the imfiles 132 157 # it is VALID to reject on more than one criterion 133 die "Number of means and number of variances differ!\n" if scalar @means != scalar @variances;158 &my_die("Number of means and number of variances differ!", $det_id, $iter, $exp_tag, $PS_EXIT_PROG_ERROR) unless scalar @means == scalar @variances; 134 159 for (my $i = 0; $i < scalar @means; $i++) { 135 160 my $mean = $means[$i]; # Mean for this imfile … … 248 273 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 249 274 run(command => $command, verbose => 1); 250 die "Unable to perform dettool -addresidexp: $error_code\n" if not $success; 275 unless ($success) { 276 $error_code >> 8; 277 warn("Unable to perform dettool -addresidexp: $error_code\n"); 278 exit($error_code); 279 } 251 280 252 281 unlink $list1Name; … … 259 288 or die "failed to execute sync: $!" ; 260 289 $? = $status; 290 } 291 292 293 sub my_die 294 { 295 my $msg = shift; # Warning message on die 296 my $det_id = shift; # Detrend identifier 297 my $iter = shift; # Iteration 298 my $exp_tag = shift; # Exposure tag 299 my $exit_code = shift; # Exit code to add 300 301 warn($msg); 302 if ($det_id and $iteration and $exp_tag) { 303 my $command = "$dettool -addresidexp -det_id $det_id -iteration $iter -exp_tag $exp_tag -code $exit_code"; 304 $command .= " -dbname $dbname" if defined $dbname; 305 system ($command); 306 } 307 exit $exit_code; 261 308 } 262 309
Note:
See TracChangeset
for help on using the changeset viewer.
