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_parser_run.pl

    r43048 r43052  
    1313use Getopt::Long qw( GetOptions );
    1414use File::Basename qw( basename dirname);
    15 use Scalar::Util qw(looks_like_number);
    1615use File::Copy;
    1716use POSIX qw( strftime );
    1817use Carp;
    19 use IPC::Cmd 0.36 qw( can_run run );
     18use IPC::Cmd 0.36 qw( can_run );
    2019
    2120use PS::IPP::Metadata::Config;
     
    2322use PS::IPP::Metadata::List qw( parse_md_list );
    2423
    25 use PS::IPP::Config qw( :standard );
     24use PS::IPP::Config qw( :standard ps_run );
    2625use PS::IPP::PStamp::RequestFile qw( :standard );
    2726
     
    129128    # if the uri is an http uri download the file
    130129    my $command = "$dsget --uri $uri --filename $new_uri --timeout 120";
    131     my ( $success, $error_msg, $full_buf, $stdout_buf, $stderr_buf ) =
    132         run(command => $command, verbose => $verbose);
    133     my $error_code = &parse_error_message ($success, $error_msg, $command);
     130    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     131        ps_run(command => $command, verbose => $verbose);
    134132    unless ($success) {
    135         my_die("Unable to perform $command error code: $error_code", $req_id, $error_code);
     133        my_die("Unable to perform $command error code: $error_code", $req_id, $error_code >> 8);
    136134    }
    137135} elsif ($uri ne $new_uri) {
     
    206204    $command   .= " -dbname $dbname" if $dbname;
    207205    $command   .= " -dbserver $dbserver" if $dbserver;
    208     my ( $success, $error_msg, $full_buf, $stdout_buf, $stderr_buf ) =
     206    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    209207        run(command => $command, verbose => $verbose);
    210     my $error_code = &parse_error_message ($success, $error_msg, $command);
    211208    unless ($success) {
    212209        die("Unable to perform $command error code: $error_code");
     
    230227
    231228    my $command = "$parse_cmd";
    232     my ( $success, $error_msg, $full_buf, $stdout_buf, $stderr_buf ) =
    233         run(command => $command, verbose => $verbose);
    234     my $error_code = &parse_error_message ($success, $error_msg, $command);
     229    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     230        ps_run(command => $command, verbose => $verbose);
    235231
    236232    # save the contents of stderr (if any) to a file. This is relevant if
     
    258254        }
    259255    } else {
    260         $fault = $error_code;
     256        $fault = $error_code >> 8;
    261257    }
    262258}
     
    275271    $command   .= " -dbserver $dbserver" if $dbserver;
    276272    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    277         run(command => $command, verbose => $verbose);
     273        ps_run(command => $command, verbose => $verbose);
    278274    unless ($success) {
    279275        die("Unable to perform $command error code: $error_code");
     
    324320    $command   .= " -dbserver $dbserver" if $dbserver;
    325321    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    326         run(command => $command, verbose => $verbose);
     322        ps_run(command => $command, verbose => $verbose);
    327323    unless ($success) {
    328324        die("Unable to perform $command error code: $error_code");
     
    330326    exit $fault;
    331327}
    332 
    333 # if the program exited normally, the exit value is returned
    334 # if the program exited with a signal (abort, crash, etc), PS_EXIT_PROG_ERROR (4) is returned
    335 # if the program failed to run, -PS_EXIT_PROG_ERROR (-4) is returned
    336 sub parse_error_message {
    337     my $success = shift;
    338     my $error_msg = shift;
    339     my $command = shift;
    340 
    341     if ($success) { return 0; }
    342 
    343     print "raw error_msg: $error_msg\n";
    344     print "full command: $command\n";
    345 
    346     if (&looks_like_number($error_msg)) { return (($error_msg >> 8) or ($PS_EXIT_PROG_ERROR)); }
    347        
    348     # which of these match?
    349     my ($error_code) = $error_msg =~ m/exited with value (\d+)/;
    350     if (defined $error_code) { return $error_code; }
    351    
    352     ($error_code) = $error_msg =~ m/died with signal (\d+)/;
    353 #   if (defined $error_code) { return (128 + $error_code); }
    354     if (defined $error_code) { return ($PS_EXIT_PROG_ERROR); }
    355    
    356     # probably failed to execute:
    357     return (-1*$PS_EXIT_PROG_ERROR);
    358 }
    359 
Note: See TracChangeset for help on using the changeset viewer.