- Timestamp:
- Mar 6, 2011, 2:34:55 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20110213/ippScripts/scripts/magic_destreak_revert.pl
r30700 r30812 78 78 defined $outroot; 79 79 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)); 80 if (defined($replace) and ($replace eq "T")) { 81 $replace = 1; 82 } else { 83 $replace = 0; 84 } 85 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; 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)); 81 91 82 92 &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); … … 84 94 85 95 86 my $ipprc = PS::IPP::Config->new( $camera ) or my_die( "Unable to set up", $magic_ds_id, $component, $PS_EXIT_CONFIG_ERROR ); # IPP configuration87 88 $ipprc->redirect_output($logfile) or my_die( "Unable to redirect output", $magic_ds_id, $component, $PS_EXIT_SYS_ERROR ) if $logfile;89 96 90 97 $cam_reduction = 'DEFAULT' if !defined $cam_reduction or ($cam_reduction eq "NULL"); … … 118 125 my $basename = basename($path_base); 119 126 my $nebulousInput = inNebulous($dirname); 120 121 if (defined($replace) and ($replace eq "T")) {122 $replace = 1;123 } else {124 $replace = 0;125 }126 127 127 128 &my_die("replace not allowed for non-nebulous files", $magic_ds_id, $component, $PS_EXIT_CONFIG_ERROR) … … 162 163 $image = $path_base . ".fits"; 163 164 } 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 } 165 170 } elsif ($stage eq "chip") { 166 171 # Check to see if we're using dynamic masks … … 302 307 sub revert_files { 303 308 my $replace = shift; 304 return if !$replace;309 # return if !$replace; 305 310 306 311 my $image = shift; … … 316 321 317 322 if ($image) { 318 revert_file($ image, $bimage) or323 revert_file($replace, $image, $bimage) or 319 324 &my_die("failed to restore image file", $magic_ds_id, $component, $PS_EXIT_CONFIG_ERROR); 320 325 } 321 326 322 327 if ($mask) { 323 if (!revert_file($ mask, $bmask)) {328 if (!revert_file($replace, $mask, $bmask)) { 324 329 &my_die("failed to restore mask file", $magic_ds_id, $component, $PS_EXIT_CONFIG_ERROR); 325 330 } … … 327 332 328 333 if ($ch_mask) { 329 if (!revert_file($ ch_mask, $bch_mask)) {334 if (!revert_file($replace, $ch_mask, $bch_mask)) { 330 335 &my_die("failed to restore chip mask file", $magic_ds_id, $component, $PS_EXIT_CONFIG_ERROR); 331 336 } … … 334 339 335 340 if ($weight) { 336 revert_file($ weight, $bweight) or341 revert_file($replace, $weight, $bweight) or 337 342 &my_die("failed to restore variance image", $magic_ds_id, $component, $PS_EXIT_CONFIG_ERROR); 338 343 } 339 344 340 345 if ($sources) { 341 revert_file($ sources, $bsources) or346 revert_file($replace, $sources, $bsources) or 342 347 &my_die("failed to restore sources file", $magic_ds_id, $component, $PS_EXIT_CONFIG_ERROR); 343 348 } 344 349 345 350 if ($astrom) { 346 revert_file($ astrom, $bastrom) or351 revert_file($replace, $astrom, $bastrom) or 347 352 &my_die("failed to restore astrometry file", $magic_ds_id, $component, $PS_EXIT_CONFIG_ERROR); 348 353 } … … 366 371 sub revert_file 367 372 { 373 my $replace = shift; 368 374 my $original = shift; 369 375 my $backup = shift; 370 376 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 } 371 389 372 390 my $o_path = $ipprc->file_resolve($original);
Note:
See TracChangeset
for help on using the changeset viewer.
