IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 43048


Ignore:
Timestamp:
Jun 1, 2026, 4:53:16 PM (7 weeks ago)
Author:
eugene
Message:

working on modernizing the error_code trapping

Location:
branches/eam_branches/ipp-pstamp-20260421/pstamp/scripts
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-pstamp-20260421/pstamp/scripts/psmkreq

    r40421 r43048  
    1717use File::Temp qw(tempfile);
    1818use File::Basename qw(basename);
     19use Scalar::Util qw(looks_like_number);
    1920use IPC::Cmd 0.36 qw( can_run run );
    2021use Carp;
     
    295296    my $command = "$pstamp_request_file --input $table_def_name --req_name $req_name";
    296297    $command .= " --output $output" if $output;
    297     my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     298    my ( $success, $error_msg, $full_buf, $stdout_buf, $stderr_buf ) =
    298299        run(command => $command, verbose => $verbose);
     300    my $error_code = &parse_error_message ($success, $error_msg, $command);
    299301    unless ($success) {
    300302        print STDERR @$stderr_buf;
    301         exit $error_code >> 8;
     303        exit $error_code;
    302304    }
    303305}
     
    447449
    448450}
     451
     452# if the program exited normally, the exit value is returned
     453# if the program exited with a signal (abort, crash, etc), PS_EXIT_PROG_ERROR (4) is returned
     454# if the program failed to run, -PS_EXIT_PROG_ERROR (-4) is returned
     455sub parse_error_message {
     456    my $success = shift;
     457    my $error_msg = shift;
     458    my $command = shift;
     459
     460    if ($success) { return 0; }
     461
     462    print "raw error_msg: $error_msg\n";
     463    print "full command: $command\n";
     464
     465    if (&looks_like_number($error_msg)) { return (($error_msg >> 8) or ($PS_EXIT_PROG_ERROR)); }
     466       
     467    # which of these match?
     468    my ($error_code) = $error_msg =~ m/exited with value (\d+)/;
     469    if (defined $error_code) { return $error_code; }
     470   
     471    ($error_code) = $error_msg =~ m/died with signal (\d+)/;
     472#   if (defined $error_code) { return (128 + $error_code); }
     473    if (defined $error_code) { return ($PS_EXIT_PROG_ERROR); }
     474   
     475    # probably failed to execute:
     476    return (-1*$PS_EXIT_PROG_ERROR);
     477}
     478
  • branches/eam_branches/ipp-pstamp-20260421/pstamp/scripts/pstamp_finish.pl

    r43023 r43048  
    1616use File::Copy;
    1717use File::Basename qw(dirname);
     18use Scalar::Util qw(looks_like_number);
    1819
    1920use PS::IPP::Metadata::Config;
  • branches/eam_branches/ipp-pstamp-20260421/pstamp/scripts/pstamp_job_run.pl

    r42981 r43048  
    1515use File::Copy;
    1616use File::Temp qw(tempfile tempdir);
     17use Scalar::Util qw(looks_like_number);
     18
    1719use Digest::MD5::File qw( file_md5_hex );
    1820use PS::IPP::PStamp::RequestFile qw( :standard );
     
    946948}
    947949
     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
     954sub 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}
  • branches/eam_branches/ipp-pstamp-20260421/pstamp/scripts/pstamp_parser_run.pl

    r42981 r43048  
    1313use Getopt::Long qw( GetOptions );
    1414use File::Basename qw( basename dirname);
     15use Scalar::Util qw(looks_like_number);
    1516use File::Copy;
    1617use POSIX qw( strftime );
     
    128129    # if the uri is an http uri download the file
    129130    my $command = "$dsget --uri $uri --filename $new_uri --timeout 120";
    130     my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    131         run(command => $command, verbose => $verbose);
     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);
    132134    unless ($success) {
    133         my_die("Unable to perform $command error code: $error_code", $req_id, $error_code >> 8);
     135        my_die("Unable to perform $command error code: $error_code", $req_id, $error_code);
    134136    }
    135137} elsif ($uri ne $new_uri) {
     
    204206    $command   .= " -dbname $dbname" if $dbname;
    205207    $command   .= " -dbserver $dbserver" if $dbserver;
    206     my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    207         run(command => $command, verbose => $verbose);
     208    my ( $success, $error_msg, $full_buf, $stdout_buf, $stderr_buf ) =
     209        run(command => $command, verbose => $verbose);
     210    my $error_code = &parse_error_message ($success, $error_msg, $command);
    208211    unless ($success) {
    209212        die("Unable to perform $command error code: $error_code");
     
    227230
    228231    my $command = "$parse_cmd";
    229     my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    230         run(command => $command, verbose => $verbose);
     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);
    231235
    232236    # save the contents of stderr (if any) to a file. This is relevant if
     
    254258        }
    255259    } else {
    256         $fault = $error_code >> 8;
     260        $fault = $error_code;
    257261    }
    258262}
     
    326330    exit $fault;
    327331}
     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
     336sub 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
  • branches/eam_branches/ipp-pstamp-20260421/pstamp/scripts/pstamp_queue_cleanup.pl

    r42981 r43048  
    1010use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt );
    1111use Pod::Usage qw( pod2usage );
     12use Scalar::Util qw(looks_like_number);
    1213
    1314my $verbose;
     
    6970
    7071my $command = "$pstamptool -updatereq -set_state goto_cleaned -state stop -timestamp_end $timestamp_end";
    71 my  ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     72my  ( $success, $error_msg, $full_buf, $stdout_buf, $stderr_buf ) =
    7273    run(command => $command, verbose => $verbose);
     74my $error_code = &parse_error_message ($success, $error_msg, $command);
    7375unless ($success) {
    74     $error_code = (($error_code >> 8) or 1);
     76    $error_code = ($error_code or 1);
    7577    warn("$command failed. exit status: $error_code");
    7678    exit $error_code;
     
    7981
    8082exit 0;
     83
     84# if the program exited normally, the exit value is returned
     85# if the program exited with a signal (abort, crash, etc), PS_EXIT_PROG_ERROR (4) is returned
     86# if the program failed to run, -PS_EXIT_PROG_ERROR (-4) is returned
     87sub parse_error_message {
     88    my $success = shift;
     89    my $error_msg = shift;
     90    my $command = shift;
     91
     92    if ($success) { return 0; }
     93
     94    print "raw error_msg: $error_msg\n";
     95    print "full command: $command\n";
     96
     97    if (&looks_like_number($error_msg)) { return (($error_msg >> 8) or ($PS_EXIT_PROG_ERROR)); }
     98       
     99    # which of these match?
     100    my ($error_code) = $error_msg =~ m/exited with value (\d+)/;
     101    if (defined $error_code) { return $error_code; }
     102   
     103    ($error_code) = $error_msg =~ m/died with signal (\d+)/;
     104#   if (defined $error_code) { return (128 + $error_code); }
     105    if (defined $error_code) { return ($PS_EXIT_PROG_ERROR); }
     106   
     107    # probably failed to execute:
     108    return (-1*$PS_EXIT_PROG_ERROR);
     109}
  • branches/eam_branches/ipp-pstamp-20260421/pstamp/scripts/pstamp_queue_requests.pl

    r42981 r43048  
    1111
    1212use Getopt::Long qw( GetOptions );
     13use Scalar::Util qw(looks_like_number);
    1314
    1415use Sys::Hostname;
     
    7778    $command .= " -dbserver $dbserver" if $dbserver;
    7879
    79     my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     80    my ( $success, $error_msg, $full_buf, $stdout_buf, $stderr_buf ) =
    8081        run(command => $command, verbose => $verbose);
     82    my $error_code = &parse_error_message ($success, $error_msg, $command);
    8183    unless ($success) {
    82         my $rc = $error_code >> 8;
     84        my $rc = $error_code;
    8385        die("Unable to perform pstamptool -datastore: $rc");
    8486    }
     
    121123        $command .= " --timeout $timeout";
    122124
    123         my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     125        my ( $success, $error_msg, $full_buf, $stdout_buf, $stderr_buf ) =
    124126            run(command => $command, verbose => $verbose);
     127        my $error_code = &parse_error_message ($success, $error_msg, $command);
    125128        unless ($success) {
    126129            # dsproductls exit status is the http error code - 300
    127             my $exit_status = $error_code >> 8;
     130            my $exit_status = $error_code;
    128131
    129132            # don't die on "common faults"
     
    167170        {
    168171            my $command = "$dsfilesetls --uri $uri";
    169             my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     172            my ( $success, $error_msg, $full_buf, $stdout_buf, $stderr_buf ) =
    170173                    run(command => $command, verbose => $verbose);
     174            my $error_code = &parse_error_message ($success, $error_msg, $command);
    171175            unless ($success) {
    172176                # we don't want to die here. We need to set lastFileset
     
    197201                $command .= " -dbserver $dbserver" if $dbserver;
    198202
    199                 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     203                my ( $success, $error_msg, $full_buf, $stdout_buf, $stderr_buf ) =
    200204                        run(command => $command, verbose => $verbose);
     205                my $error_code = &parse_error_message ($success, $error_msg, $command);
    201206
    202207                unless ($success) {
     
    208213
    209214        {
    210         ## now update the last_fileset column in pstampDataStore
    211         my $command = "$pstamptool -ds_id $ds_id -moddatastore -set_last_fileset $lastFileset";
    212         $command .= " -dbname $dbname" if $dbname;
    213         $command .= " -dbserver $dbserver" if $dbserver;
    214         my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    215             run(command => $command, verbose => $verbose);
    216             unless ($success) {
    217                 die("Unable to perform pstamptool -moddatastore: $error_code");
    218             }
     215            ## now update the last_fileset column in pstampDataStore
     216            my $command = "$pstamptool -ds_id $ds_id -moddatastore -set_last_fileset $lastFileset";
     217            $command .= " -dbname $dbname" if $dbname;
     218            $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);
     222            unless ($success) {
     223                die("Unable to perform pstamptool -moddatastore: $error_code");
     224            }
    219225        }
    220226        last if ($numFilesets >= $limit);
     
    232238                $command .= " -dbname $dbname" if $dbname;
    233239                $command .= " -dbserver $dbserver" if $dbserver;
    234     my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     240    my ( $success, $error_msg, $full_buf, $stdout_buf, $stderr_buf ) =
    235241        run(command => $command, verbose => $verbose);
     242    my $error_code = &parse_error_message ($success, $error_msg, $command);
    236243    unless ($success) {
    237244        die("Unable to perform pstamptool -moddatastore: $error_code");
    238245    }
    239246}
     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
     251sub 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}
  • branches/eam_branches/ipp-pstamp-20260421/pstamp/scripts/pstamp_queue_update_cleanup.pl

    r42981 r43048  
    1010use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt );
    1111use Pod::Usage qw( pod2usage );
     12use Scalar::Util qw(looks_like_number);
    1213
    1314my $verbose;
     
    6667
    6768my $command = "$pstamptool -pendingdependent -includefaulted -simple";
    68 my  ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     69my  ( $success, $error_msg, $full_buf, $stdout_buf, $stderr_buf ) =
    6970    run(command => $command, verbose => $very_verbose);
     71my $error_code = &parse_error_message ($success, $error_msg, $command);
    7072unless ($success) {
    71     $error_code = (($error_code >> 8) or 1);
     73    $error_code = ($error_code or 1);
    7274    warn("$command failed. exit status: $error_code");
    7375    exit $error_code;
     
    8688        $command .= " -dbname $imagedb";
    8789
    88         my  ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     90        my  ( $success, $error_msg, $full_buf, $stdout_buf, $stderr_buf ) =
    8991            run(command => $command, verbose => $very_verbose);
     92        my $error_code = &parse_error_message ($success, $error_msg, $command);
    9093        unless ($success) {
    91             $error_code = (($error_code >> 8) or 1);
     94            $error_code = ($error_code or 1);
    9295            warn("$command failed. exit status: $error_code");
    9396            exit $error_code;
     
    97100
    98101exit 0;
     102
     103# if the program exited normally, the exit value is returned
     104# if the program exited with a signal (abort, crash, etc), PS_EXIT_PROG_ERROR (4) is returned
     105# if the program failed to run, -PS_EXIT_PROG_ERROR (-4) is returned
     106sub parse_error_message {
     107    my $success = shift;
     108    my $error_msg = shift;
     109    my $command = shift;
     110
     111    if ($success) { return 0; }
     112
     113    print "raw error_msg: $error_msg\n";
     114    print "full command: $command\n";
     115
     116    if (&looks_like_number($error_msg)) { return (($error_msg >> 8) or ($PS_EXIT_PROG_ERROR)); }
     117       
     118    # which of these match?
     119    my ($error_code) = $error_msg =~ m/exited with value (\d+)/;
     120    if (defined $error_code) { return $error_code; }
     121   
     122    ($error_code) = $error_msg =~ m/died with signal (\d+)/;
     123#   if (defined $error_code) { return (128 + $error_code); }
     124    if (defined $error_code) { return ($PS_EXIT_PROG_ERROR); }
     125   
     126    # probably failed to execute:
     127    return (-1*$PS_EXIT_PROG_ERROR);
     128}
  • branches/eam_branches/ipp-pstamp-20260421/pstamp/scripts/pstamp_save_server_status.pl

    r42981 r43048  
    1111use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt );
    1212use Pod::Usage qw( pod2usage );
     13use Scalar::Util qw(looks_like_number);
    1314
    1415my $updatelink;
     
    6364my $command = "pstamp_server_status --workdir $pstamp_workdir > $file";
    6465#my $command = "pstamp_server_status > $file";
    65 my  ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     66my  ( $success, $error_msgo, $full_buf, $stdout_buf, $stderr_buf ) =
    6667    run(command => $command, verbose => $verbose);
     68my $error_code = &parse_error_message ($success, $error_msg, $command);
    6769unless ($success) {
    68     $error_code = (($error_code >> 8) or 1);
     70    $error_code = ($error_code or 1);
    6971    warn("$command failed. exit status: $error_code");
    7072    exit $error_code;
     
    8082
    8183exit 0;
     84
     85# if the program exited normally, the exit value is returned
     86# if the program exited with a signal (abort, crash, etc), PS_EXIT_PROG_ERROR (4) is returned
     87# if the program failed to run, -PS_EXIT_PROG_ERROR (-4) is returned
     88sub parse_error_message {
     89    my $success = shift;
     90    my $error_msg = shift;
     91    my $command = shift;
     92
     93    if ($success) { return 0; }
     94
     95    print "raw error_msg: $error_msg\n";
     96    print "full command: $command\n";
     97
     98    if (&looks_like_number($error_msg)) { return (($error_msg >> 8) or ($PS_EXIT_PROG_ERROR)); }
     99       
     100    # which of these match?
     101    my ($error_code) = $error_msg =~ m/exited with value (\d+)/;
     102    if (defined $error_code) { return $error_code; }
     103   
     104    ($error_code) = $error_msg =~ m/died with signal (\d+)/;
     105#   if (defined $error_code) { return (128 + $error_code); }
     106    if (defined $error_code) { return ($PS_EXIT_PROG_ERROR); }
     107   
     108    # probably failed to execute:
     109    return (-1*$PS_EXIT_PROG_ERROR);
     110}
  • branches/eam_branches/ipp-pstamp-20260421/pstamp/scripts/pstamp_server_status

    r42983 r43048  
    1313use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt );
    1414use Pod::Usage qw( pod2usage );
    15 
     15use Scalar::Util qw(looks_like_number);
    1616
    1717my ($rundir, $workdir, $verbose, $save_temps);
     
    7171    my $serverRunning = 0;
    7272    my $command = "$pantasks_client < $pantasks_script";
    73     my  ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     73    my  ( $success, $error_msg, $full_buf, $stdout_buf, $stderr_buf ) =
    7474        run(command => $command, verbose => $verbose);
     75    my $error_code = &parse_error_message ($success, $error_msg, $command);
    7576    if ($success) {
    7677        $serverRunning = 1;
    7778    } else {
    78         $error_code = (($error_code >> 8) or 1);
     79        $error_code = ($error_code or 1);
    7980        if ($error_code == 12 || $error_code == 13) {
    8081            print "Postage Stamp Server is not running\n<br>";
     
    205206
    206207exit 0;
     208
     209# if the program exited normally, the exit value is returned
     210# if the program exited with a signal (abort, crash, etc), PS_EXIT_PROG_ERROR (4) is returned
     211# if the program failed to run, -PS_EXIT_PROG_ERROR (-4) is returned
     212sub parse_error_message {
     213    my $success = shift;
     214    my $error_msg = shift;
     215    my $command = shift;
     216
     217    if ($success) { return 0; }
     218
     219    print "raw error_msg: $error_msg\n";
     220    print "full command: $command\n";
     221
     222    if (&looks_like_number($error_msg)) { return (($error_msg >> 8) or ($PS_EXIT_PROG_ERROR)); }
     223       
     224    # which of these match?
     225    my ($error_code) = $error_msg =~ m/exited with value (\d+)/;
     226    if (defined $error_code) { return $error_code; }
     227   
     228    ($error_code) = $error_msg =~ m/died with signal (\d+)/;
     229#   if (defined $error_code) { return (128 + $error_code); }
     230    if (defined $error_code) { return ($PS_EXIT_PROG_ERROR); }
     231   
     232    # probably failed to execute:
     233    return (-1*$PS_EXIT_PROG_ERROR);
     234}
  • branches/eam_branches/ipp-pstamp-20260421/pstamp/scripts/pstamp_webrequest.pl

    r42981 r43048  
    2525my $req_name_prefix = 'web';
    2626my $username;
     27
     28my $DEBUG = 0;
    2729
    2830GetOptions(
     
    9395    my $command = "$psmkreq --req_name $request_name  --output $request_file @ARGV";
    9496
    95 if (0) {
     97if ($DEBUG) {
    9698open DEBUG, ">>/tmp/pstamp.debug.log";
    9799print DEBUG "\ncommand is: $command\n";
  • branches/eam_branches/ipp-pstamp-20260421/pstamp/scripts/pstampparse.pl

    r42981 r43048  
    1515use File::Temp qw(tempfile);
    1616use File::Basename qw(basename);
     17use Scalar::Util qw(looks_like_number);
    1718use Carp;
    1819use POSIX;
     
    126127{
    127128    my $command = "echo $request_file_name | $fields -x 0 EXTNAME EXTVER REQ_NAME ACTION EMAIL";
    128     my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     129    my ( $success, $error_msg, $full_buf, $stdout_buf, $stderr_buf ) =
    129130        run(command => $command, verbose => $verbose);
     131    my $error_code = &parse_error_message ($success, $error_msg, $command);
    130132
    131133    # note fields doesn't return zero when it succeeds.
     
    184186    my $command = "$pstamptool -listreq  -name $req_name -not_req_id $req_id";
    185187    # no verbose so that error message about request not found doesn't appear in parse_error.txt
    186     my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     188    my ( $success, $error_msg, $full_buf, $stdout_buf, $stderr_buf ) =
    187189        run(command => $command, verbose => 0);
    188     my $exitStatus = $error_code >> 8;
     190    my $error_code = &parse_error_message ($success, $error_msg, $command);
     191    my $exitStatus = $error_code;
    189192    if ($success) {
    190193        # -listreq succeeded there is already a request in the database with this name
     
    781784
    782785    my $base = basename($image->{image});
    783     if (! $base =~ /.fits$/ ) {
     786    if (! ($base =~ /.fits$/) ) {
    784787        my_die("unexpected image file name found $image->{image}", $PS_EXIT_PROG_ERROR);
    785788    }
     
    11361139
    11371140    if (!$no_update) {
    1138         my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     1141        my ( $success, $error_msg, $full_buf, $stdout_buf, $stderr_buf ) =
    11391142            run(command => $command, verbose => $verbose);
     1143        my $error_code = &parse_error_message ($success, $error_msg, $command);
    11401144        unless ($success) {
    1141             my $fault = $error_code >> 8;
     1145            my $fault = $error_code;
    11421146            print STDERR "$command failed with fault $fault\n";
    11431147            if ($fault < $PSTAMP_FIRST_ERROR_CODE) {
     
    14211425    exit $fault;
    14221426}
     1427
     1428# if the program exited normally, the exit value is returned
     1429# if the program exited with a signal (abort, crash, etc), PS_EXIT_PROG_ERROR (4) is returned
     1430# if the program failed to run, -PS_EXIT_PROG_ERROR (-4) is returned
     1431sub parse_error_message {
     1432    my $success = shift;
     1433    my $error_msg = shift;
     1434    my $command = shift;
     1435
     1436    if ($success) { return 0; }
     1437
     1438    print "raw error_msg: $error_msg\n";
     1439    print "full command: $command\n";
     1440
     1441    if (&looks_like_number($error_msg)) { return (($error_msg >> 8) or ($PS_EXIT_PROG_ERROR)); }
     1442       
     1443    # which of these match?
     1444    my ($error_code) = $error_msg =~ m/exited with value (\d+)/;
     1445    if (defined $error_code) { return $error_code; }
     1446   
     1447    ($error_code) = $error_msg =~ m/died with signal (\d+)/;
     1448#   if (defined $error_code) { return (128 + $error_code); }
     1449    if (defined $error_code) { return ($PS_EXIT_PROG_ERROR); }
     1450   
     1451    # probably failed to execute:
     1452    return (-1*$PS_EXIT_PROG_ERROR);
     1453}
     1454
Note: See TracChangeset for help on using the changeset viewer.