- Timestamp:
- Jan 28, 2024, 2:24:07 PM (2 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20230313/ippScripts/scripts/xcstack_skycell.pl
r42560 r42602 19 19 20 20 use IPC::Cmd 0.36 qw( can_run run ); 21 use Scalar::Util qw(looks_like_number); 21 22 use PS::IPP::Metadata::Config; 22 23 use PS::IPP::Metadata::List qw( parse_md_list ); … … 244 245 245 246 # cannot use run_command here (no metadata output to parse) 246 my ( $success, $error_ code, $full_buf, $stdout_buf, $stderr_buf ) =247 run(command => $command, verbose => $verbose);247 my ( $success, $error_msg, $full_buf, $stdout_buf, $stderr_buf ) = run(command => $command, verbose => $verbose); 248 my $error_code = &parse_error_message ($success, $error_msg, $command); 248 249 unless ($success) { 249 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 250 &my_die("Unable to perform ppStack: $error_code", $xcstack_id, $error_code); 250 &my_die("Unable to perform $command: $error_msg", $xcstack_id, $error_code); 251 251 } 252 252 … … 259 259 # measure stats 260 260 $command = "$ppStatsFromMetadata $outputStatsReal - XCSTACK_SKYCELL"; 261 ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = run(command => $command, verbose => $verbose); 261 ( $success, $error_msg, $full_buf, $stdout_buf, $stderr_buf ) = run(command => $command, verbose => $verbose); 262 my $error_code = &parse_error_message ($success, $error_msg, $command); 262 263 unless ($success) { 263 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 264 &my_die("Unable to perform ppStatsFromMetadata: $error_code", $xcstack_id, $error_code); 264 &my_die("Unable to perform $command: $error_msg", $xcstack_id, $error_code); 265 265 } 266 266 foreach my $line (@$stdout_buf) { $cmdflags .= " $line"; } … … 295 295 $command .= " -dbname $dbname" if defined $dbname; 296 296 297 my ( $success, $error_ code, $full_buf, $stdout_buf, $stderr_buf ) =298 run(command => $command, verbose => $verbose);297 my ( $success, $error_msg, $full_buf, $stdout_buf, $stderr_buf ) = run(command => $command, verbose => $verbose); 298 my $error_code = &parse_error_message ($success, $error_msg, $command); 299 299 unless ($success) { 300 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 301 &my_die("Unable to perform xcstacktool $mode $error_code", $xcstack_id, $error_code); 300 &my_die("Unable to perform $command: $error_msg", $xcstack_id, $error_code); 302 301 } 303 302 } 304 305 303 } 306 304 307 305 print "I've updated the database: $xcstack_id\n"; 308 309 306 print "I've reached the end of processing with a code of $?: $xcstack_id\n"; 310 307 … … 411 408 my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files 412 409 413 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = run(command => $command, verbose => $verbose); 410 my ( $success, $error_msg, $full_buf, $stdout_buf, $stderr_buf ) = run(command => $command, verbose => $verbose); 411 my $error_code = &parse_error_message ($success, $error_msg, $command); 414 412 unless ($success) { 415 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 416 &my_die("Unable to perform $command", $xcstack_id, $error_code); 413 &my_die("Unable to perform $command: $error_msg", $xcstack_id, $error_code); 417 414 } 418 415 … … 435 432 } 436 433 434 # if the program exited normally, the exit value is returned 435 # if the program exited with a signal (abort, crash, etc), PS_EXIT_PROG_ERROR (4) is returned 436 # if the program failed to run, -PS_EXIT_PROG_ERROR (-4) is returned 437 sub parse_error_message { 438 my $success = shift; 439 my $error_msg = shift; 440 my $command = shift; 441 442 if ($success) { return 0; } 443 444 print "raw error_msg: $error_msg\n"; 445 print "full command: $command\n"; 446 447 if (&looks_like_number($error_msg)) { return (($error_msg >> 8) or ($PS_EXIT_PROG_ERROR)); } 448 449 # which of these match? 450 my ($error_code) = $error_msg =~ m/exited with value (\d+)/; 451 if (defined $error_code) { return $error_code; } 452 453 ($error_code) = $error_msg =~ m/died with signal (\d+)/; 454 # if (defined $error_code) { return (128 + $error_code); } 455 if (defined $error_code) { return ($PS_EXIT_PROG_ERROR); } 456 457 # probably failed to execute: 458 return (-1*$PS_EXIT_PROG_ERROR); 459 } 460 437 461 __END__ 438 462
Note:
See TracChangeset
for help on using the changeset viewer.
