IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 28141


Ignore:
Timestamp:
May 27, 2010, 11:22:52 AM (16 years ago)
Author:
watersc1
Message:

Should now set the state to error_* when an error occurs.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ippScripts/scripts/lossy_compress_imfile.pl

    r27718 r28141  
    6161    defined $state;
    6262
    63 my $ipprc = PS::IPP::Config->new() or my_die( "Unable to set up", $exp_id, $exp_name, $class_id, $uri, $PS_EXIT_CONFIG_ERROR );
     63my $ipprc = PS::IPP::Config->new() or my_die( "Unable to set up", $exp_id, $exp_name, $class_id, $uri, $state, $PS_EXIT_CONFIG_ERROR );
    6464if (defined($logfile)) {
    65     $ipprc->redirect_output($logfile) or my_die( "Unable to redirect output", $exp_id, $exp_name, $class_id, $uri, $PS_EXIT_SYS_ERROR );
     65    $ipprc->redirect_output($logfile) or my_die( "Unable to redirect output", $exp_id, $exp_name, $class_id, $uri, $state, $PS_EXIT_SYS_ERROR );
    6666}
    6767
     
    8787if ($state eq 'goto_compressed') {
    8888    # Find the actual filename for this run:
    89     &my_die("Couldn't find input file: $uri\n", $exp_id,$exp_name,$class_id,$uri,$PS_EXIT_SYS_ERROR)
     89    &my_die("Couldn't find input file: $uri\n", $exp_id,$exp_name,$class_id,$uri,$state,$PS_EXIT_SYS_ERROR)
    9090        unless ($ipprc->file_exists($uri));
    9191    my $uriReal = $ipprc->file_resolve( $uri );
     
    9393    # Create a compressed version:
    9494    my $compUri = $uri . ".fz";
    95     &my_die("Output compressed file already exists: $compUri\n", $exp_id,$exp_name,$class_id,$uri,$PS_EXIT_SYS_ERROR)
     95    &my_die("Output compressed file already exists: $compUri\n", $exp_id,$exp_name,$class_id,$uri,$state,$PS_EXIT_SYS_ERROR)
    9696        if ($ipprc->file_exists($compUri));
    9797    my $compReal= $ipprc->file_resolve( $compUri, 'create');
     
    109109        $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    110110        &my_die("Unable to uncompress file: $uri -> $compUri: $error_code",
    111                 $exp_id,$exp_name,$class_id,$uri, $PS_EXIT_SYS_ERROR);
     111                $exp_id,$exp_name,$class_id,$uri, $state, $PS_EXIT_SYS_ERROR);
    112112    }
    113113    my $compress_command = "$fpack -h -s 8 -S $tempReal >  $compReal";
     
    118118        $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    119119        &my_die("Unable to compress file: $uri -> $compUri: $error_code",
    120                 $exp_id,$exp_name,$class_id,$uri, $PS_EXIT_SYS_ERROR);
     120                $exp_id,$exp_name,$class_id,$uri, $state, $PS_EXIT_SYS_ERROR);
    121121    }
    122122    my $database_command = "$regtool -updateprocessedimfile -exp_id $exp_id -class_id $class_id -set_state compressed";
    123123    $database_command .= " -dbname $dbname" if defined $dbname;
    124124
    125     &my_die("Expected output compressed file not found: $compUri\n", $exp_id,$exp_name,$class_id, $uri,$PS_EXIT_SYS_ERROR)
     125    &my_die("Expected output compressed file not found: $compUri\n", $exp_id,$exp_name,$class_id, $uri,$state, $PS_EXIT_SYS_ERROR)
    126126        unless ($ipprc->file_exists($compUri));
    127127
     
    135135            $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    136136            &my_die("Unable to update database file: $uri -> $compUri: $error_code",
    137                     $exp_id,$exp_name,$class_id,$uri, $PS_EXIT_SYS_ERROR);
     137                    $exp_id,$exp_name,$class_id,$uri, $state, $PS_EXIT_SYS_ERROR);
    138138        }
    139139    }
     
    149149if ($state eq 'goto_lossy') {
    150150    # Confirm we have both files
    151     &my_die("Couldn't find original file: $uri\n", $exp_id,$exp_name,$class_id,$uri,$PS_EXIT_SYS_ERROR)
     151    &my_die("Couldn't find original file: $uri\n", $exp_id,$exp_name,$class_id,$uri,$state,$PS_EXIT_SYS_ERROR)
    152152        unless($ipprc->file_exists($uri));
    153153    my $uriReal = $ipprc->file_resolve( $uri );
     
    156156    unless($ipprc->file_exists($compUri)) {
    157157        &my_die("Couldn't find compressed version of the file: $compUri\n",
    158                 $exp_id,$exp_name,$class_id,$uri,$PS_EXIT_SYS_ERROR);
     158                $exp_id,$exp_name,$class_id,$uri,$state,$PS_EXIT_SYS_ERROR);
    159159
    160160        # If that die is removed, this will compress things as well.
     
    185185        $neb->swap($uri,$compUri) or
    186186            &my_die("Nebulous swap failed between $uri and $compUri",
    187                     $exp_id,$exp_name,$class_id,$uri,$PS_EXIT_SYS_ERROR);
     187                    $exp_id,$exp_name,$class_id,$uri,$state,$PS_EXIT_SYS_ERROR);
    188188    }
    189189    # Update database
     
    204204            $neb->swap($uri,$compUri) or
    205205                &my_die("DB update failed and Nebulous swap-back failed between $uri and $compUri",
    206                         $exp_id,$exp_name,$class_id,$uri,$PS_EXIT_SYS_ERROR);
     206                        $exp_id,$exp_name,$class_id,$uri,$state,$PS_EXIT_SYS_ERROR);
    207207            &my_die("Unable to update database file: $uri -> $compUri: $error_code",
    208                     $exp_id,$exp_name,$class_id,$uri, $PS_EXIT_SYS_ERROR);
     208                    $exp_id,$exp_name,$class_id,$uri, $state,$PS_EXIT_SYS_ERROR);
    209209        }
    210210        # remove original version
     
    224224    my $class_id = shift; # Class identifier
    225225    my $uri = shift; # uri for the file
     226    my $state = shift;
    226227    my $exit_code = shift; # Exit code
    227228    # outputImage and path_base are globals
     229    my $fail_state = $state;
     230    $fail_state =~ s/goto_/error_/;
     231    my $error_command = "$regtool -updateprocessedimfile -exp_id $exp_id -class_id $class_id -set_state $fail_state ";
     232    $error_command .= " -dbname $dbname" if defined $dbname;
     233    my ($success, $error_code, $full_buf, $stdout_buf, $stderr_buf) =
     234        run(command => $error_command, verbose => $verbose);
     235    unless($success) {
     236        warn("Failed at setting the error state too.");
     237    }
    228238
    229239    $exit_code = $PS_EXIT_PROG_ERROR unless defined $exit_code;
Note: See TracChangeset for help on using the changeset viewer.