- Timestamp:
- Jul 30, 2009, 5:20:29 PM (17 years ago)
- Location:
- branches/czw_branch/cleanup
- Files:
-
- 2 edited
-
. (modified) (1 prop)
-
ippScripts/scripts/magic_destreak_revert.pl (modified) (15 diffs, 1 prop)
Legend:
- Unmodified
- Added
- Removed
-
branches/czw_branch/cleanup
- Property svn:mergeinfo changed
/trunk (added) merged: 24714-24742,24744-24784,24786-24798,24801-24824,24827-24834,24836-24859,24861-24901,24903-24912,24914-24939
- Property svn:mergeinfo changed
-
branches/czw_branch/cleanup/ippScripts/scripts/magic_destreak_revert.pl
- Property svn:mergeinfo changed
/trunk/ippScripts/scripts/magic_destreak_revert.pl (added) merged: 24726,24856,24936
r24686 r24951 60 60 61 61 pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV; 62 pod2usage( -msg => "Required options: --magic_ds_id --camera --st reaks --stage --stage_id --component --uri--path_base --outroot",62 pod2usage( -msg => "Required options: --magic_ds_id --camera --stage --stage_id --component --path_base --outroot", 63 63 -exitval => 3) unless 64 64 defined $magic_ds_id and … … 70 70 defined $outroot; 71 71 72 # XXX: for testing73 $no_update = 1;74 75 72 &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)); 76 73 … … 87 84 if ($@ or not defined $nebulous) { 88 85 &my_die ("Unable to create a Nebulous::Client object with proxy $nebulousServer", $magic_ds_id, $component, $PS_EXIT_CONFIG_ERROR); 89 return undef;90 86 } 91 87 … … 99 95 } elsif ($stage eq "diff") { 100 96 $skycell_id = $component; 101 } els e{97 } elsif ($stage ne "camera") { 102 98 &my_die("Invalid value for stage: $stage", $magic_ds_id, $component, $PS_EXIT_CONFIG_ERROR); 103 99 } … … 108 104 my $basename = basename($path_base); 109 105 my $nebulousInput = inNebulous($dirname); 110 111 # parse replace arguments check for errors and set up112 # the appropriate paths113 # this program doesn't make sense if $replace is false114 &my_die("Invalid value for replace: $replace", $magic_ds_id, $component, $PS_EXIT_CONFIG_ERROR) if $replace ne "T";115 106 116 107 if (defined($replace) and ($replace eq "T")) { … … 120 111 } 121 112 122 # default value is "NULL" do not use 113 &my_die("replace not allowed for non-nebulous files", $magic_ds_id, $component, $PS_EXIT_CONFIG_ERROR) 114 if ($replace eq "T") and !$nebulousInput; 115 116 117 # default value is "NULL" do not use it 123 118 if (defined($recoveryroot) and ($recoveryroot eq "NULL")) { 124 119 $recoveryroot = undef; … … 135 130 $backup_path_base = $tmproot . "$basename"; 136 131 } else { 137 # note: t railing /is necessary132 # note: the trailing / here is necessary 138 133 $tmproot = "$outroot/"; 139 134 $backup_path_base = $tmproot . $basename; … … 147 142 148 143 149 my ($image, $mask, $ch_mask, $weight );150 my ($bimage, $bmask, $bch_mask, $bweight );144 my ($image, $mask, $ch_mask, $weight, $sources, $astrom); 145 my ($bimage, $bmask, $bch_mask, $bweight, $bsources, $bastrom); 151 146 152 147 if ($stage eq "raw") { … … 172 167 $bch_mask= $ipprc->filename("PPIMAGE.CHIP.MASK", $backup_path_base, $class_id); 173 168 $bweight = $ipprc->filename("PPIMAGE.CHIP.VARIANCE", $backup_path_base, $class_id); 169 } elsif ($stage eq "camera") { 170 $astrom = $ipprc->filename("PSASTRO.OUTPUT", $path_base); 171 $bastrom = $ipprc->filename("PSASTRO.OUTPUT", $backup_path_base); 174 172 } elsif ($stage eq "warp") { 175 173 $image = $ipprc->filename("PSWARP.OUTPUT", $path_base); 176 174 $mask = $ipprc->filename("PSWARP.OUTPUT.MASK", $path_base); 177 175 $weight = $ipprc->filename("PSWARP.OUTPUT.VARIANCE", $path_base); 176 $sources = $ipprc->filename("PSWARP.OUTPUT.SOURCES", $path_base); 178 177 $bimage = $ipprc->filename("PSWARP.OUTPUT", $backup_path_base); 179 178 $bmask = $ipprc->filename("PSWARP.OUTPUT.MASK", $backup_path_base); 180 179 $bweight = $ipprc->filename("PSWARP.OUTPUT.VARIANCE", $backup_path_base); 180 $bsources = $ipprc->filename("PSWARP.OUTPUT.SOURCES", $backup_path_base); 181 181 } elsif ($stage eq "diff") { 182 182 my $name = $inverse ? "PPSUB.INVERSE" : "PPSUB.OUTPUT"; # Base name for images … … 184 184 $mask = $ipprc->filename("$name.MASK", $path_base); 185 185 $weight = $ipprc->filename("$name.VARIANCE", $path_base); 186 $sources = $ipprc->filename("PPSUB.OUTPUT.SOURCES", $path_base); 186 187 $bimage = $ipprc->filename($name, $backup_path_base); 187 188 $bmask = $ipprc->filename("$name.MASK", $backup_path_base); 188 189 $bweight = $ipprc->filename("$name.VARIANCE", $backup_path_base); 189 } 190 191 do_swap($image, $bimage) or 190 $bsources = $ipprc->filename("PPSUB.OUTPUT.SOURCES", $backup_path_base); 191 } 192 193 if ($image) { 194 revert_file($image, $bimage) or 192 195 &my_die("failed to restore image file", $magic_ds_id, $component, $PS_EXIT_CONFIG_ERROR); 196 } 197 193 198 if ($mask) { 194 my $swap_result = do_swap($mask, $bmask); 195 if (! $swap_result) { 196 # delete next 5 lines 197 if ($stage eq "chip") { 198 # XXX: this is a kludge to get around my test environment 199 # Don't commit 200 print STDERR "failed to resotre camera mask file, proceeding\n"; 199 if (!revert_file($mask, $bmask)) { 200 if ($stage eq 'chip') { 201 # don't fail if the mask file (from the camera stage) fails to revert. 202 # It probably doesn't exist 203 # XXX: Handle this properly 204 print STDERR "failure to revert mask file, ignored\n"; 201 205 } else { 202 &my_die("failed to restore mask file", $magic_ds_id, $component, $PS_EXIT_CONFIG_ERROR); 203 } # delete this line 204 } 205 } 206 &my_die("failed to restore mask file", $magic_ds_id, $component, $PS_EXIT_CONFIG_ERROR); 207 } 208 } 209 } 210 206 211 if ($ch_mask) { 207 do_swap($ch_mask, $bch_mask) or 208 &my_die("failed to restore chip mask", $magic_ds_id, $component, $PS_EXIT_CONFIG_ERROR); 212 if (!revert_file($ch_mask, $bch_mask)) { 213 &my_die("failed to restore chip mask file", $magic_ds_id, $component, $PS_EXIT_CONFIG_ERROR); 214 } 209 215 } 216 217 210 218 if ($weight) { 211 do_swap($weight, $bweight) or219 revert_file($weight, $bweight) or 212 220 &my_die("failed to restore variance image", $magic_ds_id, $component, $PS_EXIT_CONFIG_ERROR); 213 221 } 214 222 215 # now reverse the desreaked file 216 # Change magicdstool to set the magicked value to zero 217 # Actually we should probably do this first to insure that no data gets deleted 218 # Input result into database 219 if (0) { 220 # XXX: this is the wrong mode 221 my $command = "$magicdstool -adddestreakedfile"; 223 if ($sources) { 224 revert_file($sources, $bsources) or 225 &my_die("failed to restore sources file", $magic_ds_id, $component, $PS_EXIT_CONFIG_ERROR); 226 } 227 228 if ($astrom) { 229 revert_file($astrom, $bastrom) or 230 &my_die("failed to restore astrometry file", $magic_ds_id, $component, $PS_EXIT_CONFIG_ERROR); 231 } 232 233 # now revert the row in the database 234 { 235 my $command = "$magicdstool -revertdestreakedfile"; 222 236 $command .= " -magic_ds_id $magic_ds_id"; 223 237 $command .= " -component $component"; 224 $command .= " -setmagicked" if $replace;225 $command .= " -backup_path_base $backup_path_base" if $backup_path_base;226 $command .= " -recovery_path_base $recovery_path_base" if $recovery_path_base;227 238 $command .= " -dbname $dbname" if defined $dbname; 228 239 … … 242 253 243 254 244 245 255 ### Pau. 246 256 … … 256 266 } 257 267 258 sub do_swap268 sub revert_file 259 269 { 260 270 my $original = shift; … … 297 307 if ($b_path and -e $b_path) { 298 308 print "ready to delete backup\n" if $verbose; 299 if (! $ nebulous->delete($backup)) {309 if (! $ipprc->file_delete($backup)) { 300 310 print "failed to delete $backup\n"; 301 311 return 0; … … 307 317 # delete the 'backup' (destreaked target) file if it exists 308 318 if ($b_path and -e $b_path) { 309 if (! $ nebulous->delete($backup)) {319 if (! $ipprc->file_delete($backup)) { 310 320 print "failed to delete $backup\n"; 311 321 return 0; … … 348 358 $exit_code = $PS_EXIT_PROG_ERROR unless defined $exit_code; 349 359 350 my $command = "$magicdstool -adddestreakedfile"; 351 $command .= " -magic_ds_id $magic_ds_id"; 352 $command .= " -component $component"; 353 $command .= " -fault $exit_code"; 354 $command .= " -dbname $dbname" if defined $dbname; 355 356 # Add the processed file to the database 357 unless ($no_update) { 358 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 359 run(command => $command, verbose => $verbose); 360 unless ($success) { 361 carp("failed to update database for $magic_ds_id $component"); 362 } 363 } else { 364 print "Skipping command: $command\n"; 365 } 360 # we wouldn't be here unless an entry already exists in the database 361 # my $command = "$magicdstool -adddestreakedfile"; 362 # $command .= " -magic_ds_id $magic_ds_id"; 363 # $command .= " -component $component"; 364 # $command .= " -fault $exit_code"; 365 # $command .= " -dbname $dbname" if defined $dbname; 366 367 # # Add the processed file to the database 368 # unless ($no_update) { 369 # my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 370 # run(command => $command, verbose => $verbose); 371 # unless ($success) { 372 # carp("failed to update database for $magic_ds_id $component"); 373 # } 374 # } else { 375 # print "Skipping command: $command\n"; 376 # } 366 377 367 378 carp($msg); - Property svn:mergeinfo changed
Note:
See TracChangeset
for help on using the changeset viewer.
