IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jul 8, 2009, 6:19:50 PM (17 years ago)
Author:
bills
Message:

updates to magic destreak processing

File:
1 edited

Legend:

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

    r24686 r24726  
    7070    defined $outroot;
    7171
    72 # XXX: for testing
    73 $no_update = 1;
    74 
    7572&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));
    7673
     
    8784if ($@ or not defined $nebulous) {
    8885    &my_die ("Unable to create a Nebulous::Client object with proxy $nebulousServer", $magic_ds_id, $component, $PS_EXIT_CONFIG_ERROR);
    89     return undef;
    9086}
    9187
     
    109105my $nebulousInput = inNebulous($dirname);
    110106
    111 # parse replace arguments check for errors and set up
    112 # the appropriate paths
    113 # this program doesn't make sense if $replace is false
    114 &my_die("Invalid value for replace: $replace", $magic_ds_id, $component, $PS_EXIT_CONFIG_ERROR) if $replace ne "T";
    115 
    116107if (defined($replace) and ($replace eq "T")) {
    117108    $replace = 1;
     
    120111}
    121112
    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
    123118if (defined($recoveryroot) and ($recoveryroot eq "NULL")) {
    124119    $recoveryroot = undef;
     
    135130    $backup_path_base = $tmproot . "$basename";
    136131} else {
    137     # note: trailing / is necessary
     132    # note: the trailing / here is necessary
    138133    $tmproot = "$outroot/";
    139134    $backup_path_base = $tmproot . $basename;
     
    189184}
    190185
    191 do_swap($image, $bimage) or
     186revert_file($image, $bimage) or
    192187        &my_die("failed to restore image file", $magic_ds_id, $component, $PS_EXIT_CONFIG_ERROR);
     188
     189# don't commit next the next couple of lines and see xxx below
     190# change to if 0 to revert chip runs without masks
     191if (0) {
     192
    193193if ($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";
     194    if (!revert_file($mask, $bmask)) {
     195        if ($stage eq 'chip') {
     196            # XXX: don't fail if the mask file fails to revert. It probably doesn't exist
     197            # Handle this properly
     198            print STDERR "failure to revert mask file, ignored\n";
    201199        } else {
    202         &my_die("failed to restore mask file", $magic_ds_id, $component, $PS_EXIT_CONFIG_ERROR);
    203         }  # delete this line
    204     }
    205 }
     200            &my_die("failed to restore mask file", $magic_ds_id, $component, $PS_EXIT_CONFIG_ERROR);
     201        }
     202    }
     203}
     204
    206205if ($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);
     206    # Handle this properly
     207    if (!revert_file($ch_mask, $bch_mask)) {
     208        # print STDERR "failure to revert chip mask file, ignored\n";
     209        &my_die("failed to restore chip mask file", $magic_ds_id, $component, $PS_EXIT_CONFIG_ERROR);
     210    }
    209211}
     212
     213# xxx don't commmit next line
     214}
     215
    210216if ($weight) {
    211     do_swap($weight, $bweight) or
     217    revert_file($weight, $bweight) or
    212218        &my_die("failed to restore variance image", $magic_ds_id, $component, $PS_EXIT_CONFIG_ERROR);
    213219}
    214220
    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";
     221# now revert the row in the database
     222{
     223    my $command = "$magicdstool -revertdestreakedfile";
    222224    $command   .= " -magic_ds_id $magic_ds_id";
    223225    $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;
    227226    $command   .= " -dbname $dbname" if defined $dbname;
    228227
     
    242241
    243242
    244 
    245243### Pau.
    246244
     
    256254}
    257255
    258 sub do_swap
     256sub revert_file
    259257{
    260258    my $original = shift;
     
    297295        if ($b_path and -e $b_path) {
    298296            print "ready to delete backup\n" if $verbose;
    299             if (! $nebulous->delete($backup)) {
     297            if (! $ipprc->file_delete($backup)) {
    300298                print "failed to delete $backup\n";
    301299                return 0;
     
    307305        # delete the 'backup' (destreaked target) file if it exists
    308306        if ($b_path and -e $b_path) {
    309             if (! $nebulous->delete($backup)) {
     307            if (! $ipprc->file_delete($backup)) {
    310308                print "failed to delete $backup\n";
    311309                return 0;
     
    348346    $exit_code = $PS_EXIT_PROG_ERROR unless defined $exit_code;
    349347
    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     }
     348    # we wouldn't be here unless an entry already exists in the database
     349#    my $command = "$magicdstool -adddestreakedfile";
     350#    $command   .= " -magic_ds_id $magic_ds_id";
     351#    $command   .= " -component $component";
     352#    $command   .= " -fault $exit_code";
     353#    $command   .= " -dbname $dbname" if defined $dbname;
     354
     355#    # Add the processed file to the database
     356#    unless ($no_update) {
     357#        my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     358#            run(command => $command, verbose => $verbose);
     359#        unless ($success) {
     360#            carp("failed to update database for $magic_ds_id $component");
     361#        }
     362#    } else {
     363#        print "Skipping command: $command\n";
     364#    }
    366365
    367366    carp($msg);
Note: See TracChangeset for help on using the changeset viewer.