Changeset 11316 for trunk/ippScripts/scripts/detrend_process_imfile.pl
- Timestamp:
- Jan 25, 2007, 7:10:31 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippScripts/scripts/detrend_process_imfile.pl
r11298 r11316 11 11 use PS::IPP::Metadata::Stats; 12 12 13 use PS::IPP::Config; 13 use PS::IPP::Config qw( 14 $PS_EXIT_SUCCESS 15 $PS_EXIT_UNKNOWN_ERROR 16 $PS_EXIT_SYS_ERROR 17 $PS_EXIT_CONFIG_ERROR 18 $PS_EXIT_PROG_ERROR 19 $PS_EXIT_DATA_ERROR 20 $PS_EXIT_TIMEOUT_ERROR 21 ); 14 22 my $ipprc = PS::IPP::Config->new(); # IPP configuration 15 23 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 if ($missing_tools) { 71 warn("Can't find required tools."); 72 exit($PS_EXIT_CONFIG_ERROR); 73 } 63 74 64 75 # Recipe to use in processing 65 76 my $recipe = RECIPES->{lc($det_type)}; 66 die "Unrecognised detrend type: $det_type\n" if not defined $recipe; 77 unless (defined $recipe) { 78 warn("Unrecognised detrend type: $det_type"); 79 exit($PS_EXIT_CONFIG_ERROR); 80 } 67 81 68 82 ### Output file name … … 88 102 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 89 103 run(command => $command, verbose => 1); 90 die "Unable to perform ppImage on $input_uri: $error_code\n" if not $success; 91 die "Couldn't find expected output file: $outputImage\n" if not -f $outputImage; 92 die "Couldn't find expected output file: $outputStats\n" if not -f $outputStats; 93 die "Couldn't find expected output file: $outputBin1\n" if not -f $outputBin1; 94 die "Couldn't find expected output file: $outputBin2\n" if not -f $outputBin2; 104 unless ($success) { 105 $error_code >> 8; 106 &my_die("Unable to perform ppImage: $error_code", $det_id, $exp_tag, $class_id, $error_code); 107 } 108 &my_die("Couldn't find expected output file: $outputImage", $det_id, $exp_tag, $class_id, $PS_EXIT_SYS_ERROR) unless -f $outputImage; 109 &my_die("Couldn't find expected output file: $outputStats", $det_id, $exp_tag, $class_id, $PS_EXIT_SYS_ERROR) unless -f $outputStats; 110 &my_die("Couldn't find expected output file: $outputBin1", $det_id, $exp_tag, $class_id, $PS_EXIT_SYS_ERROR) unless -f $outputBin1; 111 &my_die("Couldn't find expected output file: $outputBin2", $det_id, $exp_tag, $class_id, $PS_EXIT_SYS_ERROR) unless -f $outputBin2; 95 112 } 96 113 … … 104 121 my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files 105 122 my $metadata = $mdcParser->parse(join "", @contents) 106 or die "unable to parse metadata config";123 or &my_die("Unable to parse metadata config", $det_id, $exp_tag, $class_id, $PS_EXIT_PROG_ERROR); 107 124 $stats = PS::IPP::Metadata::Stats->new(); # Stats parser 108 $stats->parse($metadata) or die "Unable to find all values in statistics output.\n";125 $stats->parse($metadata) or &my_die("Unable to find all values in statistics output.", $det_id, $exp_tag, $class_id, $PS_EXIT_PROG_ERROR); 109 126 } 110 127 … … 131 148 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 132 149 run(command => $command, verbose => 1); 133 die "Unable to perform dettool -addprocessedimfile for $det_id/$exp_tag/$class_id: $error_code\n" 134 if not $success; 150 unless ($success) { 151 $error_code >> 8; 152 warn("Unable to perform dettool -addprocessedimfile: $error_code\n"); 153 exit($error_code); 154 } 135 155 136 156 unlink $outputStats; 157 } 158 159 sub my_die 160 { 161 my $msg = shift; # Warning message on die 162 my $det_id = shift; # Detrend identifier 163 my $exp_tag = shift; # Exposure tag 164 my $class_id = shift; # Class identifier 165 my $exit_code = shift; # Exit code to add 166 167 warn($msg); 168 if ($det_id and $exp_tag and $class_id) { 169 my $command = "$dettool -addprocessedimfile -det_id $det_id -exp_tag $exp_tag -class_id $class_id -code $exit_code"; 170 $command .= " -dbname $dbname" if defined $dbname; 171 system ($command); 172 } 173 exit $exit_code; 137 174 } 138 175
Note:
See TracChangeset
for help on using the changeset viewer.
