Changeset 11316 for trunk/ippScripts/scripts/detrend_norm_calc.pl
- Timestamp:
- Jan 25, 2007, 7:10:31 PM (19 years ago)
- File:
-
- 1 edited
-
trunk/ippScripts/scripts/detrend_norm_calc.pl (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippScripts/scripts/detrend_norm_calc.pl
r11298 r11316 9 9 use PS::IPP::Metadata::List qw( parse_md_list ); 10 10 use Data::Dumper; 11 12 use PS::IPP::Config qw( 13 $PS_EXIT_SUCCESS 14 $PS_EXIT_UNKNOWN_ERROR 15 $PS_EXIT_SYS_ERROR 16 $PS_EXIT_CONFIG_ERROR 17 $PS_EXIT_PROG_ERROR 18 $PS_EXIT_DATA_ERROR 19 $PS_EXIT_TIMEOUT_ERROR 20 ); 11 21 12 22 use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt ); … … 54 64 my $dettool = can_run('dettool') or (warn "Can't find dettool" and $missing_tools = 1); 55 65 my $ppNormCalc = can_run('ppNormCalc') or (warn "Can't find ppNormCalc" and $missing_tools = 1); 56 die "Can't find required tools.\n" if $missing_tools; 57 58 die "Unrecognised detrend type: $detType\n" unless exists NORMALIZE()->{lc($detType)}; 59 66 if ($missing_tools) { 67 warn("Can't find required tools."); 68 exit($PS_EXIT_CONFIG_ERROR); 69 } 70 71 unless (exists NORMALIZE()->{lc($detType)}) { 72 warn("Unrecognised detrend type: $detType"); 73 exit($PS_EXIT_CONFIG_ERROR); 74 } 60 75 61 76 my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files … … 69 84 my ( $stdin, $stdout, $stderr ); # Buffers for running program 70 85 print "Running [$command]...\n"; 71 run \@command, \$stdin, \$stdout, \$stderr or 72 die "Unable to perform dettool -processedimfile on detrend $detId/$iter: $?"; 86 if (not run(\@command, \$stdin, \$stdout, \$stderr)) { 87 warn("Unable to perform dettool -processedimfile on detrend $detId/$iter: $?"); 88 exit($PS_EXIT_SYS_ERROR); 89 } 73 90 # print $stdout . "\n"; 74 91 … … 82 99 push @single, "\n"; 83 100 84 my $list = parse_md_list( $mdcParser->parse( join( "\n", @single ) ) ) or 85 die "Unable to parse output from dettool.\n"; 101 my $list = parse_md_list( $mdcParser->parse( join( "\n", @single ) ) ); 102 unless (defined $list) { 103 warn("Unable to parse output from dettool."); 104 exit($PS_EXIT_PROG_ERROR); 105 } 86 106 push @files, @$list; 87 107 @single = (); … … 119 139 my @command = split /\s+/, $ppNormCalc; 120 140 print "Running [$ppNormCalc]...\n"; 121 run \@command, \$normData, \$stdout, \$stderr or 122 die "Unable to perform ppNormCalc: $?"; 141 if (not run(\@command, \$normData, \$stdout, \$stderr)) { 142 warn("Unable to perform ppNormCalc: $?"); 143 exit($PS_EXIT_SYS_ERROR); 144 } 123 145 print $stdout . "\n"; 124 146 125 147 # Parse the output 126 $norms = $mdcParser->parse($stdout) 127 or die "unable to parse metadata config doc"; 148 $norms = $mdcParser->parse($stdout); 149 unless ($norms) { 150 warn("Unable to parse metadata config doc"); 151 exit($PS_EXIT_PROG_ERROR); 152 } 128 153 } 129 154 … … 158 183 my ( $stdin, $stdout, $stderr ); # Buffers for running program 159 184 print "Running [$command]...\n"; 160 run \@command, \$stdin, \$stdout, \$stderr or 161 die "Unable to perform dettool -addnormstat for $className: $?"; 185 if (not run \@command, \$stdin, \$stdout, \$stderr) { 186 warn("Unable to perform dettool -addnormstat for $className: $?"); 187 exit($PS_EXIT_SYS_ERROR); 188 } 162 189 print $stdout . "\n"; 163 190 } … … 170 197 $? = $status; 171 198 } 199 200 __END__
Note:
See TracChangeset
for help on using the changeset viewer.
