IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jan 21, 2009, 10:47:12 AM (17 years ago)
Author:
Paul Price
Message:

Ensure temporary files are deleted even on success. Not sure why this is necessary.

File:
1 edited

Legend:

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

    r21015 r21145  
    241241        &my_die("Couldn't find expected output file: $outputStats", $stack_id, $PS_EXIT_SYS_ERROR) unless -f $outputStatsReal;
    242242
    243         # measure chip stats
     243        # measure stats
    244244        $command = "$ppStatsFromMetadata $outputStatsReal - STACK_SKYCELL";
    245245        ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     
    255255    }
    256256}
     257
     258delete_temps() unless ($save_temps);
    257259
    258260unless ($no_update) {
     
    285287
    286288
     289
    287290sub my_die
    288291{
     
    293296    carp($msg);
    294297
    295     unless ($save_temps) {
    296         print "Ensuring temporary images are deleted.\n";
    297         delete_temps();
    298     }
     298    delete_temps() unless ($save_temps);
    299299
    300300    if (defined $stack_id and not $no_update) {
     
    317317sub delete_temps
    318318{
     319    print "Ensuring temporary images are deleted.\n";
    319320    my $command = "$ppConfigDump -camera $camera -recipe PPSTACK $recipe_ppStack -dump-recipe PPSTACK -";
    320321    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    321         run(command => $command, verbose => $verbose);
     322        run(command => $command, verbose => $verbose);
    322323    unless ($success) {
    323         $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    324         &my_die("Unable to perform ppConfigDump: $error_code", $stack_id, $error_code);
     324        $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     325        &my_die("Unable to perform ppConfigDump: $error_code", $stack_id, $error_code);
    325326    }
    326327    my $md = $mdcParser->parse(join "", @$stdout_buf) or
    327         &my_die("Unable to parse metadata config doc", $stack_id, $PS_EXIT_PROG_ERROR);
     328        &my_die("Unable to parse metadata config doc", $stack_id, $PS_EXIT_PROG_ERROR);
    328329
    329330    my $temp_delete = metadataLookupBool($md, 'TEMP.DELETE'); # Delete temporary files?
    330331    if ($temp_delete) {
    331         my $temp_dir = metadataLookupStr($md, 'TEMP.DIR'); # Directory with temporary files
    332         my $temp_image = metadataLookupStr($md, 'TEMP.IMAGE'); # Suffix for image
    333         my $temp_mask = metadataLookupStr($md, 'TEMP.MASK'); # Suffix for mask
    334         my $temp_weight = metadataLookupStr($md, 'TEMP.WEIGHT'); # Suffix for weight
    335         my $temp_root = basename($outroot); # Root name for temporary files
    336 
    337         if (not defined $temp_dir or not defined $temp_image or not defined $temp_mask or
    338             not defined $temp_weight) {
    339             &my_die("Unable to find details for temporary images.", $stack_id, $PS_EXIT_CONFIG_ERROR);
    340         }
    341 
    342         for (my $i = 0; $i < $num; $i++) {
    343             foreach my $ext ( $temp_image, $temp_mask, $temp_weight ) {
    344                 my $file = $temp_dir . '/' . $temp_root . '.' . $i . '.' . $ext;
    345                 unlink $file if -e $file;
    346             }
    347         }
     332        my $temp_dir = metadataLookupStr($md, 'TEMP.DIR'); # Directory with temporary files
     333        my $temp_image = metadataLookupStr($md, 'TEMP.IMAGE'); # Suffix for image
     334        my $temp_mask = metadataLookupStr($md, 'TEMP.MASK'); # Suffix for mask
     335        my $temp_weight = metadataLookupStr($md, 'TEMP.WEIGHT'); # Suffix for weight
     336        my $temp_root = basename($outroot); # Root name for temporary files
     337
     338        if (not defined $temp_dir or not defined $temp_image or not defined $temp_mask or
     339            not defined $temp_weight) {
     340            &my_die("Unable to find details for temporary images.", $stack_id, $PS_EXIT_CONFIG_ERROR);
     341        }
     342
     343        for (my $i = 0; $i < $num; $i++) {
     344            foreach my $ext ( $temp_image, $temp_mask, $temp_weight ) {
     345                my $file = $temp_dir . '/' . $temp_root . '.' . $i . '.' . $ext;
     346                unlink $file if -e $file;
     347            }
     348        }
    348349    }
    349350}
Note: See TracChangeset for help on using the changeset viewer.