IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 28954


Ignore:
Timestamp:
Aug 18, 2010, 12:17:32 PM (16 years ago)
Author:
rhenders
Message:

now deleting batches from datastore when conditions are met; now showing batch timestamp in output for convenience

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ippToPsps/perl/checkOdmStatus.pl

    r28897 r28954  
    99use File::Temp qw(tempfile);
    1010use ippToPsps::IppToPspsDb;
     11use ippToPsps::Datastore;
    1112
    1213my $singleBatch = undef;
    1314my $verbose = undef;
    1415my $save_temps = undef;
     16my $fromTime = undef;
     17my $toTime = undef;
     18my $product = undef;
     19
    1520
    1621GetOptions(
    1722        'batch|b=s' => \$singleBatch,
     23        'from|f=s' => \$fromTime,
     24        'to|t=s' => \$toTime,
     25        'product|p=s' => \$product,
    1826        'verbose|v' => \$verbose,
    1927        'save_temps|s' => \$save_temps
    2028        );
    2129
     30if (!defined $product) {
     31    print "* OPTIONAL: a datastore product name        -p <name>\n";
     32}
    2233if (!defined $singleBatch) {
    2334    print "* OPTIONAL: a single batch                  -b                   (default = none)\n";
     35}
     36if (!defined $fromTime) {
     37    $fromTime = "2010-01-01";
     38    print "* OPTIONAL: from time                       -f                   (default = $fromTime)\n";
     39}
     40if (!defined $toTime) {
     41    $toTime = "2099-12-31";
     42    print "* OPTIONAL: to time                         -t                   (default = $toTime)\n";
    2443}
    2544if (!defined $verbose) {
     
    3352
    3453
     54my $datastore = new ippToPsps::Datastore($product, 0, 0);
    3555my $ippToPspsDb = new ippToPsps::IppToPspsDb("ippToPsps", "ippdb01", "ipp", "ipp", $verbose, $save_temps);
    36 my $fromFilter = "2010-08-01";
    37 my $toFilter = "2099-12-31";
    3856my $odmUrl = "http://web01.psps.ifa.hawaii.edu/a01/OdmWebService/OdmWebService.asmx/GetBatchStatus";
    3957my $ua = LWP::UserAgent->new;
     
    5573
    5674    if (defined $singleBatch ) { $numOfBatches = $ippToPspsDb->getSingleBatch($singleBatch, \$batches);}
    57     else { $numOfBatches = $ippToPspsDb->getBatchList(\$batches);}
     75    else { $numOfBatches = $ippToPspsDb->getBatchList(\$batches, $fromTime, $toTime);}
    5876
    5977    if ($numOfBatches < 1) {return 0;}
    6078
    6179    print "\n";
    62     printf("+--------------+--------------+----------------+---------------+---------+\n");
    63     printf("|    Batch     |  Exposure ID | Loaded to ODM? | Merge worthy? | Merged? |\n");
    64     printf("+--------------+--------------+----------------+---------------+---------+\n");
     80    printf("+----------------------+--------------+--------------+----------------+---------------+---------+----------+\n");
     81    printf("|      Timestamp       |    Batch     |  Exposure ID | Loaded to ODM? | Merge worthy? | Merged? | Deleted? |\n");
     82    printf("+----------------------+--------------+--------------+----------------+---------------+---------+----------+\n");
    6583
    6684    # loop round batches
     
    6886    my $numChecked = 0;
    6987    foreach $batch ( @{$batches} ) {
    70         my ($expId, $batchId, $surveyType) =  @{$batch};
     88        my ($timestamp, $expId, $batchId, $surveyType, $deleted) =  @{$batch};
    7189
    72 if (checkBatch($expId, $batchId, $surveyType)) {$numChecked++;}
     90        if (checkBatch($timestamp, $expId, $batchId, $surveyType, $deleted)) {$numChecked++;}
    7391
    7492    }
    75     printf("+--------------+--------------+----------------+---------------+---------+\n");
     93    printf("+----------------------+--------------+--------------+----------------+---------------+---------+----------+\n");
    7694
    7795    printf( "* Successfully checked %d batch%s out of %d\n", $numChecked, ($numChecked==1) ? "" : "es", $numOfBatches);
     
    85103########################################################################################
    86104sub checkBatch {
    87     my ($expId, $batchId, $surveyType) = @_;
     105    my ($timestamp, $expId, $batchId, $surveyType, $deleted) = @_;
    88106
    89107
     
    94112            [batchNameFilter => $batchFilter,
    95113            statusFilter => $statusFilter,
    96             fromFilter => $fromFilter,
    97             toFilter => $toFilter]
     114            fromFilter => "2010-01-01",
     115            toFilter => "2099-01-01"]
    98116            );
    99117
     
    110128    close($tempFile);
    111129
    112     my $loadedToOdm;
    113     my $mergeWorthy;
    114     my $mergeCompleted;
     130    my $loadedToOdm = 0;
     131    my $mergeWorthy = 0;
     132    my $mergeCompleted = 0;
    115133
    116134    parseXml($tempName, \$loadedToOdm, \$mergeWorthy, \$mergeCompleted);
    117     printf( "| %11s  | %10d   |    %6s      |    %6s     | %6s  |\n",
     135
     136    # delete from datastore
     137    if(defined $product) {
     138   
     139        if (!$deleted && $loadedToOdm && $mergeWorthy) {
     140       
     141            $deleted = $datastore->remove($batchFilter);
     142            if ($deleted) {
     143                $ippToPspsDb->setBatchAsDeleted($batchId, $expId);
     144            }
     145        }
     146    }
     147   
     148    printf( "| %18s  | %11s  | %10d   |    %6s      |    %6s     | %6s  |  %5s   |\n",
     149            $timestamp,
    118150            $batchFilter,
    119151            $expId,
    120152            $loadedToOdm ? "yes" : "no",
    121153            $mergeWorthy ? "yes" : "no",
    122             $mergeCompleted ? "yes" : "no");
     154            $mergeCompleted ? "yes" : "no",
     155            $deleted ? "yes" : "no");
    123156
    124     $ippToPspsDb->updateODMStatus($batchId, $expId, $loadedToOdm, $mergeWorthy, $mergeCompleted);
     157    $ippToPspsDb->updateODMStatus($batchId, $expId, $loadedToOdm, $mergeWorthy, $mergeCompleted, $deleted);
     158
    125159}
    126160
Note: See TracChangeset for help on using the changeset viewer.