IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jun 12, 2026, 2:47:49 PM (5 weeks ago)
Author:
eugene
Message:

convert the IPC::Cmd run calls to ps_run to handle inconsistent behavior between IPC:Cmd versions pre- and post-0.40

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-pstamp-20260421/pstamp/scripts/pstampparse.pl

    r43048 r43052  
    1515use File::Temp qw(tempfile);
    1616use File::Basename qw(basename);
    17 use Scalar::Util qw(looks_like_number);
    1817use Carp;
    1918use POSIX;
     
    6766}
    6867
    69 use IPC::Cmd 0.36 qw( can_run run );
     68use IPC::Cmd 0.36 qw( can_run );
    7069
    7170use PS::IPP::Metadata::Config;
     
    7372use PS::IPP::Metadata::List qw( parse_md_list );
    7473
    75 use PS::IPP::Config qw( :standard );
     74use PS::IPP::Config qw( :standard ps_run );
    7675my $ipprc = PS::IPP::Config->new(); # IPP Configuration
    7776
     
    127126{
    128127    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);
    132130
    133131    # note fields doesn't return zero when it succeeds.
     132    # XXX EAM 2026.06.10 : the above note has not been true since 2007!
    134133    $fields_output = join "", @$stdout_buf;
    135134}
     
    186185    my $command = "$pstamptool -listreq  -name $req_name -not_req_id $req_id";
    187186    # 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;
    192190    if ($success) {
    193191        # -listreq succeeded there is already a request in the database with this name
     
    285283    unless ($no_update) {
    286284        my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    287             run(command => $command, verbose => $verbose);
     285            ps_run(command => $command, verbose => $verbose);
    288286        unless ($success) {
    289287            my_die("$command failed", $PS_EXIT_UNKNOWN_ERROR);
     
    313311    my $command = "$pstampdump $request_file_name";
    314312    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    315         run(command => $command, verbose => $verbose);
     313        ps_run(command => $command, verbose => $verbose);
    316314    unless ($success) {
    317315        print STDERR @$stderr_buf;
     
    394392    my $command = "$pstamptool -updatereq -req_id $req_id  -set_label $label";
    395393    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    396         run(command => $command, verbose => $verbose);
     394        ps_run(command => $command, verbose => $verbose);
    397395    unless ($success) {
    398396        my_die("$command failed", $PS_EXIT_UNKNOWN_ERROR);
     
    822820        my $start_addjob = gettimeofday();
    823821        my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    824             run(command => $command, verbose => $verbose);
     822            ps_run(command => $command, verbose => $verbose);
    825823        unless ($success) {
    826824            print STDERR @$stderr_buf;
     
    977975            # mode eq "queue_job"
    978976            my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    979                 run(command => $command, verbose => $verbose);
     977                ps_run(command => $command, verbose => $verbose);
    980978            unless ($success) {
    981979                print STDERR @$stderr_buf;
     
    10301028        # mode eq "queue_job"
    10311029        my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    1032             run(command => $command, verbose => $verbose);
     1030            ps_run(command => $command, verbose => $verbose);
    10331031        unless ($success) {
    10341032            print STDERR @$stderr_buf;
     
    11391137
    11401138    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);
    11441141        unless ($success) {
    1145             my $fault = $error_code;
     1142            my $fault = $error_code >> 8;
    11461143            print STDERR "$command failed with fault $fault\n";
    11471144            if ($fault < $PSTAMP_FIRST_ERROR_CODE) {
     
    14251422    exit $fault;
    14261423}
    1427 
    1428 # if the program exited normally, the exit value is returned
    1429 # if the program exited with a signal (abort, crash, etc), PS_EXIT_PROG_ERROR (4) is returned
    1430 # if the program failed to run, -PS_EXIT_PROG_ERROR (-4) is returned
    1431 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.