Changeset 11316 for trunk/ippScripts/scripts/detrend_norm_apply.pl
- Timestamp:
- Jan 25, 2007, 7:10:31 PM (19 years ago)
- File:
-
- 1 edited
-
trunk/ippScripts/scripts/detrend_norm_apply.pl (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippScripts/scripts/detrend_norm_apply.pl
r11298 r11316 8 8 use Data::Dumper; 9 9 10 use PS::IPP::Config; 10 use PS::IPP::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 my $ipprc = PS::IPP::Config->new(); # IPP configuration 12 20 use File::Spec; … … 60 68 my $dettool = can_run('dettool') or (warn "Can't find dettool" and $missing_tools = 1); 61 69 my $ppImage = can_run('ppImage') or (warn "Can't find ppImage" and $missing_tools = 1); 62 die "Can't find required tools.\n" if $missing_tools; 70 71 if ($missing_tools) { 72 warn("Can't find required tools."); 73 exit($PS_EXIT_CONFIG_ERROR); 74 } 63 75 64 76 unless (defined $workdir) { … … 85 97 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 86 98 run(command => $command, verbose => 1); 87 die "Unable to perform ppImage: $error_code\n" if not $success; 88 die "Can't find expected output file: $output\n" if not -e $output; 89 die "Can't find expected output file: $b1name\n" if not -e $b1name; 90 die "Can't find expected output file: $b2name\n" if not -e $b2name; 91 die "Can't find expected output file: $statsName\n" if not -e $statsName; 99 unless ($success) { 100 $error_code >> 8; 101 &my_die("Unable to perform ppImage: $error_code", $det_id, $iter, $class_id, $error_code); 102 } 103 &my_die("Can't find expected output file: $output", $det_id, $iter, $class_id, $PS_EXIT_SYS_ERROR) unless -e $output; 104 &my_die("Can't find expected output file: $b1name", $det_id, $iter, $class_id, $PS_EXIT_SYS_ERROR) unless -e $b2name; 105 &my_die("Can't find expected output file: $b2name", $det_id, $iter, $class_id, $PS_EXIT_SYS_ERROR) unless -e $b1name; 106 &my_die("Can't find expected output file: $statsName", $det_id, $iter, $class_id, $PS_EXIT_SYS_ERROR) unless -e $statsName; 92 107 } 93 108 … … 96 111 { 97 112 my $statsFile; # File handle 98 open $statsFile, $statsName or die "Can't open statistics file $statsName: $!\n";113 open $statsFile, $statsName or &my_die("Can't open statistics file $statsName: $!\n", $det_id, $iter, $class_id, $PS_EXIT_SYS_ERROR); 99 114 my @contents = <$statsFile>; # Contents of file 100 115 close $statsFile; 101 116 my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files 102 117 my $metadata = $mdcParser->parse(join "", @contents) 103 or die "unable to parse metadata config";118 or &my_die("Unable to parse metadata config", $det_id, $iter, $class_id, $PS_EXIT_PROG_ERROR); 104 119 $stats = PS::IPP::Metadata::Stats->new(); # Stats parser 105 $stats->parse($metadata) or die "Unable to find all values in statistics output.\n";120 $stats->parse($metadata) or &my_die("Unable to find all values in statistics output.", $det_id, $iter, $class_id, $PS_EXIT_PROG_ERROR); 106 121 } 107 122 … … 127 142 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 128 143 run(command => $command, verbose => 1); 129 die "Unable to perform dettool -addnormalizedimfile: $error_code\n" 130 if not $success; 144 unless ($success) { 145 $error_code >> 8; 146 warn("Unable to perform dettool -addnormalizedimfile: $error_code\n"); 147 exit($error_code); 148 } 131 149 132 150 unlink $statsName; 133 151 } 152 153 sub my_die 154 { 155 my $msg = shift; # Warning message on die 156 my $det_id = shift; # Detrend identifier 157 my $iter = shift; # Iteration 158 my $class_id = shift; # Class identifier 159 my $exit_code = shift; # Exit code to add 160 161 warn($msg); 162 if ($det_id and $iter and $class_id) { 163 my $command = "$dettool -addnormalizedimfile -det_id $det_id -iteration $iter -class_id $class_id -code $exit_code"; 164 $command .= " -dbname $dbname" if defined $dbname; 165 system ($command); 166 } 167 exit $exit_code; 168 } 169 134 170 135 171 END { … … 139 175 $? = $status; 140 176 } 177 178 __END__
Note:
See TracChangeset
for help on using the changeset viewer.
