- Timestamp:
- Jun 12, 2026, 2:47:49 PM (5 weeks ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-pstamp-20260421/pstamp/scripts/pstampparse.pl
r43048 r43052 15 15 use File::Temp qw(tempfile); 16 16 use File::Basename qw(basename); 17 use Scalar::Util qw(looks_like_number);18 17 use Carp; 19 18 use POSIX; … … 67 66 } 68 67 69 use IPC::Cmd 0.36 qw( can_run run);68 use IPC::Cmd 0.36 qw( can_run ); 70 69 71 70 use PS::IPP::Metadata::Config; … … 73 72 use PS::IPP::Metadata::List qw( parse_md_list ); 74 73 75 use PS::IPP::Config qw( :standard );74 use PS::IPP::Config qw( :standard ps_run ); 76 75 my $ipprc = PS::IPP::Config->new(); # IPP Configuration 77 76 … … 127 126 { 128 127 my $command = "echo $request_file_name | $fields -x 0 EXTNAME EXTVER REQ_NAME ACTION EMAIL"; 129 my ( $success, $error_msg, $full_buf, $stdout_buf, $stderr_buf ) = 130 run(command => $command, verbose => $verbose); 131 my $error_code = &parse_error_message ($success, $error_msg, $command); 128 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 129 ps_run(command => $command, verbose => $verbose); 132 130 133 131 # note fields doesn't return zero when it succeeds. 132 # XXX EAM 2026.06.10 : the above note has not been true since 2007! 134 133 $fields_output = join "", @$stdout_buf; 135 134 } … … 186 185 my $command = "$pstamptool -listreq -name $req_name -not_req_id $req_id"; 187 186 # no verbose so that error message about request not found doesn't appear in parse_error.txt 188 my ( $success, $error_msg, $full_buf, $stdout_buf, $stderr_buf ) = 189 run(command => $command, verbose => 0); 190 my $error_code = &parse_error_message ($success, $error_msg, $command); 191 my $exitStatus = $error_code; 187 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 188 ps_run(command => $command, verbose => 0); 189 my $exitStatus = $error_code >> 8; 192 190 if ($success) { 193 191 # -listreq succeeded there is already a request in the database with this name … … 285 283 unless ($no_update) { 286 284 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 287 run(command => $command, verbose => $verbose);285 ps_run(command => $command, verbose => $verbose); 288 286 unless ($success) { 289 287 my_die("$command failed", $PS_EXIT_UNKNOWN_ERROR); … … 313 311 my $command = "$pstampdump $request_file_name"; 314 312 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 315 run(command => $command, verbose => $verbose);313 ps_run(command => $command, verbose => $verbose); 316 314 unless ($success) { 317 315 print STDERR @$stderr_buf; … … 394 392 my $command = "$pstamptool -updatereq -req_id $req_id -set_label $label"; 395 393 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 396 run(command => $command, verbose => $verbose);394 ps_run(command => $command, verbose => $verbose); 397 395 unless ($success) { 398 396 my_die("$command failed", $PS_EXIT_UNKNOWN_ERROR); … … 822 820 my $start_addjob = gettimeofday(); 823 821 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 824 run(command => $command, verbose => $verbose);822 ps_run(command => $command, verbose => $verbose); 825 823 unless ($success) { 826 824 print STDERR @$stderr_buf; … … 977 975 # mode eq "queue_job" 978 976 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 979 run(command => $command, verbose => $verbose);977 ps_run(command => $command, verbose => $verbose); 980 978 unless ($success) { 981 979 print STDERR @$stderr_buf; … … 1030 1028 # mode eq "queue_job" 1031 1029 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 1032 run(command => $command, verbose => $verbose);1030 ps_run(command => $command, verbose => $verbose); 1033 1031 unless ($success) { 1034 1032 print STDERR @$stderr_buf; … … 1139 1137 1140 1138 if (!$no_update) { 1141 my ( $success, $error_msg, $full_buf, $stdout_buf, $stderr_buf ) = 1142 run(command => $command, verbose => $verbose); 1143 my $error_code = &parse_error_message ($success, $error_msg, $command); 1139 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 1140 ps_run(command => $command, verbose => $verbose); 1144 1141 unless ($success) { 1145 my $fault = $error_code ;1142 my $fault = $error_code >> 8; 1146 1143 print STDERR "$command failed with fault $fault\n"; 1147 1144 if ($fault < $PSTAMP_FIRST_ERROR_CODE) { … … 1425 1422 exit $fault; 1426 1423 } 1427 1428 # if the program exited normally, the exit value is returned1429 # if the program exited with a signal (abort, crash, etc), PS_EXIT_PROG_ERROR (4) is returned1430 # if the program failed to run, -PS_EXIT_PROG_ERROR (-4) is returned1431 sub parse_error_message {1432 my $success = shift;1433 my $error_msg = shift;1434 my $command = shift;1435 1436 if ($success) { return 0; }1437 1438 print "raw error_msg: $error_msg\n";1439 print "full command: $command\n";1440 1441 if (&looks_like_number($error_msg)) { return (($error_msg >> 8) or ($PS_EXIT_PROG_ERROR)); }1442 1443 # which of these match?1444 my ($error_code) = $error_msg =~ m/exited with value (\d+)/;1445 if (defined $error_code) { return $error_code; }1446 1447 ($error_code) = $error_msg =~ m/died with signal (\d+)/;1448 # if (defined $error_code) { return (128 + $error_code); }1449 if (defined $error_code) { return ($PS_EXIT_PROG_ERROR); }1450 1451 # probably failed to execute:1452 return (-1*$PS_EXIT_PROG_ERROR);1453 }1454
Note:
See TracChangeset
for help on using the changeset viewer.
