Changeset 11036 for trunk/ippScripts/scripts/phase0_imfile.pl
- Timestamp:
- Jan 11, 2007, 12:13:36 PM (19 years ago)
- File:
-
- 1 edited
-
trunk/ippScripts/scripts/phase0_imfile.pl (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippScripts/scripts/phase0_imfile.pl
r10625 r11036 15 15 use Data::Dumper; 16 16 17 use PS::IPP::Config; 17 use PS::IPP::Config qw( 18 $PS_EXIT_SUCCESS 19 $PS_EXIT_UNKNOWN_ERROR 20 $PS_EXIT_SYS_ERROR 21 $PS_EXIT_CONFIG_ERROR 22 $PS_EXIT_PROG_ERROR 23 $PS_EXIT_DATA_ERROR 24 $PS_EXIT_TIMEOUT_ERROR 25 ); 26 18 27 my $ipprc = PS::IPP::Config->new(); # IPP configuration 19 28 use File::Spec; … … 40 49 and defined $uri; 41 50 42 use constant RECIPE => "PPSTATS_PHASE0"; # Recipe to use for ppStats 51 my $RECIPE = "PPSTATS_PHASE0"; # Recipe to use for ppStats 52 # use constant RECIPE => "PPSTATS_PHASE0"; # Recipe to use for ppStats 43 53 44 54 # These values should be constant for all components … … 77 87 my $p0tool = can_run('p0tool') or (warn "Can't find p0tool" and $missing_tools = 1); 78 88 my $ppStats = can_run('ppStats') or (warn "Can't find ppStats" and $missing_tools = 1); 79 die "Can't find required tools.\n" if $missing_tools; 89 90 if ($missing_tools) { 91 warn ("Can't find required tools"); 92 &my_die ("", "", $PS_EXIT_CONFIG_ERROR); 93 } 80 94 81 95 # setup cache interface … … 92 106 my $stats; 93 107 { 94 my $command = "$ppStats $uri -recipe PPSTATS " . RECIPE; # Command to run ppStats108 my $command = "$ppStats $uri -recipe PPSTATS $RECIPE"; # Command to run ppStats 95 109 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 96 110 cache_run(command => $command, verbose => 1); 97 die "Unable to perform ppStats on exposure id $exp_tag: $error_code\n" 98 if not $success; 111 unless ($success) { 112 warn ("Unable to perform ppStats on exposure id $exp_tag: $error_code"); 113 &my_die ($exp_tag, $class_id, $error_code); 114 } 99 115 100 116 # Parse the output 101 117 my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files 102 my $metadata = $mdcParser->parse(join "", @$stdout_buf) 103 or die "unable to parse metadata config doc"; 118 my $metadata = $mdcParser->parse(join "", @$stdout_buf); # XXX is this join necessary? 119 unless ($metadata) { 120 warn ("Unable to parse metadata config doc"); 121 &my_die ($exp_tag, $class_id, $PS_EXIT_PROG_ERROR); 122 } 104 123 my @constants = keys %{CONSTANTS()}; # List of constants to parse out 105 124 my @variables = keys %{VARIABLES()}; # List of variables to parse out 106 125 $stats = PS::IPP::Metadata::Stats->new(\@constants, \@variables); # Stats parser 107 $stats->parse($metadata) or die "Unable to find all values.\n"; 126 unless ($stats->parse($metadata)) { 127 warn ("Unable to find all values"); 128 &my_die ($exp_tag, $class_id, $PS_EXIT_PROG_ERROR); 129 # XXX is this a programming or a config error? 130 } 131 132 # XXX for a test, randomly declare a failure and return to pantasks 133 my $rnd = rand(1); 134 if ($rnd > 0.5) { 135 warn ("random failure"); 136 &my_die ($exp_tag, $class_id, $PS_EXIT_DATA_ERROR); 137 } 108 138 } 109 139 … … 151 181 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 152 182 run(command => \@command, verbose => 1); 153 die "Unable to perform p0tool -updateimfile: $error_code\n" if not $success; 183 184 unless ($success) { 185 # XXX this is tricky: if we can't run -updateimfile, can we actually set the error code? 186 # XXX if this is not a database error, it is probably a programming error (in p0tool or the passed args) 187 warn ("Unable to perform p0tool -updateimfile: $error_code"); 188 &my_die ($exp_tag, $class_id, $error_code); 189 } 154 190 } 155 191 … … 166 202 return @output; 167 203 } 204 } 205 206 sub my_die 207 { 208 my $exp_tag = $_[0]; 209 my $class_id = $_[1]; 210 my $exit_code = $_[2]; 211 if ($exp_tag && $class_id) { 212 system ("$p0tool -faultimfile -exp_tag $exp_tag -class_id $class_id -code $exit_code"); 213 } 214 exit $exit_code; 168 215 } 169 216
Note:
See TracChangeset
for help on using the changeset viewer.
