IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Oct 18, 2009, 10:23:28 AM (17 years ago)
Author:
eugene
Message:

updated vysos branch from trunk

Location:
branches/eam_branches/20090820
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/20090820

  • branches/eam_branches/20090820/ippScripts/scripts/ipp_cleanup.pl

    r25766 r25870  
    9191
    9292    # if there are no chipProcessedImfiles (@$stdout_buf == 0), the reset the state to 'new'
     93    # XXX Why? This could just mean there's nothing to cleanup, or that we're trying to rerun an errored run.
    9394    if (@$stdout_buf == 0)  {
    94         my $command = "$chiptool -chip_id $stage_id -updaterun -set_state new";
     95        my $command = "$chiptool -chip_id $stage_id -updaterun -set_state $error_state";
    9596        $command .= " -dbname $dbname" if defined $dbname;
    9697
     
    123124            my $config_file = $ipprc->filename("PPIMAGE.CONFIG", $path_base, $class_id);
    124125
    125 #            if (!$config_file or ! -e $config_file) {
    126126            unless ($ipprc->file_exists($config_file)) {
    127127                print STDERR "skipping cleanup for chipRun $stage_id $class_id "
     
    187187                &my_die("Unable to perform chiptool: $error_code", "chip", $stage_id, $error_code);
    188188            }
     189
     190            # Tell magicdstool that we've cleaned up this data, so it needs to do the same if it needs to do the same.
     191            my $magicdstool = can_run('magicdstool') or die "Can't find magicdstool";
     192            $command = "$magicdstool -dbname gpc1  -stage $stage -stage_id $stage_id -updaterun -set_state goto_cleaned";
     193            ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     194                run(command => $command, verbose => $verbose);
     195            unless ($success) {
     196                $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     197                &my_die("Unable to perform magicdstool: $error_code", "$stage", $stage_id, $error_code);
     198            }
     199
    189200        } else {
    190201
     
    199210                &my_die("Unable to perform chiptool: $error_code", "chip", $stage_id, $error_code);
    200211            }
     212           
     213            # We want to flag the run as well, to avoid attempting to reprocess the same data over and over again.
     214            $command = "$chiptool -chip_id $stage_id -updaterun -set_state $error_state";
     215            $command .= " -dbname $dbname" if defined $dbname;
     216
     217            ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     218                run(command => $command, verbose => $verbose);
     219            unless ($success) {
     220                $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     221                &my_die("Unable to perform chiptool: $error_code", "chip", $stage_id, $error_code);
     222            }
     223
    201224        }
    202225    }
     
    283306            &my_die("Unable to perform camtool: $error_code", "camera", $stage_id, $error_code);
    284307        }
     308
     309        # Tell magicdstool that we've cleaned up this data, so it needs to do the same if it needs to do the same.
     310        my $magicdstool = can_run('magicdstool') or die "Can't find magicdstool";
     311        $command = "$magicdstool -dbname gpc1 -stage $stage -stage_id $stage_id -updaterun -set_state goto_cleaned";
     312        ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     313            run(command => $command, verbose => $verbose);
     314        unless ($success) {
     315            $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     316            &my_die("Unable to perform magicdstool: $error_code", "$stage", $stage_id, $error_code);
     317        }
     318
    285319    } else {
    286320        # since 'camera' has only a single imfile, we can just update the run
     
    296330        exit $PS_EXIT_UNKNOWN_ERROR;
    297331    }
     332
     333
    298334    exit 0;
    299335}
     
    314350        $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    315351        &my_die("Unable to perform warptool: $error_code", "warp", $stage_id, $error_code);
     352    }
     353   
     354    if (@$stdout_buf == 0) {
     355        # No skycells were found for some reason.
     356        # Not technically an "error," but a "you told me to do X, and I can't. Please fix this yourself."
     357        my $command = "$warptool -updaterun -warp_id $stage_id -set_state $error_state";
     358        $command .= " -dbname $dbname" if defined $dbname;
     359       
     360        my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     361            run(command => $command, verbose => $verbose);
     362        unless ($success) {
     363            $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     364            &my_die("Unable to perform warptool: $error_code", "warp", $stage_id, $error_code);
     365        }
     366       
     367        exit(0);
    316368    }
    317369    my $metadata = $mdcParser->parse(join "", @$stdout_buf) or
     
    389441                &my_die("Unable to perform warptool: $error_code", "warp", $stage_id, $error_code);
    390442            }
     443
     444            # Tell magicdstool that we've cleaned up this data, so it needs to do the same if it needs to do the same.
     445            my $magicdstool = can_run('magicdstool') or die "Can't find magicdstool";
     446            $command = "$magicdstool -dbname gpc1 -stage $stage -stage_id $stage_id -updaterun -set_state goto_cleaned";
     447            ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     448                run(command => $command, verbose => $verbose);
     449            unless ($success) {
     450                $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     451                &my_die("Unable to perform magicdstool: $error_code", "$stage", $stage_id, $error_code);
     452            }
     453
    391454         } else {
    392455            my $command = "$warptool -updateskyfile -warp_id $stage_id -skycell_id $skycell_id -set_state $error_state";
     
    399462                &my_die("Unable to perform warptool: $error_code", "warp", $stage_id, $error_code);
    400463            }
    401             exit $PS_EXIT_UNKNOWN_ERROR;
     464
     465            #            exit $PS_EXIT_UNKNOWN_ERROR;
    402466        }
    403467    }
     
    407471### added for cleanup, based on warp stage entry
    408472if ($stage eq 'stack') {
    409    
    410473    die "--stage_id required for stage stack\n" if !$stage_id;
    411 
    412474    # this stage uses 'stacktool'
    413475    my $stacktool = can_run('stacktool') or die "Can't find stacktool";
     
    422484        &my_die("Unable to perform stacktool: $error_code", "stack", $stage_id, $error_code);
    423485    }
     486
     487    if (@$stdout_buf == 0) {
     488        # No skycells were found for some reason.
     489        # Not technically an "error," but a "you told me to do X, and I can't. Please fix this yourself."
     490        my $command = "$stacktool -updaterun -stack_id $stage_id -set_state $error_state";
     491        $command .= " -dbname $dbname" if defined $dbname;
     492       
     493        my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     494            run(command => $command, verbose => $verbose);
     495        unless ($success) {
     496            $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     497            &my_die("Unable to perform stacktool: $error_code", "stack", $stage_id, $error_code);
     498        }
     499       
     500        exit(0);
     501    }
     502
    424503    my $metadata = $mdcParser->parse(join "", @{ $stdout_buf }) or
    425504        &my_die("Unable to parse metadata config doc", "stack", $stage_id, $PS_EXIT_PROG_ERROR);
     
    434513
    435514        my $status = 1;
    436         if ($mode eq "goto_cleaned") {
    437             my $config_file = $ipprc->filename("PPSTACK.CONFIG", $path_base, $skycell_id);
    438 
    439             unless ($ipprc->file_exists($config_file)) {
    440                 print STDERR "skipping cleanup for stackRun $stage_id $skycell_id" .
    441                     " because config file is missing\n";
    442                 $status = 0;
    443             }
    444         }
    445         elsif ($mode eq "goto_scrubbed") {
    446             my $config_file = $ipprc->filename("PPSTACK.CONFIG", $path_base, $skycell_id);
    447 
    448             if ($ipprc->file_exists($config_file)) {
    449                 print STDERR "skipping scrubbed for stackRun $stage_id $skycell_id" .
    450                     " because config file is present\n";
    451                 $status = 0;
    452             }
    453         }
     515        if ((!exists($skyfile->{path_base}))||
     516            (!defined($path_base))) {
     517            $status = 0;
     518        }
     519        if ($status) {
     520            if ($mode eq "goto_cleaned") {
     521                my $config_file = $ipprc->filename("PPSTACK.CONFIG", $path_base, $skycell_id);
     522               
     523                unless ($ipprc->file_exists($config_file)) {
     524                    print STDERR "skipping cleanup for stackRun $stage_id $skycell_id" .
     525                        " because config file is missing\n";
     526                    $status = 0;
     527                }
     528            }
     529            elsif ($mode eq "goto_scrubbed") {
     530                my $config_file = $ipprc->filename("PPSTACK.CONFIG", $path_base, $skycell_id);
     531               
     532                if ($ipprc->file_exists($config_file)) {
     533                    print STDERR "skipping scrubbed for stackRun $stage_id $skycell_id" .
     534                        " because config file is present\n";
     535                    $status = 0;
     536                }
     537            }
     538        }
     539
    454540        if ($status) {
    455541            my @files = ();
     
    475561            my $command = "$stacktool -stack_id $stage_id";
    476562            if ($mode eq "goto_purged") {
    477                 $command .= " -updaterun -state purged";
     563                $command .= " -updaterun -set_state purged";
    478564            }
    479565            elsif ($mode eq "goto_cleaned") {
    480                 $command .= " -updaterun -state cleaned";
     566                $command .= " -updaterun -set_state cleaned";
    481567            }
    482568            elsif ($mode eq "goto_scrubbed") {
    483                 $command .= " -updaterun -state scrubbed";
     569                $command .= " -updaterun -set_state scrubbed";
    484570            }
    485571            $command .= " -dbname $dbname" if defined $dbname;
     
    491577                &my_die("Unable to perform stacktool: $error_code", "stack", $stage_id, $error_code);
    492578            }
     579
     580            # Tell magicdstool that we've cleaned up this data, so it needs to do the same if it needs to do the same.
     581            my $magicdstool = can_run('magicdstool') or die "Can't find magicdstool";
     582            $command = "$magicdstool -dbname gpc1  -stage $stage -stage_id $stage_id -updaterun -set_state goto_cleaned";
     583            ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     584                run(command => $command, verbose => $verbose);
     585            unless ($success) {
     586                $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     587                &my_die("Unable to perform magicdstool: $error_code", "$stage", $stage_id, $error_code);
     588            }
     589
    493590        } else {
    494             my $command = "$stacktool -updaterun  -stack_id $stage_id -state $error_state";
     591            my $command = "$stacktool -updaterun  -stack_id $stage_id -set_state $error_state";
    495592            $command .= " -dbname $dbname" if defined $dbname;
    496593           
     
    501598                &my_die("Unable to perform stacktool: $error_code", "stack", $stage_id, $error_code);
    502599            }
    503             exit $PS_EXIT_UNKNOWN_ERROR;
     600#           exit $PS_EXIT_UNKNOWN_ERROR;
    504601        }
    505602    }
     
    523620        &my_die("Unable to perform difftool: $error_code", "diff", $stage_id, $error_code);
    524621    }
     622
     623    if (@$stdout_buf == 0) {
     624        # No skycells were found for some reason.
     625        # Not technically an "error," but a "you told me to do X, and I can't. Please fix this yourself."
     626        my $command = "$difftool -updaterun -diff_id $stage_id -set_state $error_state";
     627        $command .= " -dbname $dbname" if defined $dbname;
     628       
     629        my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     630            run(command => $command, verbose => $verbose);
     631        unless ($success) {
     632            $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     633            &my_die("Unable to perform difftool: $error_code", "diff", $stage_id, $error_code);
     634        }
     635       
     636        exit(0);
     637    }
     638
    525639    my $metadata = $mdcParser->parse(join "", @{ $stdout_buf }) or
    526640        &my_die("Unable to parse metadata config doc", "diff", $stage_id, $PS_EXIT_PROG_ERROR);
     
    535649
    536650        my $status = 1;
    537         if ($mode eq "goto_cleaned") {
    538             my $config_file = $ipprc->filename("PPSUB.CONFIG", $path_base, $skycell_id);
    539 
    540             unless ($ipprc->file_exists($config_file)) {
    541                 print STDERR "skipping cleanup for diffRun $stage_id $skycell_id" .
    542                     " because config file ($config_file) is missing\n";
    543                 $status = 0;
    544             }
    545         }
    546         elsif ($mode eq "goto_scrubbed") {
    547             my $config_file = $ipprc->filename("PPSUB.CONFIG", $path_base, $skycell_id);
    548 
    549             if ($ipprc->file_exists($config_file)) {
    550                 print STDERR "skipping scrubbed for diffRun $stage_id $skycell_id" .
    551                     " because config file ($config_file) is present\n";
    552                 $status = 0;
     651        if ((!exists($skyfile->{path_base}))||
     652            (!defined($path_base))) {
     653            $status = 0;
     654        }
     655        if ($status) {
     656           
     657            if ($mode eq "goto_cleaned") {
     658                my $config_file = $ipprc->filename("PPSUB.CONFIG", $path_base, $skycell_id);
     659               
     660                unless ($ipprc->file_exists($config_file)) {
     661                    print STDERR "skipping cleanup for diffRun $stage_id $skycell_id" .
     662                        " because config file ($config_file) is missing\n";
     663                    $status = 0;
     664                }
     665            }
     666            elsif ($mode eq "goto_scrubbed") {
     667                my $config_file = $ipprc->filename("PPSUB.CONFIG", $path_base, $skycell_id);
     668               
     669                if ($ipprc->file_exists($config_file)) {
     670                    print STDERR "skipping scrubbed for diffRun $stage_id $skycell_id" .
     671                        " because config file ($config_file) is present\n";
     672                    $status = 0;
     673                }
    553674            }
    554675        }
     
    588709#       print STDERR "MY STATUS: $status\n";
    589710        if ($status) {
    590             my $command = "$difftool -diff_id $stage_id";
    591 
    592             if ($mode eq "goto_purged") {
    593                 $command .= " -updaterun -state purged";
     711            my $command = "$difftool -diff_id $stage_id -skycell_id $skycell_id";
     712
     713            if ($mode eq "goto_purged") {
     714                $command .= " -topurgedskyfile";
    594715            }
    595716            elsif ($mode eq "goto_cleaned") {
    596                 $command .= " -updaterun -state cleaned";
     717                $command .= " -tocleanedskyfile";
    597718            }
    598719            elsif ($mode eq "goto_scrubbed") {
    599                 $command .= " -updaterun -state scrubbed";
     720                $command .= " -toscrubbedskyfile";
    600721            }
    601722
     
    608729                &my_die("Unable to perform difftool: $error_code", "diff", $stage_id, $error_code);
    609730            }
     731
     732            # Tell magicdstool that we've cleaned up this data, so it needs to do the same if it needs to do the same.
     733            my $magicdstool = can_run('magicdstool') or die "Can't find magicdstool";
     734            $command = "$magicdstool -dbname gpc1 -stage $stage -stage_id $stage_id -updaterun -set_state goto_cleaned";
     735            ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     736                run(command => $command, verbose => $verbose);
     737            unless ($success) {
     738                $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     739                &my_die("Unable to perform magicdstool: $error_code", "$stage", $stage_id, $error_code);
     740            }
     741
    610742        } else {
    611             my $command = "$difftool -updaterun -diff_id $stage_id -state $error_state";
     743            my $command = "$difftool -updaterun -diff_id $stage_id -set_state $error_state";
    612744
    613745            $command .= " -dbname $dbname" if defined $dbname;
     
    619751                &my_die("Unable to perform difftool: $error_code", "diff", $stage_id, $error_code);
    620752            }
    621             exit $PS_EXIT_UNKNOWN_ERROR;
     753#           exit $PS_EXIT_UNKNOWN_ERROR;
    622754        }
    623755    }
     
    646778    # if there are no fakeProcessedImfiles (@$stdout_buf == 0), the reset the state to 'new'
    647779    if (@$stdout_buf == 0)  {
    648         my $command = "$faketool -fake_id $stage_id -updaterun -set_state new";
     780        my $command = "$faketool -fake_id $stage_id -updaterun -set_state $error_state";
    649781        $command .= " -dbname $dbname" if defined $dbname;
    650782
Note: See TracChangeset for help on using the changeset viewer.