IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jun 12, 2026, 2:47:49 PM (7 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_finish.pl

    r43048 r43052  
    1212use Time::Local;
    1313use Sys::Hostname;
    14 use IPC::Cmd 0.36 qw( can_run run );
     14use IPC::Cmd 0.36 qw( can_run );
    1515use File::Temp qw( tempfile );
    1616use File::Copy;
    1717use File::Basename qw(dirname);
    18 use Scalar::Util qw(looks_like_number);
    1918
    2019use PS::IPP::Metadata::Config;
     
    2221use PS::IPP::Metadata::List qw( parse_md_list );
    2322
    24 use PS::IPP::Config qw( :standard );
     23use PS::IPP::Config qw( :standard ps_run );
    2524use PS::IPP::PStamp::RequestFile qw( :standard );
    2625use PS::IPP::PStamp::Job qw( :standard );
     
    138137            $command   .= " -dbname $dbname" if $dbname;
    139138            $command   .= " -dbserver $dbserver" if $dbserver;
    140             my ( $success, $error_msg, $full_buf, $stdout_buf, $stderr_buf ) = run(command => $command, verbose => $verbose);
    141             my $error_code = &parse_error_message ($success, $error_msg, $command);
     139            my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = ps_run($command, $verbose);
    142140            unless ($success) {
    143                 die("Unable to perform $command error code: $error_code");
     141                my $rc = $error_code >> 8;
     142                die("Unable to perform $command error code: $rc ($error_code)");
    144143            }
    145144            my $output = join "", @$stdout_buf;
     
    261260        {
    262261            my $command = "$pstamp_results --input $table_def_name --output $outdir/results.fits";
    263             my ( $success, $error_msg, $full_buf, $stdout_buf, $stderr_buf ) = run(command => $command, verbose => $verbose);
    264             my $error_code = &parse_error_message ($success, $error_msg, $command);
     262            my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = ps_run(command => $command, verbose => $verbose);
    265263            unless ($success) {
    266264                print STDERR "Unable to perform $command error code: $error_code\n";
    267                 $request_fault = $error_code;
     265                $request_fault = $error_code >> 8;
    268266            } else {
    269267                # dump a textual representation
    270268                my $command = "$pstampdump $outdir/results.fits > $outdir/results.mdc";
    271269                my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    272                     run(command => $command, verbose => $verbose);
     270                    ps_run(command => $command, verbose => $verbose);
    273271                unless ($success) {
    274                     $request_fault = $error_code;
     272                    $request_fault = $error_code >> 8;
    275273                    my_die("Unable to perform $command error code: $error_code", $req_id, $request_fault);
    276274                }
     
    287285
    288286        my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    289             run(command => $command, verbose => $verbose);
     287            ps_run(command => $command, verbose => $verbose);
    290288        unless ($success) {
    291             $request_fault = $error_code;
     289            $request_fault = $error_code >> 8;
    292290            my_die("Unable to perform $command error code: $error_code\n", $req_id, $request_fault);
    293291        }
     
    299297        $command   .= " -dbserver $dbserver" if $dbserver;
    300298        my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    301             run(command => $command, verbose => $verbose);
     299            ps_run(command => $command, verbose => $verbose);
    302300        unless ($success) {
    303301            die("Unable to perform $command error code: $error_code");
     
    319317
    320318    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    321         run(command => $command, verbose => $verbose);
     319        ps_run(command => $command, verbose => $verbose);
    322320    unless ($success) {
    323321        die("Unable to perform $command error code: $error_code");
     
    435433            # run the tool and parse the output
    436434            my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    437                         run(command => $command, verbose => $verbose);
     435                        ps_run(command => $command, verbose => $verbose);
    438436            unless ($success) {
    439437                # not sure if we should die here
     
    506504    return 40587.0 + ($ticks/86400.);
    507505}
    508 
    509 # if the program exited normally, the exit value is returned
    510 # if the program exited with a signal (abort, crash, etc), PS_EXIT_PROG_ERROR (4) is returned
    511 # if the program failed to run, -PS_EXIT_PROG_ERROR (-4) is returned
    512 sub parse_error_message {
    513     my $success = shift;
    514     my $error_msg = shift;
    515     my $command = shift;
    516 
    517     if ($success) { return 0; }
    518 
    519     print "raw error_msg: $error_msg\n";
    520     print "full command: $command\n";
    521 
    522     if (&looks_like_number($error_msg)) { return (($error_msg >> 8) or ($PS_EXIT_PROG_ERROR)); }
    523        
    524     # which of these match?
    525     my ($error_code) = $error_msg =~ m/exited with value (\d+)/;
    526     if (defined $error_code) { return $error_code; }
    527    
    528     ($error_code) = $error_msg =~ m/died with signal (\d+)/;
    529 #   if (defined $error_code) { return (128 + $error_code); }
    530     if (defined $error_code) { return ($PS_EXIT_PROG_ERROR); }
    531    
    532     # probably failed to execute:
    533     return (-1*$PS_EXIT_PROG_ERROR);
    534 }
Note: See TracChangeset for help on using the changeset viewer.