IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 27297


Ignore:
Timestamp:
Mar 16, 2010, 9:23:13 AM (16 years ago)
Author:
Paul Price
Message:

Check that output file exists.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/ipp_apply_burntool.pl

    r26497 r27297  
    11#!/usr/bin/env perl
    22# this program is used to run 'burntool' on images for a single chip
    3 # for all exposures for a given time period.   
    4 # USAGE: ipp_apply_burntool.pl --dbname gpc1 --class_id XY00 --dateobs_begin YYYY/MM/DD --dateobs_end YYYY/MM/DD 
     3# for all exposures for a given time period.
     4# USAGE: ipp_apply_burntool.pl --dbname gpc1 --class_id XY00 --dateobs_begin YYYY/MM/DD --dateobs_end YYYY/MM/DD
    55
    66# XXX todo:
    77# - add filters to processedimfile
    8 # 
     8#
    99
    1010use warnings;
     
    8282foreach my $cfg (@$recipeData) {
    8383    if ($cfg->{name} eq 'BURNTOOL.STATE.GOOD') {
    84         $burntoolStateGood = $cfg->{value};
     84        $burntoolStateGood = $cfg->{value};
    8585    }
    8686}
     
    100100$command .= " -dbname $dbname" if defined $dbname;
    101101
    102 ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 
     102( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    103103    run ( command => $command, verbose => $verbose);
    104104unless ($success) {
     
    125125    my $rawImfile = $file->{uri};
    126126    my $rawImfileReal = $ipprc->file_resolve($rawImfile, 0);
    127    
     127
    128128    my $outTable  = $file->{uri};
    129129    $outTable  =~ s/fits$/burn.tbl/;
    130130    my $outTableReal = $ipprc->file_resolve($outTable, 1);
    131    
     131
    132132    my $process = 0;
    133133    my $previousTableStyle = 0;
    134134
    135135    if ($state == 0) {
    136         $process = 1;
     136        $process = 1;
    137137    }
    138138    elsif ($state == -1) {
    139         $process = 1;
     139        $process = 1;
    140140    }
    141141    elsif ($state == -3) {
    142         $process = 1;
     142        $process = 1;
    143143    }
    144144    elsif ($state == -2) {
    145         &my_die("Aborting as $rawImfile has modified pixel data!");
     145        &my_die("Aborting as $rawImfile has modified pixel data!");
    146146    }
    147147    elsif ($state == $burntoolStateGood) {
    148         $process = 0;
    149         $previousTableStyle = 1;
     148        $process = 0;
     149        $previousTableStyle = 1;
    150150    }
    151151    elsif ($state == -1 * $burntoolStateGood) {
    152         $process = 0;
    153 #       $previousTable = "in=$outTableReal";
    154         $previousTableStyle = -1;
     152        $process = 0;
     153#       $previousTable = "in=$outTableReal";
     154        $previousTableStyle = -1;
    155155    }
    156156    else {
    157         $process = 1;
     157        $process = 1;
    158158    }
    159159    if ($REALRUN == 0) {
    160         print "##Pretending to process as instructed!\n";
    161         $process = 1;
     160        print "##Pretending to process as instructed!\n";
     161        $process = 1;
    162162    }
    163163    if (($process == 1)||($processNext == 1)) {
    164         $processNext = 1;
    165         # Set state to processing
    166         my $status = vsystem ("$regtool -dbname $dbname -updateprocessedimfile -exp_id $exp_id -class_id $class_id -burntool_state -1", $REALRUN);
    167         if ($status) {
    168             &my_die("failed to update imfile");
    169         }
    170         $file->{burntool_state} = -1;
    171        
    172         my $tempfile = new File::Temp ( TEMPLATE => "$file->{exp_name}.XXXX",
    173                                         DIR => '/tmp/',
    174                                         UNLINK => !$save_temps,
    175                                         SUFFIX => '.fits');
    176         my $tempPixels = $tempfile->filename;
    177        
    178         # Run burntool
    179         $status = vsystem ("$funpack -S $rawImfileReal > $tempPixels", $REALRUN);
    180         if ($status) {
    181             &my_die("failed on funpack",$exp_id,$class_id);
    182         }
    183         if ($previousTable ne '') {
    184             $status = vsystem ("$burntool $tempPixels $previousTable out=$outTableReal tableonly=t persist=t", $REALRUN);
    185         }
    186         else {
    187             $status = vsystem ("$burntool $tempPixels out=$outTableReal tableonly=t persist=t", $REALRUN);
    188         }
    189         if ($status) {
    190             &my_die("failed on burntool",$exp_id,$class_id);
    191         }
    192        
    193         $status = vsystem ("$nebXattr --write $outTable user.copies:2", $REALRUN);
    194         if ($status) {
    195             &my_die("failed to neb-xattr imfile", $outTable);
    196         }
    197         $status = vsystem ("$regtool -dbname $dbname -updateprocessedimfile -exp_id $exp_id -class_id $class_id -burntool_state $outState", $REALRUN);
    198         if ($status) {
    199             &my_die("failed to update imfile");
    200         }
    201 
    202         $previousTableStyle = -1;
    203        
    204         print "\n";
    205     }
    206    
     164        $processNext = 1;
     165        # Set state to processing
     166        my $status = vsystem ("$regtool -dbname $dbname -updateprocessedimfile -exp_id $exp_id -class_id $class_id -burntool_state -1", $REALRUN);
     167        if ($status) {
     168            &my_die("failed to update imfile");
     169        }
     170        $file->{burntool_state} = -1;
     171
     172        my $tempfile = new File::Temp ( TEMPLATE => "$file->{exp_name}.XXXX",
     173                                        DIR => '/tmp/',
     174                                        UNLINK => !$save_temps,
     175                                        SUFFIX => '.fits');
     176        my $tempPixels = $tempfile->filename;
     177
     178        # Run burntool
     179        $status = vsystem ("$funpack -S $rawImfileReal > $tempPixels", $REALRUN);
     180        if ($status) {
     181            &my_die("failed on funpack",$exp_id,$class_id);
     182        }
     183        if ($previousTable ne '') {
     184            $status = vsystem ("$burntool $tempPixels $previousTable out=$outTableReal tableonly=t persist=t", $REALRUN);
     185        }
     186        else {
     187            $status = vsystem ("$burntool $tempPixels out=$outTableReal tableonly=t persist=t", $REALRUN);
     188        }
     189        if ($status) {
     190            &my_die("failed on burntool",$exp_id,$class_id);
     191        }
     192        &my_die("Unable to find output file: $outTableReal", $exp_id, $class_id) unless $ipprc->file_exists($outTableReal);
     193
     194        $status = vsystem ("$nebXattr --write $outTable user.copies:2", $REALRUN);
     195        if ($status) {
     196            &my_die("failed to neb-xattr imfile", $outTable);
     197        }
     198        $status = vsystem ("$regtool -dbname $dbname -updateprocessedimfile -exp_id $exp_id -class_id $class_id -burntool_state $outState", $REALRUN);
     199        if ($status) {
     200            &my_die("failed to update imfile");
     201        }
     202
     203        $previousTableStyle = -1;
     204
     205        print "\n";
     206    }
     207
    207208    if ($previousTableStyle == 1) {
    208         $previousTable = "infits=$rawImfileReal";
     209        $previousTable = "infits=$rawImfileReal";
    209210    }
    210211    elsif ($previousTableStyle == -1) {
    211         $previousTable = "in=$outTableReal";
     212        $previousTable = "in=$outTableReal";
    212213    }
    213214    else {
    214         die "previousTableStyle undefined!\n";
    215     }
    216    
    217 }
    218    
     215        die "previousTableStyle undefined!\n";
     216    }
     217
     218}
     219
    219220exit 0;
    220221
     
    224225
    225226    print "$command\n";
    226    
     227
    227228    my $status = 0;
    228229    if ($realrun) {
    229         $status = system ($command);
     230        $status = system ($command);
    230231    }
    231232
     
    236237    my $message = shift;
    237238    if ($#_ != -1) {
    238         my $exp_id = shift;
    239         my $class_id = shift;
    240         vsystem("$regtool -dbname $dbname -updateprocessedimfile -exp_id $exp_id -class_id $class_id -burntool_state -3",1);
     239        my $exp_id = shift;
     240        my $class_id = shift;
     241        vsystem("$regtool -dbname $dbname -updateprocessedimfile -exp_id $exp_id -class_id $class_id -burntool_state -3",1);
    241242    }
    242243    printf STDERR "$message\n";
Note: See TracChangeset for help on using the changeset viewer.