Changeset 11316 for trunk/ippScripts/scripts/detrend_process_exp.pl
- Timestamp:
- Jan 25, 2007, 7:10:31 PM (19 years ago)
- File:
-
- 1 edited
-
trunk/ippScripts/scripts/detrend_process_exp.pl (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippScripts/scripts/detrend_process_exp.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; … … 47 55 my $dettool = can_run('dettool') or (warn "Can't find dettool" and $missing_tools = 1); 48 56 my $ppImage = can_run('ppImage') or (warn "Can't find ppImage" and $missing_tools = 1); 49 die "Can't find required tools.\n" if $missing_tools; 57 if ($missing_tools) { 58 warn("Can't find required tools."); 59 exit($PS_EXIT_CONFIG_ERROR); 60 } 50 61 51 62 my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files … … 58 69 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 59 70 run(command => $command, verbose => 1); 60 die "Unable to perform dettool -processedimfile: $error_code\n" if not $success; 61 my $metadata = $mdcParser->parse(join "", @$stdout_buf) 62 or die "unable to parse metadata config doc"; 63 $files = parse_md_list($metadata); 71 unless ($success) { 72 $error_code >> 8; 73 &my_die("Unable to perform dettool -processedimfile: $error_code", $det_id, $exp_tag, $error_code); 74 } 75 my $metadata = $mdcParser->parse(join "", @$stdout_buf) or 76 &my_die("Unable to parse metadata config doc", $det_id, $exp_tag, $PS_EXIT_PROG_ERROR); 77 $files = parse_md_list($metadata) or 78 &my_die("Unable to parse metadata list", $det_id, $exp_tag, $PS_EXIT_PROG_ERROR); 64 79 } 65 80 … … 70 85 my @variances; # Array of variances for each component 71 86 foreach my $file (@$files) { 72 die "Unable to find class id\n"unless defined $file->{class_id};87 &my_die("Unable to find class id", $det_id, $exp_tag, $PS_EXIT_SYS_ERRROR) unless defined $file->{class_id}; 73 88 my $class_id = $file->{class_id}; 74 die "Unable to find bg for class_id=$class_id\n"unless defined $file->{bg};75 die "Unable to find bg_mean_stdev for class_id=$class_id\n"unless defined $file->{bg_mean_stdev};89 &my_die("Unable to find bg for class_id=$class_id", $det_id, $exp_tag, $PS_EXIT_SYS_ERROR) unless defined $file->{bg}; 90 &my_die("Unable to find bg_mean_stdev for class_id=$class_id", $det_id, $exp_tag, $PS_EXIT_SYS_ERROR) unless defined $file->{bg_mean_stdev}; 76 91 push @backgrounds, $file->{bg}; 77 92 push @variances, $file->{bg_stdev}**2; … … 125 140 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 126 141 run(command => $command, verbose => 1); 127 die "Unable to find expected output file: $jpeg1\n" if not -f $jpeg1; 142 unless ($success) { 143 $error_code >> 8; 144 &my_die("Unable to perform ppImage: $error_code", $det_id, $exp_tag, $error_code); 145 } 146 &my_die("Unable to find expected output file: $jpeg1", $det_id, $exp_tag, $PS_EXIT_SYS_ERROR) unless -f $jpeg1; 128 147 } 129 148 … … 133 152 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 134 153 run(command => $command, verbose => 1); 135 die "Unable to find expected output file: $jpeg2\n" if not -f $jpeg2; 154 unless ($success) { 155 $error_code >> 8; 156 &my_die("Unable to perform ppImage: $error_code", $det_id, $exp_tag, $error_code); 157 } 158 &my_die("Unable to find expected output file: $jpeg2", $det_id, $exp_tag, $PS_EXIT_SYS_ERROR) unless -f $jpeg2; 136 159 } 137 160 … … 148 171 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 149 172 run(command => $command, verbose => 1); 150 die "Unable to perform dettool -addprocessedexp: $error_code\n" if not $success; 173 unless ($success) { 174 $error_code >> 8; 175 warn("Unable to perform dettool -addprocessedexp: $error_code"); 176 exit($error_code); 177 } 151 178 152 179 unlink $list1Name; 153 180 unlink $list2Name; 181 } 182 183 184 sub my_die 185 { 186 my $msg = shift; # Warning message on die 187 my $det_id = shift; # Detrend identifier 188 my $exp_tag = shift; # Exposure tag 189 my $exit_code = shift; # Exit code to add 190 191 warn($msg); 192 if ($det_id && $exp_tag) { 193 my $command = "$dettool -addprocessedexp -det_id $det_id -exp_tag $exp_tag -code $exit_code"; 194 $command .= " -dbname $dbname" if defined $dbname; 195 system ($command); 196 } 197 exit $exit_code; 154 198 } 155 199
Note:
See TracChangeset
for help on using the changeset viewer.
