Changeset 11316 for trunk/ippScripts/scripts/detrend_norm_exp.pl
- Timestamp:
- Jan 25, 2007, 7:10:31 PM (19 years ago)
- File:
-
- 1 edited
-
trunk/ippScripts/scripts/detrend_norm_exp.pl (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippScripts/scripts/detrend_norm_exp.pl
r11298 r11316 8 8 9 9 use IPC::Cmd qw( can_run run ); 10 use PS::IPP::Metadata::Config; 10 use PS::IPP::Metadata::Config qw( 11 $PS_EXIT_SUCCESS 12 $PS_EXIT_UNKNOWN_ERROR 13 $PS_EXIT_SYS_ERROR 14 $PS_EXIT_CONFIG_ERROR 15 $PS_EXIT_PROG_ERROR 16 $PS_EXIT_DATA_ERROR 17 $PS_EXIT_TIMEOUT_ERROR 18 ); 11 19 use PS::IPP::Metadata::List qw( parse_md_list ); 12 20 use Statistics::Descriptive; … … 49 57 my $dettool = can_run('dettool') or (warn "Can't find dettool" and $missing_tools = 1); 50 58 my $ppImage = can_run('ppImage') or (warn "Can't find ppImage" and $missing_tools = 1); 51 die "Can't find required tools.\n" if $missing_tools; 59 if ($missing_tools) { 60 warn("Can't find required tools."); 61 exit($PS_EXIT_CONFIG_ERROR); 62 } 52 63 53 64 my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files … … 60 71 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 61 72 run(command => $command, verbose => 1); 62 die "Unable to perform dettool -normalizedimfile: $error_code\n" if not $success; 63 my $metadata = $mdcParser->parse(join "", @$stdout_buf) 64 or die "unable to parse metadata config doc"; 65 $files = parse_md_list($metadata); 73 unless ($success) { 74 $error_code >> 8; 75 &my_die("Unable to perform ppImage: $error_code", $det_id, $iter, $error_code); 76 } 77 my $metadata = $mdcParser->parse(join "", @$stdout_buf) or 78 &my_die("Unable to parse metadata config doc", $det_id, $iter, $PS_EXIT_PROG_ERROR); 79 $files = parse_md_list($metadata) or 80 &my_die("Unable to parse metadata list", $det_id, $iter, $PS_EXIT_PROG_ERROR); 66 81 } 67 82 … … 72 87 my @variances; # Array of variances for each component 73 88 foreach my $file (@$files) { 74 die "Unable to find class id\n"unless defined $file->{class_id};89 &my_die("Unable to find class id", $det_id, $iter, $PS_EXIT_SYS_ERROR) unless defined $file->{class_id}; 75 90 my $class_id = $file->{class_id}; 76 die "Unable to find bg for class_id=$class_id\n"unless defined $file->{bg};77 die "Unable to find bg_mean_stdev for class_id=$class_id\n"unless defined $file->{bg_mean_stdev};91 &my_die("Unable to find bg for class_id=$class_id", $det_id, $iter, $PS_EXIT_SYS_ERROR) unless defined $file->{bg}; 92 &my_die("Unable to find bg_mean_stdev for class_id=$class_id", $det_id, $iter, $PS_EXIT_SYS_ERROR) unless defined $file->{bg_mean_stdev}; 78 93 push @backgrounds, $file->{bg}; 79 94 push @variances, $file->{bg_stdev}**2; … … 127 142 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 128 143 run(command => $command, verbose => 1); 129 die "Unable to find expected output file: $jpeg1Name\n" if not-f $jpeg1Name;144 &my_die("Unable to find expected output file: $jpeg1Name", $det_id, $iter, $PS_EXIT_SYS_ERROR) unless -f $jpeg1Name; 130 145 } 131 146 … … 135 150 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 136 151 run(command => $command, verbose => 1); 137 die "Unable to find expected output file: $jpeg2Name\n" if not-f $jpeg2Name;152 &my_die("Unable to find expected output file: $jpeg2Name", $det_id, $iter, $PS_EXIT_SYS_ERROR) unless -f $jpeg2Name; 138 153 } 139 154 … … 148 163 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 149 164 run(command => $command, verbose => 1); 150 die "Unable to perform dettool -addnormalizedexp: $error_code\n" if not $success; 165 unless ($success) { 166 $error_code >> 8; 167 &my_die("Unable to perform dettool -addnormalizedexp: $error_code", $det_id, $iter, $error_code); 168 } 151 169 152 170 unlink $list1Name; 153 171 unlink $list2Name; 172 } 173 174 175 sub my_die 176 { 177 my $msg = shift; # Warning message on die 178 my $det_id = shift; # Detrend identifier 179 my $iter = shift; # Iteration 180 my $exit_code = shift; # Exit code to add 181 182 warn($msg); 183 if ($det_id and $iter) { 184 my $command = "$dettool -addprocessedimfile -det_id $det_id -iter $iter -code $exit_code"; 185 $command .= " -dbname $dbname" if defined $dbname; 186 system ($command); 187 } 188 exit $exit_code; 154 189 } 155 190
Note:
See TracChangeset
for help on using the changeset viewer.
