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

    r43048 r43052  
    1515use File::Copy;
    1616use File::Temp qw(tempfile tempdir);
    17 use Scalar::Util qw(looks_like_number);
    1817
    1918use Digest::MD5::File qw( file_md5_hex );
    2019use PS::IPP::PStamp::RequestFile qw( :standard );
    2120use PS::IPP::PStamp::Job qw( :standard );
    22 use IPC::Cmd 0.36 qw( can_run run );
     21use IPC::Cmd 0.36 qw( can_run );
    2322use POSIX;
    2423
     
    2726use PS::IPP::Metadata::List qw( parse_md_list );
    2827
    29 use PS::IPP::Config qw( :standard );
     28use PS::IPP::Config qw( :standard ps_run );
    3029
    3130my ($job_id, $redirect_output, $outputBase, $rownum, $jobType, $options);
     
    222221        my $command = "$psgetcalibinfo --cam_id $cam_id --output $calibfile --dbname $params->{imagedb}";
    223222        my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    224             run(command => $command, verbose => $verbose);
     223            ps_run(command => $command, verbose => $verbose);
    225224
    226225        my $exitStatus;
     
    254253
    255254        my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    256             run(command => $command, verbose => $verbose);
     255            ps_run(command => $command, verbose => $verbose);
    257256
    258257        if (WIFEXITED($error_code)) {
     
    289288
    290289            my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    291                 run(command => $command, verbose => $verbose);
     290                ps_run(command => $command, verbose => $verbose);
    292291
    293292            if (WIFEXITED($error_code)) {
     
    311310                    my $command = "$fpack_gzip $tmpName > $numName";
    312311                    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    313                         run(command => $command, verbose => $verbose);
     312                        ps_run(command => $command, verbose => $verbose);
    314313
    315314                    if (WIFEXITED($error_code)) {
     
    330329                my $command = "$fpack_gzip $tmpBase.fits > $outputBase.exp.fits";
    331330                my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    332                     run(command => $command, verbose => $verbose);
     331                    ps_run(command => $command, verbose => $verbose);
    333332
    334333                if (WIFEXITED($error_code)) {
     
    412411    $command .= " --verbose" if $verbose;
    413412    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    414         run(command => $command, verbose => $verbose);
     413        ps_run(command => $command, verbose => $verbose);
    415414
    416415    if ($success) {
     
    437436    $command .= " --save-temps" if $save_temps;
    438437    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    439         run(command => $command, verbose => $verbose);
     438        ps_run(command => $command, verbose => $verbose);
    440439
    441440    # Although dqueryparse can potentially force more updates (and more jobs), it should still return success.
     
    461460    if (!$no_update) {
    462461        my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    463             run(command => $command, verbose => $verbose);
     462            ps_run(command => $command, verbose => $verbose);
    464463        unless ($success) {
    465464            die("Unable to perform $command: $error_code");
     
    652651
    653652    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    654         run(command => $command, verbose => $verbose);
     653        ps_run(command => $command, verbose => $verbose);
    655654    unless ($success) {
    656655        $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     
    826825            my $command = "$stack_bkg_mk_mdc --stack_id $stack_id --camera $camera --dbname $imagedb > $mdcfile";
    827826            my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    828                 run(command => $command, verbose => $verbose);
     827                ps_run(command => $command, verbose => $verbose);
    829828            unless ($success) {
    830829                $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     
    842841            $command .= " -mask $input_mask" if $input_mask;
    843842            my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    844                 run(command => $command, verbose => $very_verbose);
     843                ps_run(command => $command, verbose => $very_verbose);
    845844            unless ($success) {
    846845                # we turned off verbosity because ppBackgroundStack emits too much output
     
    867866
    868867            my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    869                 run(command => $command, verbose => $verbose);
     868                ps_run(command => $command, verbose => $verbose);
    870869            unless ($success) {
    871870                print STDERR join "", @$stderr_buf;
     
    947946    exit $exit_code;
    948947}
    949 
    950 
    951 # if the program exited normally, the exit value is returned
    952 # if the program exited with a signal (abort, crash, etc), PS_EXIT_PROG_ERROR (4) is returned
    953 # if the program failed to run, -PS_EXIT_PROG_ERROR (-4) is returned
    954 sub parse_error_message {
    955     my $success = shift;
    956     my $error_msg = shift;
    957     my $command = shift;
    958 
    959     if ($success) { return 0; }
    960 
    961     print "raw error_msg: $error_msg\n";
    962     print "full command: $command\n";
    963 
    964     if (&looks_like_number($error_msg)) { return (($error_msg >> 8) or ($PS_EXIT_PROG_ERROR)); }
    965        
    966     # which of these match?
    967     my ($error_code) = $error_msg =~ m/exited with value (\d+)/;
    968     if (defined $error_code) { return $error_code; }
    969    
    970     ($error_code) = $error_msg =~ m/died with signal (\d+)/;
    971 #   if (defined $error_code) { return (128 + $error_code); }
    972     if (defined $error_code) { return ($PS_EXIT_PROG_ERROR); }
    973    
    974     # probably failed to execute:
    975     return (-1*$PS_EXIT_PROG_ERROR);
    976 }
Note: See TracChangeset for help on using the changeset viewer.