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/pstamp_queue_requests.pl

    r43048 r43052  
    1111
    1212use Getopt::Long qw( GetOptions );
    13 use Scalar::Util qw(looks_like_number);
    1413
    1514use Sys::Hostname;
     
    3534}
    3635
    37 use IPC::Cmd 0.36 qw( can_run run );
     36use IPC::Cmd 0.36 qw( can_run );
    3837
    3938use PS::IPP::Metadata::Config;
     
    5150                       metadataLookupBool
    5251                       caturi
     52                       ps_run
    5353                       );
    5454
     
    7878    $command .= " -dbserver $dbserver" if $dbserver;
    7979
    80     my ( $success, $error_msg, $full_buf, $stdout_buf, $stderr_buf ) =
    81         run(command => $command, verbose => $verbose);
    82     my $error_code = &parse_error_message ($success, $error_msg, $command);
     80    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     81        ps_run(command => $command, verbose => $verbose);
    8382    unless ($success) {
    84         my $rc = $error_code;
     83        my $rc = ($error_code >> 8);
    8584        die("Unable to perform pstamptool -datastore: $rc");
    8685    }
     
    123122        $command .= " --timeout $timeout";
    124123
    125         my ( $success, $error_msg, $full_buf, $stdout_buf, $stderr_buf ) =
    126             run(command => $command, verbose => $verbose);
    127         my $error_code = &parse_error_message ($success, $error_msg, $command);
     124        my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     125            ps_run(command => $command, verbose => $verbose);
    128126        unless ($success) {
    129127            # dsproductls exit status is the http error code - 300
    130             my $exit_status = $error_code;
     128            my $exit_status = ($error_code >> 8);
    131129
    132130            # don't die on "common faults"
     
    170168        {
    171169            my $command = "$dsfilesetls --uri $uri";
    172             my ( $success, $error_msg, $full_buf, $stdout_buf, $stderr_buf ) =
    173                     run(command => $command, verbose => $verbose);
    174             my $error_code = &parse_error_message ($success, $error_msg, $command);
     170            my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     171                    ps_run(command => $command, verbose => $verbose);
    175172            unless ($success) {
    176173                # we don't want to die here. We need to set lastFileset
     
    201198                $command .= " -dbserver $dbserver" if $dbserver;
    202199
    203                 my ( $success, $error_msg, $full_buf, $stdout_buf, $stderr_buf ) =
    204                         run(command => $command, verbose => $verbose);
    205                 my $error_code = &parse_error_message ($success, $error_msg, $command);
     200                my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     201                        ps_run(command => $command, verbose => $verbose);
    206202
    207203                unless ($success) {
     
    217213            $command .= " -dbname $dbname" if $dbname;
    218214            $command .= " -dbserver $dbserver" if $dbserver;
    219             my ( $success, $error_msg, $full_buf, $stdout_buf, $stderr_buf ) =
    220                 run(command => $command, verbose => $verbose);
    221             my $error_code = &parse_error_message ($success, $error_msg, $command);
     215            my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     216                ps_run(command => $command, verbose => $verbose);
    222217            unless ($success) {
    223218                die("Unable to perform pstamptool -moddatastore: $error_code");
     
    238233                $command .= " -dbname $dbname" if $dbname;
    239234                $command .= " -dbserver $dbserver" if $dbserver;
    240     my ( $success, $error_msg, $full_buf, $stdout_buf, $stderr_buf ) =
     235    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    241236        run(command => $command, verbose => $verbose);
    242     my $error_code = &parse_error_message ($success, $error_msg, $command);
    243237    unless ($success) {
    244238        die("Unable to perform pstamptool -moddatastore: $error_code");
    245239    }
    246240}
    247 
    248 # if the program exited normally, the exit value is returned
    249 # if the program exited with a signal (abort, crash, etc), PS_EXIT_PROG_ERROR (4) is returned
    250 # if the program failed to run, -PS_EXIT_PROG_ERROR (-4) is returned
    251 sub parse_error_message {
    252     my $success = shift;
    253     my $error_msg = shift;
    254     my $command = shift;
    255 
    256     if ($success) { return 0; }
    257 
    258     print "raw error_msg: $error_msg\n";
    259     print "full command: $command\n";
    260 
    261     if (&looks_like_number($error_msg)) { return (($error_msg >> 8) or ($PS_EXIT_PROG_ERROR)); }
    262        
    263     # which of these match?
    264     my ($error_code) = $error_msg =~ m/exited with value (\d+)/;
    265     if (defined $error_code) { return $error_code; }
    266    
    267     ($error_code) = $error_msg =~ m/died with signal (\d+)/;
    268 #   if (defined $error_code) { return (128 + $error_code); }
    269     if (defined $error_code) { return ($PS_EXIT_PROG_ERROR); }
    270    
    271     # probably failed to execute:
    272     return (-1*$PS_EXIT_PROG_ERROR);
    273 }
Note: See TracChangeset for help on using the changeset viewer.