Changeset 42580
- Timestamp:
- Jan 10, 2024, 12:37:40 PM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20230313/ippScripts/scripts/xcsky.pl
r42574 r42580 18 18 19 19 use IPC::Cmd 0.36 qw( can_run run ); 20 use Scalar::Util qw(looks_like_number); 20 21 use PS::IPP::Metadata::Config; 21 22 use PS::IPP::Metadata::List qw( parse_md_list ); … … 113 114 my $command = "$xcskytool -inputs -xcsky_id $xcsky_id"; 114 115 $command .= " -dbname $dbname" if defined $dbname; 115 my ( $success, $error_ code, $full_buf, $stdout_buf, $stderr_buf ) =116 run(command => $command, verbose => $verbose);116 my ( $success, $error_msg, $full_buf, $stdout_buf, $stderr_buf ) = run(command => $command, verbose => $verbose); 117 my $error_code = &parse_error_message ($success, $error_msg, $command); 117 118 unless ($success) { 118 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 119 &my_die("Unable to perform xcskytool -inputs: $error_code", $xcsky_id, $error_code); 119 &my_die("Unable to perform $command: $error_msg", $xcsky_id, $error_code); 120 120 } 121 121 … … 268 268 269 269 unless ($no_op) { 270 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = run(command => $command, verbose => $verbose); 271 print "error code: $error_code\n"; 272 unless ($success) { 273 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 274 &my_die("Unable to perform psphotStack: $error_code", $xcsky_id, $error_code); 275 } 270 my ( $success, $error_msg, $full_buf, $stdout_buf, $stderr_buf ) = run(command => $command, verbose => $verbose); 271 my $error_code = &parse_error_message ($success, $error_msg, $command); 272 unless ($success) { 273 &my_die("Unable to perform psphotStack: $error_msg", $xcsky_id, $error_code); 274 } 276 275 277 276 # my $outputStatsReal = $ipprc->file_resolve($outputStats); … … 353 352 } 354 353 355 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 356 run(command => $command, verbose => $verbose); 357 unless ($success) { 358 print "error: $error_code\n"; 359 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 360 my $err_message = "Unable to perform: $command\n"; 361 warn($err_message); 354 my ( $success, $error_msg, $full_buf, $stdout_buf, $stderr_buf ) = run(command => $command, verbose => $verbose); 355 my $error_code = &parse_error_message ($success, $error_msg, $command); 356 unless ($success) { 357 warn("Unable to perform: $command\n"); 362 358 exit $error_code; 363 359 } 364 360 } 365 361 } 366 367 362 368 363 sub my_die … … 392 387 } 393 388 389 # if the program exited normally, the exit value is returned 390 # if the program exited with a signal (abort, crash, etc), PS_EXIT_PROG_ERROR (4) is returned 391 # if the program failed to run, -PS_EXIT_PROG_ERROR (-4) is returned 392 sub parse_error_message { 393 my $success = shift; 394 my $error_msg = shift; 395 my $command = shift; 396 397 if ($success) { return 0; } 398 399 print "raw error_msg: $error_msg\n"; 400 print "full command: $command\n"; 401 402 if (&looks_like_number($error_msg)) { return (($error_msg >> 8) or ($PS_EXIT_PROG_ERROR)); } 403 404 # which of these match? 405 my ($error_code) = $error_msg =~ m/exited with value (\d+)/; 406 if (defined $error_code) { return $error_code; } 407 408 ($error_code) = $error_msg =~ m/died with signal (\d+)/; 409 # if (defined $error_code) { return (128 + $error_code); } 410 if (defined $error_code) { return ($PS_EXIT_PROG_ERROR); } 411 412 # probably failed to execute: 413 return (-1*$PS_EXIT_PROG_ERROR); 414 } 415 394 416 END { 395 417 my $exit = $?;
Note:
See TracChangeset
for help on using the changeset viewer.
