IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jan 28, 2024, 2:24:07 PM (2 years ago)
Author:
eugene
Message:

fixes to get xcstack and related scripts working

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20230313/ippScripts/scripts/xcstack_skycell.pl

    r42560 r42602  
    1919
    2020use IPC::Cmd 0.36 qw( can_run run );
     21use Scalar::Util qw(looks_like_number);
    2122use PS::IPP::Metadata::Config;
    2223use PS::IPP::Metadata::List qw( parse_md_list );
     
    244245
    245246    # cannot use run_command here (no metadata output to parse)
    246     my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    247         run(command => $command, verbose => $verbose);
     247    my ( $success, $error_msg, $full_buf, $stdout_buf, $stderr_buf ) = run(command => $command, verbose => $verbose);
     248    my $error_code = &parse_error_message ($success, $error_msg, $command);
    248249    unless ($success) {
    249         $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    250         &my_die("Unable to perform ppStack: $error_code", $xcstack_id, $error_code);
     250        &my_die("Unable to perform $command: $error_msg", $xcstack_id, $error_code);
    251251    }
    252252
     
    259259        # measure stats
    260260        $command = "$ppStatsFromMetadata $outputStatsReal - XCSTACK_SKYCELL";
    261         ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = run(command => $command, verbose => $verbose);
     261        ( $success, $error_msg, $full_buf, $stdout_buf, $stderr_buf ) = run(command => $command, verbose => $verbose);
     262        my $error_code = &parse_error_message ($success, $error_msg, $command);
    262263        unless ($success) {
    263             $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    264             &my_die("Unable to perform ppStatsFromMetadata: $error_code", $xcstack_id, $error_code);
     264            &my_die("Unable to perform $command: $error_msg", $xcstack_id, $error_code);
    265265        }
    266266        foreach my $line (@$stdout_buf) { $cmdflags .= " $line"; }
     
    295295        $command .= " -dbname $dbname" if defined $dbname;
    296296
    297         my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    298             run(command => $command, verbose => $verbose);
     297        my ( $success, $error_msg, $full_buf, $stdout_buf, $stderr_buf ) = run(command => $command, verbose => $verbose);
     298        my $error_code = &parse_error_message ($success, $error_msg, $command);
    299299        unless ($success) {
    300             $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    301             &my_die("Unable to perform xcstacktool $mode $error_code", $xcstack_id, $error_code);
     300            &my_die("Unable to perform $command: $error_msg", $xcstack_id, $error_code);
    302301        }
    303302    }
    304 
    305303}
    306304
    307305print "I've updated the database: $xcstack_id\n";
    308 
    309306print "I've reached the end of processing with a code of $?: $xcstack_id\n";
    310307
     
    411408    my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files
    412409
    413     my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = run(command => $command, verbose => $verbose);
     410    my ( $success, $error_msg, $full_buf, $stdout_buf, $stderr_buf ) = run(command => $command, verbose => $verbose);
     411    my $error_code = &parse_error_message ($success, $error_msg, $command);
    414412    unless ($success) {
    415         $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    416         &my_die("Unable to perform $command", $xcstack_id, $error_code);
     413        &my_die("Unable to perform $command: $error_msg", $xcstack_id, $error_code);
    417414    }
    418415
     
    435432}
    436433
     434# if the program exited normally, the exit value is returned
     435# if the program exited with a signal (abort, crash, etc), PS_EXIT_PROG_ERROR (4) is returned
     436# if the program failed to run, -PS_EXIT_PROG_ERROR (-4) is returned
     437sub parse_error_message {
     438    my $success = shift;
     439    my $error_msg = shift;
     440    my $command = shift;
     441
     442    if ($success) { return 0; }
     443
     444    print "raw error_msg: $error_msg\n";
     445    print "full command: $command\n";
     446
     447    if (&looks_like_number($error_msg)) { return (($error_msg >> 8) or ($PS_EXIT_PROG_ERROR)); }
     448       
     449    # which of these match?
     450    my ($error_code) = $error_msg =~ m/exited with value (\d+)/;
     451    if (defined $error_code) { return $error_code; }
     452   
     453    ($error_code) = $error_msg =~ m/died with signal (\d+)/;
     454#   if (defined $error_code) { return (128 + $error_code); }
     455    if (defined $error_code) { return ($PS_EXIT_PROG_ERROR); }
     456   
     457    # probably failed to execute:
     458    return (-1*$PS_EXIT_PROG_ERROR);
     459}
     460
    437461__END__
    438462
Note: See TracChangeset for help on using the changeset viewer.