Changeset 28954
- Timestamp:
- Aug 18, 2010, 12:17:32 PM (16 years ago)
- File:
-
- 1 edited
-
trunk/ippToPsps/perl/checkOdmStatus.pl (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippToPsps/perl/checkOdmStatus.pl
r28897 r28954 9 9 use File::Temp qw(tempfile); 10 10 use ippToPsps::IppToPspsDb; 11 use ippToPsps::Datastore; 11 12 12 13 my $singleBatch = undef; 13 14 my $verbose = undef; 14 15 my $save_temps = undef; 16 my $fromTime = undef; 17 my $toTime = undef; 18 my $product = undef; 19 15 20 16 21 GetOptions( 17 22 'batch|b=s' => \$singleBatch, 23 'from|f=s' => \$fromTime, 24 'to|t=s' => \$toTime, 25 'product|p=s' => \$product, 18 26 'verbose|v' => \$verbose, 19 27 'save_temps|s' => \$save_temps 20 28 ); 21 29 30 if (!defined $product) { 31 print "* OPTIONAL: a datastore product name -p <name>\n"; 32 } 22 33 if (!defined $singleBatch) { 23 34 print "* OPTIONAL: a single batch -b (default = none)\n"; 35 } 36 if (!defined $fromTime) { 37 $fromTime = "2010-01-01"; 38 print "* OPTIONAL: from time -f (default = $fromTime)\n"; 39 } 40 if (!defined $toTime) { 41 $toTime = "2099-12-31"; 42 print "* OPTIONAL: to time -t (default = $toTime)\n"; 24 43 } 25 44 if (!defined $verbose) { … … 33 52 34 53 54 my $datastore = new ippToPsps::Datastore($product, 0, 0); 35 55 my $ippToPspsDb = new ippToPsps::IppToPspsDb("ippToPsps", "ippdb01", "ipp", "ipp", $verbose, $save_temps); 36 my $fromFilter = "2010-08-01";37 my $toFilter = "2099-12-31";38 56 my $odmUrl = "http://web01.psps.ifa.hawaii.edu/a01/OdmWebService/OdmWebService.asmx/GetBatchStatus"; 39 57 my $ua = LWP::UserAgent->new; … … 55 73 56 74 if (defined $singleBatch ) { $numOfBatches = $ippToPspsDb->getSingleBatch($singleBatch, \$batches);} 57 else { $numOfBatches = $ippToPspsDb->getBatchList(\$batches );}75 else { $numOfBatches = $ippToPspsDb->getBatchList(\$batches, $fromTime, $toTime);} 58 76 59 77 if ($numOfBatches < 1) {return 0;} 60 78 61 79 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"); 65 83 66 84 # loop round batches … … 68 86 my $numChecked = 0; 69 87 foreach $batch ( @{$batches} ) { 70 my ($ expId, $batchId, $surveyType) = @{$batch};88 my ($timestamp, $expId, $batchId, $surveyType, $deleted) = @{$batch}; 71 89 72 if (checkBatch($expId, $batchId, $surveyType)) {$numChecked++;}90 if (checkBatch($timestamp, $expId, $batchId, $surveyType, $deleted)) {$numChecked++;} 73 91 74 92 } 75 printf("+-------------- +--------------+----------------+---------------+---------+\n");93 printf("+----------------------+--------------+--------------+----------------+---------------+---------+----------+\n"); 76 94 77 95 printf( "* Successfully checked %d batch%s out of %d\n", $numChecked, ($numChecked==1) ? "" : "es", $numOfBatches); … … 85 103 ######################################################################################## 86 104 sub checkBatch { 87 my ($ expId, $batchId, $surveyType) = @_;105 my ($timestamp, $expId, $batchId, $surveyType, $deleted) = @_; 88 106 89 107 … … 94 112 [batchNameFilter => $batchFilter, 95 113 statusFilter => $statusFilter, 96 fromFilter => $fromFilter,97 toFilter => $toFilter]114 fromFilter => "2010-01-01", 115 toFilter => "2099-01-01"] 98 116 ); 99 117 … … 110 128 close($tempFile); 111 129 112 my $loadedToOdm ;113 my $mergeWorthy ;114 my $mergeCompleted ;130 my $loadedToOdm = 0; 131 my $mergeWorthy = 0; 132 my $mergeCompleted = 0; 115 133 116 134 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, 118 150 $batchFilter, 119 151 $expId, 120 152 $loadedToOdm ? "yes" : "no", 121 153 $mergeWorthy ? "yes" : "no", 122 $mergeCompleted ? "yes" : "no"); 154 $mergeCompleted ? "yes" : "no", 155 $deleted ? "yes" : "no"); 123 156 124 $ippToPspsDb->updateODMStatus($batchId, $expId, $loadedToOdm, $mergeWorthy, $mergeCompleted); 157 $ippToPspsDb->updateODMStatus($batchId, $expId, $loadedToOdm, $mergeWorthy, $mergeCompleted, $deleted); 158 125 159 } 126 160
Note:
See TracChangeset
for help on using the changeset viewer.
