IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Mar 6, 2011, 2:34:55 PM (15 years ago)
Author:
eugene
Message:

updates from trunk

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20110213/ippScripts/scripts/magic_destreak_revert.pl

    r30700 r30812  
    7878    defined $outroot;
    7979
    80 &my_die("bytes and md5sum are is required for raw stage stage", $magic_ds_id, $component, $PS_EXIT_CONFIG_ERROR) if ($stage eq 'raw' and (!$bytes or !$md5sum));
     80if (defined($replace) and ($replace eq "T")) {
     81    $replace = 1;
     82} else {
     83    $replace = 0;
     84}
     85
     86my $ipprc = PS::IPP::Config->new( $camera ) or my_die( "Unable to set up", $magic_ds_id, $component, $PS_EXIT_CONFIG_ERROR ); # IPP configuration
     87
     88$ipprc->redirect_output($logfile) or my_die( "Unable to redirect output", $magic_ds_id, $component, $PS_EXIT_SYS_ERROR ) if $logfile;
     89
     90&my_die("bytes and md5sum are is required for raw stage stage", $magic_ds_id, $component, $PS_EXIT_CONFIG_ERROR) if ($replace and $stage eq 'raw' and (!$bytes or !$md5sum));
    8191
    8292&my_die("cam_path_base is required for chip stage", $magic_ds_id, $component, $PS_EXIT_CONFIG_ERROR) if ($stage eq 'chip' and !$cam_path_base);
     
    8494
    8595
    86 my $ipprc = PS::IPP::Config->new( $camera ) or my_die( "Unable to set up", $magic_ds_id, $component, $PS_EXIT_CONFIG_ERROR ); # IPP configuration
    87 
    88 $ipprc->redirect_output($logfile) or my_die( "Unable to redirect output", $magic_ds_id, $component, $PS_EXIT_SYS_ERROR ) if $logfile;
    8996
    9097$cam_reduction = 'DEFAULT' if !defined $cam_reduction or ($cam_reduction eq "NULL");
     
    118125my $basename = basename($path_base);
    119126my $nebulousInput = inNebulous($dirname);
    120 
    121 if (defined($replace) and ($replace eq "T")) {
    122     $replace = 1;
    123 } else {
    124     $replace = 0;
    125 }
    126127
    127128&my_die("replace not allowed for non-nebulous files", $magic_ds_id, $component, $PS_EXIT_CONFIG_ERROR)
     
    162163        $image = $path_base . ".fits";
    163164    }
    164     $bimage = $backup_path_base . ".fits";
     165    if ($backup_path_base =~ /.*\.fits$/) {
     166        $bimage = $backup_path_base;
     167    } else {
     168        $bimage = $backup_path_base . ".fits";
     169    }
    165170} elsif ($stage eq "chip") {
    166171    # Check to see if we're using dynamic masks
     
    302307sub revert_files {
    303308    my $replace = shift;
    304     return if !$replace;
     309#    return if !$replace;
    305310
    306311    my $image = shift;
     
    316321
    317322    if ($image) {
    318         revert_file($image, $bimage) or
     323        revert_file($replace, $image, $bimage) or
    319324            &my_die("failed to restore image file", $magic_ds_id, $component, $PS_EXIT_CONFIG_ERROR);
    320325    }
    321326
    322327    if ($mask) {
    323         if (!revert_file($mask, $bmask)) {
     328        if (!revert_file($replace, $mask, $bmask)) {
    324329            &my_die("failed to restore mask file", $magic_ds_id, $component, $PS_EXIT_CONFIG_ERROR);
    325330        }
     
    327332
    328333    if ($ch_mask) {
    329         if (!revert_file($ch_mask, $bch_mask)) {
     334        if (!revert_file($replace, $ch_mask, $bch_mask)) {
    330335            &my_die("failed to restore chip mask file", $magic_ds_id, $component, $PS_EXIT_CONFIG_ERROR);
    331336        }
     
    334339
    335340    if ($weight) {
    336         revert_file($weight, $bweight) or
     341        revert_file($replace, $weight, $bweight) or
    337342            &my_die("failed to restore variance image", $magic_ds_id, $component, $PS_EXIT_CONFIG_ERROR);
    338343    }
    339344
    340345    if ($sources) {
    341         revert_file($sources, $bsources) or
     346        revert_file($replace, $sources, $bsources) or
    342347            &my_die("failed to restore sources file", $magic_ds_id, $component, $PS_EXIT_CONFIG_ERROR);
    343348    }
    344349
    345350    if ($astrom) {
    346         revert_file($astrom, $bastrom) or
     351        revert_file($replace, $astrom, $bastrom) or
    347352            &my_die("failed to restore astrometry file", $magic_ds_id, $component, $PS_EXIT_CONFIG_ERROR);
    348353    }
     
    366371sub revert_file
    367372{
     373    my $replace = shift;
    368374    my $original = shift;
    369375    my $backup   = shift;
    370376    my $force = 1; # force deletion of backup files in nebulous
     377
     378    if (!$replace) {
     379        # we don't need to do all of this checking unless the destreak run is
     380        # replace mode just delete the backup
     381        my $error_code = $ipprc->kill_file($backup);
     382        if ($error_code) {
     383            print STDERR "failed to kill $backup: error_code $error_code\n";
     384            return 0;
     385        } else {
     386            return 1;
     387        }
     388    }
    371389
    372390    my $o_path = $ipprc->file_resolve($original);
Note: See TracChangeset for help on using the changeset viewer.