Changeset 28980
- Timestamp:
- Aug 19, 2010, 6:50:13 PM (16 years ago)
- Location:
- branches/eam_branches/ipp-20100621
- Files:
-
- 1 deleted
- 44 edited
- 25 copied
-
ippMonitor/Makefile.in (modified) (7 diffs)
-
ippMonitor/def/failedCamProcessedExp.d (copied) (copied from trunk/ippMonitor/def/failedCamProcessedExp.d )
-
ippMonitor/def/failedChipProcessedImfile.d (copied) (copied from trunk/ippMonitor/def/failedChipProcessedImfile.d )
-
ippMonitor/def/failedDiffSkyfile.d (copied) (copied from trunk/ippMonitor/def/failedDiffSkyfile.d )
-
ippMonitor/def/failedFakeProcessedImfile.d (copied) (copied from trunk/ippMonitor/def/failedFakeProcessedImfile.d )
-
ippMonitor/def/failedMagicMasks.d (copied) (copied from trunk/ippMonitor/def/failedMagicMasks.d )
-
ippMonitor/def/failedMagicNodes.d (copied) (copied from trunk/ippMonitor/def/failedMagicNodes.d )
-
ippMonitor/def/failedMagicTrees.d (copied) (copied from trunk/ippMonitor/def/failedMagicTrees.d )
-
ippMonitor/def/failedStackSkyfile.d (copied) (copied from trunk/ippMonitor/def/failedStackSkyfile.d )
-
ippMonitor/def/failedWarpSkyfiles.d (copied) (copied from trunk/ippMonitor/def/failedWarpSkyfiles.d )
-
ippMonitor/raw/czartool_getplot.php (modified) (1 diff)
-
ippMonitor/raw/czartool_labels.php (modified) (13 diffs)
-
ippMonitor/raw/ipp.imfiles.dat (modified) (1 diff)
-
ippMonitor/scripts/czartool_revert.pl (modified) (1 diff)
-
ippMonitor/scripts/generate (modified) (2 diffs)
-
ippToPsps/perl/checkOdmStatus.pl (copied) (copied from trunk/ippToPsps/perl/checkOdmStatus.pl )
-
ippToPsps/perl/convertPhotCodesToXml.pl (copied) (copied from trunk/ippToPsps/perl/convertPhotCodesToXml.pl )
-
ippToPsps/perl/ippToPsps/Datastore.pm (copied) (copied from trunk/ippToPsps/perl/ippToPsps/Datastore.pm )
-
ippToPsps/perl/ippToPsps/Gpc1Db.pm (modified) (4 diffs)
-
ippToPsps/perl/ippToPsps/IppToPspsDb.pm (modified) (18 diffs)
-
ippToPsps/perl/ippToPsps_run.pl (modified) (14 diffs)
-
ippToPsps/perl/pspsSchema2xml.pl (copied) (copied from trunk/ippToPsps/perl/pspsSchema2xml.pl )
-
ippToPsps/perl/removeFromDatastore.pl (copied) (copied from trunk/ippToPsps/perl/removeFromDatastore.pl )
-
ippToPsps/scripts (deleted)
-
ippTools/share/Makefile.am (modified) (6 diffs)
-
ippTools/share/addtool_find_cam_id_dvo.sql (copied) (copied from trunk/ippTools/share/addtool_find_cam_id_dvo.sql )
-
ippTools/share/bgtool_listchip.sql (copied) (copied from trunk/ippTools/share/bgtool_listchip.sql )
-
ippTools/share/bgtool_listwarp.sql (copied) (copied from trunk/ippTools/share/bgtool_listwarp.sql )
-
ippTools/share/chiptool_setimfiletoupdate.sql (modified) (1 diff)
-
ippTools/share/disttool_definebyquery_sky.sql (copied) (copied from trunk/ippTools/share/disttool_definebyquery_sky.sql )
-
ippTools/share/disttool_pending_sky.sql (copied) (copied from trunk/ippTools/share/disttool_pending_sky.sql )
-
ippTools/share/disttool_rerun_select.sql (copied) (copied from trunk/ippTools/share/disttool_rerun_select.sql )
-
ippTools/share/disttool_toadvance.sql (modified) (1 diff)
-
ippTools/share/magicdstool_torevert_chip.sql (modified) (2 diffs)
-
ippTools/share/pxadmin_create_tables.sql (modified) (3 diffs)
-
ippTools/share/staticskytool_export_input.sql (copied) (copied from trunk/ippTools/share/staticskytool_export_input.sql )
-
ippTools/share/staticskytool_export_result.sql (copied) (copied from trunk/ippTools/share/staticskytool_export_result.sql )
-
ippTools/share/staticskytool_export_run.sql (copied) (copied from trunk/ippTools/share/staticskytool_export_run.sql )
-
ippTools/share/staticskytool_result.sql (modified) (1 diff)
-
ippTools/src/addtool.c (modified) (1 diff)
-
ippTools/src/bgtool.c (modified) (6 diffs)
-
ippTools/src/bgtool.h (modified) (2 diffs)
-
ippTools/src/bgtoolConfig.c (modified) (4 diffs)
-
ippTools/src/disttool.c (modified) (4 diffs)
-
ippTools/src/disttool.h (modified) (1 diff)
-
ippTools/src/disttoolConfig.c (modified) (3 diffs)
-
ippTools/src/magicdstool.c (modified) (1 diff)
-
ippTools/src/magicdstoolConfig.c (modified) (1 diff)
-
ippTools/src/pstamptool.c (modified) (1 diff)
-
ippTools/src/pstamptoolConfig.c (modified) (1 diff)
-
ippTools/src/staticskytool.c (modified) (5 diffs)
-
pstamp/scripts/detect_query_create (modified) (6 diffs)
-
pstamp/scripts/detect_query_read (modified) (8 diffs)
-
pstamp/scripts/detectability_respond.pl (modified) (8 diffs)
-
pstamp/scripts/dqueryparse.pl (modified) (2 diffs)
-
pstamp/scripts/pstamp_checkdependent.pl (modified) (1 diff)
-
pstamp/scripts/pstamp_job_run.pl (modified) (4 diffs)
-
pstamp/scripts/pstampparse.pl (modified) (1 diff)
-
pstamp/src/ppstampMakeStamp.c (modified) (4 diffs)
-
tools/czarplot.pl (modified) (6 diffs)
-
tools/czartool.pl (modified) (3 diffs)
-
tools/czartool/CzarDb.pm (modified) (9 diffs)
-
tools/czartool/Czarplot.pm (modified) (7 diffs)
-
tools/czartool/Gpc1Db.pm (modified) (6 diffs)
-
tools/czartool/Nebulous.pm (copied) (copied from trunk/tools/czartool/Nebulous.pm )
-
tools/czartool/Pantasks.pm (modified) (7 diffs)
-
tools/difflog_grep.pl (copied) (copied from trunk/tools/difflog_grep.pl )
-
tools/examine_burntool_pcontrol.pl (modified) (1 diff)
-
tools/psstatus (modified) (6 diffs)
-
tools/roboczar.pl (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20100621/ippMonitor/Makefile.in
r28794 r28980 103 103 $(DESTWWW)/chipProcessedImfile.php \ 104 104 $(DESTWWW)/chipProcessedImfile_failure.php \ 105 $(DESTWWW)/failedChipProcessedImfile.php \ 105 106 $(DESTWWW)/camSummary.php \ 106 107 $(DESTWWW)/camStageExp.php \ … … 109 110 $(DESTWWW)/camProcessedExp_Images.php \ 110 111 $(DESTWWW)/camProcessedExp_failure.php \ 112 $(DESTWWW)/failedCamProcessedExp.php \ 111 113 $(DESTWWW)/camIQstats.php \ 112 114 $(DESTWWW)/camProcessedImfile.php \ … … 118 120 $(DESTWWW)/fakeProcessedImfile.php \ 119 121 $(DESTWWW)/fakeProcessedImfile_failure.php \ 122 $(DESTWWW)/failedFakeProcessedImfile.php \ 120 123 $(DESTWWW)/pzPendingExp.php \ 121 124 $(DESTWWW)/pzPendingImfile.php \ … … 142 145 $(DESTWWW)/warpProcessedSkyfiles.php \ 143 146 $(DESTWWW)/warpFailedSkyfiles.php \ 147 $(DESTWWW)/failedWarpSkyfiles.php \ 144 148 $(DESTWWW)/diffSummary.php \ 145 149 $(DESTWWW)/diffSummary_Images.php \ … … 148 152 $(DESTWWW)/diffProcessedSkyfile.php \ 149 153 $(DESTWWW)/diffProcessedSkyfile_Images.php \ 150 $(DESTWWW)/ diffFailedSkyfile.php \154 $(DESTWWW)/failedDiffSkyfile.php \ 151 155 $(DESTWWW)/stackRun.php \ 152 156 $(DESTWWW)/stackSummary.php \ … … 156 160 $(DESTWWW)/stackProcessedSkyfile_Images.php \ 157 161 $(DESTWWW)/stackFailedSkyfile.php \ 162 $(DESTWWW)/failedStackSkyfile.php \ 158 163 $(DESTWWW)/staticskyRun.php \ 159 164 $(DESTWWW)/staticskySummary.php \ … … 168 173 $(DESTWWW)/magicProcessedMasks_Images.php \ 169 174 $(DESTWWW)/magicFailedTrees.php \ 175 $(DESTWWW)/failedMagicTrees.php \ 170 176 $(DESTWWW)/magicFailedNodes.php \ 177 $(DESTWWW)/failedMagicNodes.php \ 171 178 $(DESTWWW)/magicFailedMasks.php \ 179 $(DESTWWW)/failedMagicMasks.php \ 172 180 $(DESTWWW)/distSummary.php \ 173 181 $(DESTWWW)/distTarget.php \ -
branches/eam_branches/ipp-20100621/ippMonitor/raw/czartool_getplot.php
r28794 r28980 20 20 else if ($type=="h") 21 21 $filePath = "/tmp/czarplot_".$label."_all_stages_".$type.".png"; 22 else if ($type=="s") 23 $filePath = "/tmp/czarplot_hosts_space.png"; 24 22 25 $file = fopen ($filePath, "r"); 23 26 if ($file && !$debug) { -
branches/eam_branches/ipp-20100621/ippMonitor/raw/czartool_labels.php
r28794 r28980 10 10 //$db = dbconnect($ID['proj']); 11 11 $czardb = dbconnect("czardb"); // HACK to connect to czarDb 12 $lastUpdateTime = getLastUpdateTime($czardb); 13 12 14 $gpc1db = dbconnect($ID['proj']); 13 15 … … 22 24 else {$myMenu = "ipp.imfiles.dat";} 23 25 24 menu($myMenu, 'Czartool ', 'ipp.css', $ID['link'], $ID['proj']);26 menu($myMenu, 'Czartool on '.$lastUpdateTime, 'ipp.css', $ID['link'], $ID['proj']); 25 27 26 28 $pass = $ID['pass']; … … 31 33 $selectedLabel = $_GET[label]; 32 34 $selectedServer = $_GET[server]; 33 $selectedRevertServer = $_GET[revertserver];34 35 $selectedRevertStage = $_GET[revertstage]; 35 36 $selectedRevertMode = $_GET[revertmode]; 36 37 37 if ($selectedLabel == "") $selectedLabel = "all_labels"; 38 if ($selectedStage == "") $selectedStage = "all_stages"; 38 if ($selectedLabel == "") { $selectedLabel = "all_stdscience_labels"; } 39 if ($selectedStage == "") { $selectedStage = "all_stages"; } 40 41 echo 'Some documentation can be found <a href="http://svn.pan-starrs.ifa.hawaii.edu/trac/ipp/wiki/Processing">here</a><br>'; 39 42 40 43 // deal with reverts: turn on or off if requested and pass current revert state for this stage onto labels table later 41 $currentRevertMode; 42 if ($selectedRevertStage != "" && $selectedRevertMode != "" && $selectedRevertServer != "" ) { 43 44 exec("czartool_revert.pl -s $selectedRevertServer -t $selectedRevertStage -o $selectedRevertMode", $response, $status);44 if ($selectedRevertStage != "" && $selectedRevertMode != "") { 45 46 exec("czartool_revert.pl -t $selectedRevertStage -o $selectedRevertMode", $response, $status); 47 $currentRevertMode; 45 48 if ($response[0] == "off") $currentRevertMode = 0; 46 49 else if ($response[0] == "on") $currentRevertMode = 1; 50 51 setRevertStatus($czardb, $selectedRevertStage, $currentRevertMode); 47 52 } 48 53 $debug = 0; … … 51 56 $distLabels = getLabels($czardb, "distribution"); 52 57 $pubLabels = getLabels($czardb, "publishing"); 58 $updateLabels = getLabels($czardb, "update"); 53 59 54 60 if ($debug) { … … 81 87 echo "<input type=\"hidden\" name=\"menu\" value=\"$menu\">\n"; 82 88 echo "</form>\n"; 83 $lastUpdateTime = getLastUpdateTime($czardb);84 89 echo "<p align=\"center\"> Current status of IPP (any faults are shown in parentheses). NOTE: This data is good as of: $lastUpdateTime </p>"; 85 90 86 91 echo "<table>\n"; 87 92 echo "<tr>\n"; 93 echo "<td>\n"; 94 echo "<img src=\"czartool_getplot.php?type=t&label=$selectedLabel&stage=$selectedStage\"><br>"; 95 echo "</td>\n"; 88 96 89 97 echo "<td> \n"; 90 echo "<img src=\"czartool_getplot.php?type=t&label=$selectedLabel&stage=$selectedStage\"><br>\n"; 91 echo "</td>\n"; 92 93 echo "<td> \n"; 94 createLabelsTable($pass, $proj, $czardb, $stdsLabels, $distLabels, $pubLabels, $stages, $states, "new", $selectedLabel, $selectedStage, $selectedRevertStage, $currentRevertMode); 95 echo "</td>\n"; 96 97 echo "</tr>\n"; 98 echo "<tr>\n"; 99 100 echo "<table>\n"; 101 echo "<tr valign=top>\n"; 102 echo "<td> \n"; 103 echo "<img src=\"czartool_getplot.php?type=h&label=$selectedLabel&stage=$selectedStage\"><br>\n"; 104 echo "</td>\n"; 105 echo "<td> \n"; 106 createServersTable($pass, $proj,$czardb, $servers, $selectedLabel, $selectedStage); 107 echo "</td>\n"; 108 109 echo "<td> \n"; 110 $today = date("Y-m-d"); // 03.10.01 111 showSummitData($gpc1db, $today); 98 createLabelsTable($pass, $proj, $czardb, "stdscience", $stdsLabels, $distLabels, $pubLabels, $stages, $states, "new", $selectedLabel, $selectedStage); 112 99 echo "</td>\n"; 113 100 echo "</tr>\n"; 114 echo "</table>\n"; 115 if ($selectedServer) showServerStatus($selectedServer); 116 101 102 echo "<tr>\n"; 103 echo "<td>\n"; 104 echo "<img src=\"czartool_getplot.php?type=h&label=$selectedLabel&stage=$selectedStage\"><br>"; 105 echo "</td>\n"; 106 107 echo "<td> \n"; 108 createLabelsTable($pass, $proj, $czardb, "update", $updateLabels, $distLabels, $pubLabels, $stages, $states, "new", $selectedLabel, $selectedStage); 109 echo "</td>\n"; 110 echo "</tr>\n"; 111 112 echo "<tr>\n"; 113 echo "<table>\n"; 114 echo "<tr valign=top>\n"; 115 echo "<td> \n"; 116 echo "<img src=\"czartool_getplot.php?type=s\"><br>"; 117 echo "</td>\n"; 118 echo "<td>\n"; 119 createServersTable($pass, $proj,$czardb, $servers, $selectedLabel, $selectedStage); 120 echo "</td>\n"; 121 122 echo "<td> \n"; 123 $today = date("Y-m-d"); 124 showSummitData($gpc1db, $today); 125 echo "</td>\n"; 126 echo "</tr>\n"; 127 echo "</table>\n"; 128 129 echo "<table>\n"; 130 echo "<tr valign=top>\n"; 131 echo "<td> \n"; 132 echo "</td>\n"; 133 echo "<td>\n"; 134 if ($selectedServer) showServerStatus($selectedServer); 135 echo "</td>\n"; 136 echo "</tr>\n"; 137 echo "</table>\n"; 117 138 echo "</tr>\n"; 118 139 echo "</table>\n"; … … 203 224 # 204 225 ########################################################################### 205 function createLabelsTable($pass, $proj, $db, $s tdsLabels, $distLabels, $pubLabels, $stages, $states, $selectedState, $selectedLabel, $selectedStage, $selectedRevertStage, $currentRevertMode) {226 function createLabelsTable($pass, $proj, $db, $server, $labels, $distLabels, $pubLabels, $stages, $states, $selectedState, $selectedLabel, $selectedStage) { 206 227 207 228 // set up table columns … … 210 231 echo "<tr><td></td>\n"; 211 232 233 echo "<p align=\"center\"> Current labels for $server server </p>"; 234 212 235 write_header_cell($class, ""); 213 236 write_header_cell($class, ""); … … 215 238 foreach ($stages as &$stage) { 216 239 217 $revertOnOff=array(); 218 if ($stage == "destreak" or $stage == "dist") $server = "distribution"; 219 else $server = "stdscience"; 220 if ($stage == $selectedRevertStage) $reverting = $currentRevertMode; 221 else $reverting = getRevertStatus($db, $stage); 222 $link = "czartool_labels.php?pass=" . $pass . "&proj=" . $proj . "&revertserver=" . $server . "&revertstage=" . $stage . "&revertmode="; 240 $reverting = getRevertStatus($db, $stage); 241 $link = "czartool_labels.php?pass=" . $pass . "&proj=" . $proj . "&label=" . $selectedLabel . "&stage=" . $selectedStage . "&revertstage=" . $stage . "&revertmode="; 223 242 if(!$reverting) {$label = "Start";$link = $link . "on";} 224 243 if($reverting) {$label = "Stop";$link = $link . "off";} … … 250 269 251 270 // write rows 252 foreach ($ stdsLabels as &$stdsLabel) {271 foreach ($labels as &$thisLabel) { 253 272 254 273 $distributing = false; … … 256 275 foreach ($distLabels as &$distLabel) { 257 276 258 if ($ stdsLabel == $distLabel) { $distributing = true; break;}277 if ($thisLabel == $distLabel) { $distributing = true; break;} 259 278 } 260 279 foreach ($pubLabels as &$pubLabel) { 261 280 262 if ($ stdsLabel == $pubLabel) { $publishing = true; break;}281 if ($thisLabel == $pubLabel) { $publishing = true; break;} 263 282 } 264 283 265 284 // create link to label summary page for each label 266 if ($ stdsLabel == $selectedLabel) $link = "";267 else $link = "czartool_labels.php?pass=" . $pass . "&proj=" . $proj . "&label=" . $ stdsLabel . "&stage=" . $selectedStage;285 if ($thisLabel == $selectedLabel) $link = ""; 286 else $link = "czartool_labels.php?pass=" . $pass . "&proj=" . $proj . "&label=" . $thisLabel . "&stage=" . $selectedStage; 268 287 269 288 echo "<tr><td></td>\n"; 270 write_table_cell($class, '%s', $link, $ stdsLabel);289 write_table_cell($class, '%s', $link, $thisLabel); 271 290 write_table_cell($class, '%s', "", $distributing ? "yes" : "NO"); 272 291 write_table_cell($class, '%s', "", $publishing ? "yes" : "NO"); … … 275 294 $anyFaults = false; 276 295 277 $link = " chipProcessedImfile_failure.php?pass=" . $pass . "&proj=" . $proj . "&chipRun.label=" . $stdsLabel . "&chipRun.state=new";278 getStateAndFaults($db, $ stdsLabel, $selectedState, "chip", $str, $anyFaults);296 $link = "failedChipProcessedImfile.php?pass=" . $pass . "&proj=" . $proj . "&chipRun.label=" . $thisLabel . "&chipRun.state=new"; 297 getStateAndFaults($db, $thisLabel, $selectedState, "chip", $str, $anyFaults); 279 298 write_table_cell($class, '%s', $anyFaults ? $link : "", $str); 280 299 281 $link = " camProcessedExp_failure.php?pass=" . $pass . "&proj=" . $proj . "&camRun.label=" . $stdsLabel . "&camRun.state=new";282 getStateAndFaults($db, $ stdsLabel, $selectedState, "cam", $str, $anyFaults);300 $link = "failedCamProcessedExp.php?pass=" . $pass . "&proj=" . $proj . "&camRun.label=" . $thisLabel . "&camRun.state=new"; 301 getStateAndFaults($db, $thisLabel, $selectedState, "cam", $str, $anyFaults); 283 302 write_table_cell($class, '%s', $anyFaults ? $link : "", $str); 284 303 304 $link = "failedFakeProcessedImfile.php?pass=" . $pass . "&proj=" . $proj . "&fakeRun.label=" . $thisLabel . "&fakeRun.state=new"; 305 getStateAndFaults($db, $thisLabel, $selectedState, "fake", $str, $anyFaults); 306 write_table_cell($class, '%s', $anyFaults ? $link : "", $str); 307 308 $link = "failedWarpSkyfiles.php?pass=" . $pass . "&proj=" . $proj . "&warpRun.label=" . $thisLabel . "&warpRun.state=new"; 309 getStateAndFaults($db, $thisLabel, $selectedState, "warp", $str, $anyFaults); 310 write_table_cell($class, '%s', $anyFaults ? $link : "", $str); 311 312 $link = "failedStackSkyfile.php?pass=" . $pass . "&proj=" . $proj . "&stackRun.label=" . $thisLabel . "&stackRun.state=new"; 313 getStateAndFaults($db, $thisLabel, $selectedState, "stack", $str, $anyFaults); 314 write_table_cell($class, '%s', $anyFaults ? $link : "", $str); 315 316 $link = "failedDiffSkyfile.php?pass=" . $pass . "&proj=" . $proj . "&diffRun.label=" . $thisLabel . "&diffRun.state=new"; 317 getStateAndFaults($db, $thisLabel, $selectedState, "diff", $str, $anyFaults); 318 write_table_cell($class, '%s', $anyFaults ? $link : "", $str); 319 285 320 $link = $defaultlink; 286 getStateAndFaults($db, $ stdsLabel, $selectedState, "fake", $str, $anyFaults);321 getStateAndFaults($db, $thisLabel, $selectedState, "magic", $str, $anyFaults); 287 322 write_table_cell($class, '%s', $anyFaults ? $link : "", $str); 288 323 289 $link = "warpFailedSkyfiles.php?pass=" . $pass . "&proj=" . $proj . "&warpRun.label=" . $stdsLabel . "&warpRun.state=new"; 290 getStateAndFaults($db, $stdsLabel, $selectedState, "warp", $str, $anyFaults); 291 write_table_cell($class, '%s', $anyFaults ? $link : "", $str); 292 293 $link = "stackFailedSkyfile.php?pass=" . $pass . "&proj=" . $proj . "&stackRun.label=" . $stdsLabel . "&stackRun.state=new"; 294 getStateAndFaults($db, $stdsLabel, $selectedState, "stack", $str, $anyFaults); 324 $link = $defaultlink; 325 getStateAndFaults($db, $thisLabel, $selectedState, "magicDS", $str, $anyFaults); 295 326 write_table_cell($class, '%s', $anyFaults ? $link : "", $str); 296 327 297 $link = "diffFailedSkyfile.php?pass=" . $pass . "&proj=" . $proj . "&diffRun.label=" . $stdsLabel . "&diffRun.state=new";298 getStateAndFaults($db, $stdsLabel, $selectedState, "diff", $str, $anyFaults);299 write_table_cell($class, '%s', $anyFaults ? $link : "", $str);300 301 328 $link = $defaultlink; 302 getStateAndFaults($db, $ stdsLabel, $selectedState, "magic", $str, $anyFaults);329 getStateAndFaults($db, $thisLabel, $selectedState, "dist", $str, $anyFaults); 303 330 write_table_cell($class, '%s', $anyFaults ? $link : "", $str); 304 331 305 $link = $defaultlink;306 getStateAndFaults($db, $stdsLabel, $selectedState, "magicDS", $str, $anyFaults);307 write_table_cell($class, '%s', $anyFaults ? $link : "", $str);308 309 $link = $defaultlink;310 getStateAndFaults($db, $stdsLabel, $selectedState, "dist", $str, $anyFaults);311 write_table_cell($class, '%s', $anyFaults ? $link : "", $str);312 313 332 echo "</tr>\n"; 314 333 } 315 334 316 if ($selectedLabel == "all_ labels") $link = "";317 else $link = "czartool_labels.php?pass=" . $pass . "&proj=" . $proj . "&label=all_ labels&stage=".$selectedStage;335 if ($selectedLabel == "all_".$server."_labels") $link = ""; 336 else $link = "czartool_labels.php?pass=" . $pass . "&proj=" . $proj . "&label=all_".$server."_labels&stage=".$selectedStage; 318 337 319 338 echo "<tr><td></td>\n"; 320 write_table_cell($class, '%s', $link, "All labels:"); 321 write_table_cell($class, '%s', "", "-"); 322 write_table_cell($class, '%s', "", "-"); 323 324 $str = ""; 325 $anyFaults = false; 326 327 $link = "chipProcessedImfile_failure.php?pass=" . $pass . "&proj=" . $proj . "&chipRun.state=new"; 328 getStateAndFaults($db, "all_labels", $selectedState, "chip", $str, $anyFaults); 329 write_table_cell($class, '%s', $anyFaults ? $link : "", $str); 330 331 $link = "camProcessedExp_failure.php?pass=" . $pass . "&proj=" . $proj . "&camRun.state=new"; 332 getStateAndFaults($db, "all_labels", $selectedState, "cam", $str, $anyFaults); 333 write_table_cell($class, '%s', $anyFaults ? $link : "", $str); 334 335 $link = $defaultlink; 336 getStateAndFaults($db, "all_labels", $selectedState, "fake", $str, $anyFaults); 337 write_table_cell($class, '%s', $anyFaults ? $link : "", $str); 338 339 $link = "warpFailedSkyfiles.php?pass=" . $pass . "&proj=" . $proj . "&warpRun.state=new"; 340 getStateAndFaults($db, "all_labels", $selectedState, "warp", $str, $anyFaults); 341 write_table_cell($class, '%s', $anyFaults ? $link : "", $str); 342 343 $link = "stackFailedSkyfile.php?pass=" . $pass . "&proj=" . $proj . "&stackRun.state=new"; 344 getStateAndFaults($db, "all_labels", $selectedState, "stack", $str, $anyFaults); 345 write_table_cell($class, '%s', $anyFaults ? $link : "", $str); 346 347 $link = "diffFailedSkyfile.php?pass=" . $pass . "&proj=" . $proj . "&diffRun.state=new"; 348 getStateAndFaults($db, "all_labels", $selectedState, "diff", $str, $anyFaults); 349 write_table_cell($class, '%s', $anyFaults ? $link : "", $str); 350 351 $link = $defaultlink; 352 getStateAndFaults($db, "all_labels", $selectedState, "magic", $str, $anyFaults); 353 write_table_cell($class, '%s', $anyFaults ? $link : "", $str); 354 355 $link = $defaultlink; 356 getStateAndFaults($db, "all_labels", $selectedState, "magicDS", $str, $anyFaults); 357 write_table_cell($class, '%s', $anyFaults ? $link : "", $str); 358 359 $link = $defaultlink; 360 getStateAndFaults($db, "all_labels", $selectedState, "dist", $str, $anyFaults); 361 write_table_cell($class, '%s', $anyFaults ? $link : "", $str); 362 339 write_table_cell($class, '%s', $link, "All $server labels"); 363 340 364 341 echo "</tr>\n"; … … 368 345 ########################################################################### 369 346 # 347 # Sets reverts status 348 # 349 ########################################################################### 350 function setRevertStatus($db, $stage, $reverting) { 351 352 $sql = "UPDATE reverts SET reverting = $reverting WHERE stage LIKE '$stage'"; 353 if ($debug) {echo "$sql<br>";} 354 355 $qry = $db->query($sql); 356 if (dberror($qry)) {echo "<b>error with $sql </b><br>\n";} 357 } 358 359 ########################################################################### 360 # 370 361 # Returns whether this stage is reverting or not 371 362 # … … 374 365 375 366 $anyFaults = false; 376 $sql = "SELECT reverting FROM $stage ORDER BY timestamp DESC LIMIT 1"; 367 368 $sql = "SELECT reverting FROM reverts WHERE stage LIKE '$stage'"; 377 369 if ($debug) {echo "$sql<br>";} 378 370 -
branches/eam_branches/ipp-20100621/ippMonitor/raw/ipp.imfiles.dat
r28794 r28980 25 25 26 26 menutop | menutop | plain | | 27 menutop | menutop | link | New failed chip | failedChipProcessedImfile.php 28 menutop | menutop | link | New failed cam | failedCamProcessedExp.php 29 menutop | menutop | link | New failed fake | failedFakeProcessedImfile.php 30 menutop | menutop | link | New failed warp | failedWarpSkyfiles.php 31 menutop | menutop | link | New failed stack | failedStackSkyfile.php 32 menutop | menutop | link | New failed diff | failedDiffSkyfile.php 33 menutop | menutop | link | New failed magic tree | failedMagicTrees.php 34 menutop | menutop | link | New failed magic node | failedMagicNodes.php 35 menutop | menutop | link | New failed magic mask | failedMagicMasks.php 36 37 menutop | menutop | plain | | 27 38 menulink | menuselect | link | Tables columns | columns_in_db.php 28 39 menulink | menuselect | link | Clean /tmp directory | cleanTmpDirectory.php -
branches/eam_branches/ipp-20100621/ippMonitor/scripts/czartool_revert.pl
r28794 r28980 5 5 use Getopt::Long; 6 6 7 my $server = undef;8 7 my $task = undef; 9 8 my $onoff = undef; 10 9 11 10 GetOptions ( 12 "server|s=s" => \$server,13 11 "task|t=s" => \$task, 14 12 "onoff|o=s" => \$onoff); 15 13 16 14 my $prob = 0; 17 if (!$server) {print "ERROR: need to define a server (-s)\n"; $prob=1;}18 15 if (!$task) {print "ERROR: need to define a task (-t)\n"; $prob=1;} 19 16 if ($prob) {exit;} 20 17 21 18 if ($task eq "cam") {$task = "camera";} 19 20 my $server = undef; 21 if ($task eq "destreak" or $task eq "dist") {$server = "distribution";} 22 else {$server = "stdscience";} 22 23 23 24 my $revert = undef; -
branches/eam_branches/ipp-20100621/ippMonitor/scripts/generate
r28794 r28980 648 648 foreach $word (@words) { 649 649 $fword = &parse_fieldname ($word); 650 #print "field: $word -> $fword\n";650 # print "field: $word -> $fword\n"; 651 651 push @outwords, $fword; 652 652 if ($word =~ m|^\$|) { … … 660 660 $opf{$name} = $outline; 661 661 662 #print "ops: $name : $ops{$name}\n";663 #print "opf: $name : $opf{$name}\n";662 # print "ops: $name : $ops{$name}\n"; 663 # print "opf: $name : $opf{$name}\n"; 664 664 665 665 return 1; -
branches/eam_branches/ipp-20100621/ippToPsps/perl/ippToPsps/Gpc1Db.pm
r28794 r28980 28 28 JOIN diffSkyfile USING (diff_id) 29 29 WHERE rawExp.exp_id = $expId AND camRun.magicked 30 31 30 SQL 32 31 … … 37 36 ########################################################################### 38 37 # 39 # Returns camera-stage smf files for this exposure 38 # Returns camera-stage smf file for this exposure as used in the provided DVO Db 39 # 40 ########################################################################### 41 sub getCameraStageSmfForThisDvoDb { 42 my ($self, $dvoDb, $expId) = @_; 43 44 my $query = $self->{_db}->prepare(<<SQL); 45 SELECT path_base 46 FROM camProcessedExp 47 JOIN addRun USING(cam_id) 48 JOIN camRun USING(cam_id) 49 JOIN chipRun USING(chip_id) 50 JOIN rawExp USING(exp_id) 51 WHERE addRun.dvodb LIKE '$dvoDb' 52 AND exp_id = $expId; 53 SQL 54 55 $query->execute; 56 return $query->fetchrow_array(); 57 } 58 59 ########################################################################### 60 # 61 # Returns latest processed camera-stage smf file for this exposure ID 40 62 # 41 63 ########################################################################### … … 64 86 ########################################################################### 65 87 # 66 # Returns a list of exposure IDs for this survey88 # Returns a list of exposure IDs in a given DVO database 67 89 # 68 90 ########################################################################### 69 sub getExposureListFrom Survey{70 my ($self, $ survey) = @_;91 sub getExposureListFromDvoDb { 92 my ($self, $dvoDb, $exposures) = @_; 71 93 72 94 my $query = $self->{_db}->prepare(<<SQL); 73 74 SELECT rawExp.exp_id, rawExp.exp_name, camRun.dist_group 75 FROM camRun, chipRun, rawExp 76 WHERE camRun.state = 'full' 77 AND camRun.chip_id = chipRun.chip_id 78 AND chipRun.exp_id = rawExp.exp_id 79 AND camRun.dist_group = '$survey' 80 GROUP BY rawExp.exp_id 81 ORDER BY rawExp.exp_id ASC; 95 SELECT exp_id, exp_name, camRun.dist_group 96 FROM addRun 97 JOIN camRun USING(cam_id) 98 JOIN chipRun USING(chip_id) 99 JOIN rawExp USING(exp_id) 100 WHERE addRun.dvodb LIKE '$dvoDb' 101 AND addRun.state = 'full' 102 ORDER BY exp_id ASC; 82 103 SQL 83 84 104 85 105 #AND rawExp.exp_id > 133887 … … 93 113 94 114 $query->execute; 95 return $query->fetchall_arrayref(); 115 ${$exposures} = $query->fetchall_arrayref(); 116 my $numOfExposures = scalar @{${$exposures}}; 117 if ($numOfExposures > 0) { 118 119 print "* Found $numOfExposures exposures in DVO Db '$dvoDb'\n"; 120 return 1; 121 } 122 123 print "* No exposures found in DVO Db '$dvoDb'\n"; 124 return 0; 96 125 } 97 126 98 127 ########################################################################### 99 128 # 100 # Returns info for this exposure ID 129 # Returns info for this exposure ID for given DVO Db 101 130 # 102 131 ########################################################################### 103 sub get ExposureListFromExpId{104 my ($self, $ expId) = @_;132 sub getSingleExposureFromDvoDb { 133 my ($self, $dvoDb, $expId, $exposures) = @_; 105 134 106 135 my $query = $self->{_db}->prepare(<<SQL); 107 SELECT DISTINCT rawExp.exp_id, rawExp.exp_name, dist_group 108 FROM rawExp, chipRun 109 WHERE chipRun.exp_id = rawExp.exp_id 110 AND rawExp.exp_id = $expId 136 SELECT exp_id, exp_name, camRun.dist_group 137 FROM addRun 138 JOIN camRun USING(cam_id) 139 JOIN chipRun USING(chip_id) 140 JOIN rawExp USING(exp_id) 141 WHERE addRun.dvodb LIKE '$dvoDb' 142 AND exp_id = $expId; 111 143 SQL 112 144 113 145 $query->execute; 114 return $query->fetchall_arrayref(); 146 147 ${$exposures} = $query->fetchall_arrayref(); 148 149 if (scalar @{${$exposures}} > 0) { 150 151 print "* Found exposure $expId in DVO Db '$dvoDb'\n"; 152 return 1; 153 } 154 155 print "* Exposure $expId NOT found in DVO Db '$dvoDb'\n"; 156 return 0; 115 157 } 116 158 117 118 119 159 1; -
branches/eam_branches/ipp-20100621/ippToPsps/perl/ippToPsps/IppToPspsDb.pm
r28794 r28980 8 8 use ippToPsps::MySQLDb; 9 9 our @ISA = qw(ippToPsps::MySQLDb); # inherits from MySQLDb 10 11 12 ########################################################################### 13 # 14 # Returns a list of batches that have been processed and loaded to datastore 15 # 16 ########################################################################### 17 sub getBatchList { 18 my ($self, $exposures, $fromTime, $toTime) = @_; 19 20 my $query = $self->{_db}->prepare(<<SQL); 21 SELECT created, exp_id, batch_id, survey_id, deleted 22 FROM batches 23 WHERE processed = 1 24 AND on_datastore = 1 25 AND created >= '$fromTime' 26 AND created <= '$toTime'; 27 SQL 28 29 # TODO remove date restriction 30 $query->execute; 31 ${$exposures} = $query->fetchall_arrayref(); 32 my $count = scalar @{${$exposures}}; 33 34 printf( "* Found %d batch%s\n", $count, ($count==1) ? "" : "es"); 35 return $count; 36 } 37 38 ########################################################################### 39 # 40 # Returns a info about one particular batch 41 # 42 ########################################################################### 43 sub getSingleBatch{ 44 my ($self, $batch_id, $exposures) = @_; 45 46 my $query = $self->{_db}->prepare(<<SQL); 47 SELECT created, exp_id, batch_id, survey_id, deleted 48 FROM batches 49 WHERE batch_id = $batch_id 50 AND processed = 1 51 AND on_datastore = 1; 52 SQL 53 54 $query->execute; 55 ${$exposures} = $query->fetchall_arrayref(); 56 my $count = scalar @{${$exposures}}; 57 58 printf( "* Found %d batch%s\n", $count, ($count==1) ? "" : "es"); 59 return $count; 60 } 10 61 11 62 ####################################################################################### … … 56 107 # 57 108 ######################################################################################## 58 sub updateDb { 59 my ($self, $batchId, $expId, $processed, $published, $totalDetections) = @_; 60 61 print "HJHJH '$batchId', '$expId', '$processed', '$published', '$totalDetections'\n"; 109 sub updateBatch { 110 my ($self, $batchId, $expId, $processed, $published, $totalDetections, $minObjId, $maxObjId) = @_; 111 112 if (!$minObjId) {$minObjId = -1;} 113 if (!$maxObjId) {$maxObjId = -1;} 62 114 63 115 if (!$totalDetections) {$totalDetections = -1;} … … 65 117 my $query = $self->{_db}->prepare(<<SQL); 66 118 UPDATE batches 67 SET processed = $processed, on_datastore = $published, total_detections = $totalDetections 119 SET 120 processed = $processed, 121 on_datastore = $published, 122 total_detections = $totalDetections, 123 min_obj_id = $minObjId, 124 max_obj_id = $maxObjId 68 125 WHERE batch_id = $batchId 69 126 AND exp_id = $expId; … … 84 141 SELECT COUNT(*) 85 142 FROM batches 86 WHERE exp_id = $expId 143 WHERE exp_id = $expId 144 AND created > '2010-08-12' 87 145 AND processed = 1; 88 146 SQL … … 102 160 # 103 161 ######################################################################################## 104 sub getNewBatchId{105 my ($self, $expId, $surveyType, $batchType ) = @_;162 sub createNewBatch { 163 my ($self, $expId, $surveyType, $batchType, $dvoDb, $datastoreProduct) = @_; 106 164 107 165 my $query = $self->{_db}->prepare(<<SQL); … … 118 176 $batchId++; 119 177 120 my$query = $self->{_db}->prepare(<<SQL);178 $query = $self->{_db}->prepare(<<SQL); 121 179 INSERT INTO batches 122 (batch_id, exp_id, survey_id, batch_type )180 (batch_id, exp_id, survey_id, batch_type, dvo_db, datastore_product) 123 181 VALUES 124 ($batchId, $expId, '$surveyType', '$batchType'); 125 182 ($batchId, $expId, '$surveyType', '$batchType', '$dvoDb', '$datastoreProduct'); 126 183 SQL 127 184 … … 133 190 } 134 191 192 ####################################################################################### 193 # 194 # Updates an existing database record to show datastore status 195 # 196 ####################################################################################### 197 sub setBatchAsDeleted { 198 my ($self,$batchId, $expId) = @_; 199 200 my $query = $self->{_db}->prepare(<<SQL); 201 UPDATE batches 202 SET deleted = 1 203 WHERE batch_id = $batchId 204 AND exp_id = $expId; 205 SQL 206 207 $query->execute; # TODO check response of these 208 } 209 210 ####################################################################################### 211 # 212 # Updates an existing database record with info from ODM 213 # 214 ####################################################################################### 215 sub updateODMStatus { 216 my ($self,$batchId, $expId, $loadedToOdm, $mergeWorthy, $mergeCompleted) = @_; 217 218 my $query = $self->{_db}->prepare(<<SQL); 219 UPDATE batches 220 SET loaded_to_ODM = $loadedToOdm, merge_worthy = $mergeWorthy, merged = $mergeCompleted 221 WHERE batch_id = $batchId 222 AND exp_id = $expId; 223 SQL 224 225 $query->execute; # TODO check response of these 226 } 227 228 229 135 230 ########################################################################### 136 231 # … … 142 237 143 238 my $currentRevision = -1; 144 my $latestRevision = 4;239 my $latestRevision = 6; 145 240 146 241 while ($currentRevision != $latestRevision) { 147 242 148 243 $currentRevision = $self->getRevision(); 149 if ($self->{_verbose}) {print "* Current revision = $currentRevision\n";}244 if ($self->{_verbose}) {print "* Current database revision = $currentRevision\n";} 150 245 151 246 if ($currentRevision == 0) {$self->createRevision_1();} … … 153 248 elsif ($currentRevision == 2) {$self->createRevision_3();} 154 249 elsif ($currentRevision == 3) {$self->createRevision_4();} 250 elsif ($currentRevision == 4) {$self->createRevision_5();} 251 elsif ($currentRevision == 5) {$self->createRevision_6();} 155 252 } 156 253 } … … 164 261 my ($self) = @_; 165 262 166 print "* Creating revision 1 of '$ dbname'\n";263 print "* Creating revision 1 of '$self->{_dbName}'\n"; 167 264 168 265 my $query = $self->{_db}->prepare(<<SQL); … … 175 272 $query->execute; 176 273 177 my$query = $self->{_db}->prepare(<<SQL);274 $query = $self->{_db}->prepare(<<SQL); 178 275 CREATE TABLE batches ( 179 276 batch_id BIGINT NOT NULL, … … 192 289 $query->execute; 193 290 194 setRevision(1);291 $self->setRevision(1); 195 292 } 196 293 … … 203 300 my ($self) = @_; 204 301 205 print "* Creating revision 2 of '$ dbname'\n";302 print "* Creating revision 2 of '$self->{_dbName}'\n"; 206 303 207 304 my $query = $self->{_db}->prepare(<<SQL); … … 211 308 $query->execute; 212 309 213 setRevision(2);310 $self->setRevision(2); 214 311 } 215 312 … … 222 319 my ($self) = @_; 223 320 224 print "* Creating revision 3 of '$ dbname'\n";321 print "* Creating revision 3 of '$self->{_dbName}'\n"; 225 322 226 323 my $query = $self->{_db}->prepare(<<SQL); … … 230 327 $query->execute; 231 328 232 setRevision(3);329 $self->setRevision(3); 233 330 } 234 331 … … 241 338 my ($self) = @_; 242 339 243 print "* Creating revision 4 of '$ dbname'\n";340 print "* Creating revision 4 of '$self->{_dbName}'\n"; 244 341 245 342 my $query = $self->{_db}->prepare(<<SQL); … … 249 346 $query->execute; 250 347 251 setRevision(4); 348 $self->setRevision(4); 349 } 350 351 ####################################################################################### 352 # 353 # Create revision 5 of the database 354 # 355 ####################################################################################### 356 sub createRevision_5 { 357 my ($self) = @_; 358 359 print "* Creating revision 5 of '$self->{_dbName}'\n"; 360 361 my $query = $self->{_db}->prepare(<<SQL); 362 CREATE INDEX batchesIndex ON batches (batch_id); 363 SQL 364 $query->execute; 365 366 $self->setRevision(5); 367 } 368 369 ####################################################################################### 370 # 371 # Create revision 6 of the database 372 # 373 ####################################################################################### 374 sub createRevision_6 { 375 my ($self) = @_; 376 377 print "* Creating revision 6 of '$self->{_dbName}'\n"; 378 379 my $query = $self->{_db}->prepare(<<SQL); 380 ALTER TABLE batches 381 ADD COLUMN dvo_db VARCHAR(50) DEFAULT "UNKNOWN", 382 ADD COLUMN datastore_product VARCHAR(50) DEFAULT "UNKNOWN", 383 ADD COLUMN min_obj_id BIGINT DEFAULT 0, 384 ADD COLUMN max_obj_id BIGINT DEFAULT 0 385 SQL 386 $query->execute; 387 388 $self->setRevision(6); 252 389 } 253 390 -
branches/eam_branches/ipp-20100621/ippToPsps/perl/ippToPsps_run.pl
r28794 r28980 6 6 use PS::IPP::Config 1.01 qw( :standard ); 7 7 use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt ); 8 use Pod::Usage qw( pod2usage );9 8 use IPC::Cmd 0.36 qw( can_run run ); 10 9 use File::Temp qw(tempfile); 11 10 use XML::LibXML; 11 use File::Basename; 12 12 13 13 # local classes 14 14 use ippToPsps::Gpc1Db; 15 15 use ippToPsps::IppToPspsDb; 16 use ippToPsps::Datastore; 16 17 17 18 # globals 18 19 my $camera = 'GPC1'; 19 20 my $batchType = undef; 20 my $survey = undef; 21 my $dvodb = undef; 21 my $dvoLocation = undef; 22 my $dvoDb = undef; 23 my $fullDvoPath = undef; 22 24 my $verbose = undef; 23 25 my $save_temps = undef; 24 my $no_update = undef;25 26 my $output = undef; 26 27 my $singleExpId = undef; … … 34 35 'output|o=s' => \$output, 35 36 'batch|b=s' => \$batchType, 36 'dvodb|d=s' => \$dvodb, 37 'survey|s=s' => \$survey, 37 'dvo|d=s' => \$fullDvoPath, 38 38 'expid|e=s' => \$singleExpId, 39 39 'product|p=s' => \$datastoreProduct, 40 40 'verbose|v' => \$verbose, 41 41 'save_temps|t' => \$save_temps, 42 'no-update|u' => \$no_update,43 42 'force|f' => \$force, 44 43 'tarnzip|z' => \$dontTarNZip, … … 49 48 print "* \n"; 50 49 if (@ARGV) { 51 print "* UNKNKOWN: option: @ARGV\n"; $quit=1;} 50 $quit=1; 51 print "* UNKNKOWN: option @ARGV\n"; 52 } 52 53 if (!defined $output) { 53 print "* REQUIRED: need to provide an output path: -o <path>\n"; $quit=1;} 54 $quit=1; 55 print "* REQUIRED: need to provide an output path -o <path>\n"; 56 } 54 57 if (!defined $batchType) { 55 print "* REQUIRED: need to define a batch type: -b <init|det|diff|stack>\n"; $quit=1;} 56 if (!defined $dvodb) { 57 print "* REQUIRED: need to provide a DVO Db path: -d <path>\n"; $quit=1;} 58 if (!defined $survey and !defined $singleExpId) { 59 print "* REQUIRED: need to provide a survey type: -s <ThreePi|STS|SAS|M31|MD01|MD02|etc> ***OR***\n"; 60 print "* an exposure ID -e <expID>\n"; $quit=1;} 58 $quit=1; 59 print "* REQUIRED: need to define a batch type -b <init|det|diff|stack>\n"; 60 } 61 if (!defined $fullDvoPath) { 62 $quit=1; 63 print "* REQUIRED: need to provide a DVO Db -d <pathToDVO>\n"; 64 } 65 if (!defined $singleExpId) { 66 67 print "* OPTIONAL: a single exposure ID -e <expID> (default = none)\n"; 68 } 61 69 if (!defined $datastoreProduct) { 62 print "* OPTIONAL: datastore product: -p <product>\n";} 70 71 print "* OPTIONAL: datastore product -p <product> (default = none, i.e. data will not be published)\n"; 72 } 63 73 if (!defined $verbose) { 64 print "* OPTIONAL: run in verbose mode: -v\n"; $verbose = 0;} 74 $verbose = 0; 75 print "* OPTIONAL: run in verbose mode -v (default = $verbose)\n"; 76 } 65 77 if (!defined $save_temps) { 66 print "* OPTIONAL: keep temp files: -t\n"; $save_temps = 0;}67 if (!defined $no_update) { 68 print "* OPTIONAL: don't update database: -u\n"; $no_update = 0;}78 $save_temps = 0; 79 print "* OPTIONAL: keep temp files -t (default = $save_temps)\n"; 80 } 69 81 if (!defined $force) { 70 print "* OPTIONAL: force if already processed : -f\n"; $force = 0;} 82 $force = 0; 83 print "* OPTIONAL: force if already processed -f (default = $force)\n"; 84 } 71 85 if (!defined $dontTarNZip) { 72 print "* OPTIONAL: don't tar and zip output : -z\n"; $dontTarNZip = 0;} 73 print "*\n*******************************************************************************\n"; 86 $dontTarNZip = 0; 87 print "* OPTIONAL: don't tar and zip output -z (default = $dontTarNZip)\n"; 88 } 89 print "*\n*******************************************************************************\n"; 74 90 75 91 if ($quit) { exit; } 92 93 # determine PSPS batch 'type' 94 my $pspsBatchType; 95 if ($batchType eq 'init') {$pspsBatchType = "IN";} 96 elsif ($batchType eq 'det') {$pspsBatchType = "P2";} 97 elsif ($batchType eq 'stack') {$pspsBatchType = "ST";} 98 elsif ($batchType eq 'diff') {$pspsBatchType = "OB";} 99 else {$pspsBatchType = "UNKNOWN";} 100 101 # spilt full DVO path into Db and path 102 $fullDvoPath =~ s/\/$//; # strip off trailing '\' 103 ($dvoDb, $dvoLocation) = fileparse($fullDvoPath); 76 104 77 105 my $gpc1Db = new ippToPsps::Gpc1Db("gpc1", "ippdb01", "ippuser", "ippuser", $verbose, $save_temps); 78 106 my $ippToPspsDb = new ippToPsps::IppToPspsDb("ippToPsps", "ippdb01", "ipp", "ipp", $verbose, $save_temps); 107 my $datastore = undef; 108 if ($datastoreProduct) {$datastore = new ippToPsps::Datastore($datastoreProduct, $verbose, $save_temps);} 79 109 80 110 # check we can run programs and get camera config 81 111 my $ippToPsps = can_run('ippToPsps') or (warn "Can't find 'ippToPsps' program" and exit($PS_EXIT_CONFIG_ERROR)); 82 my $dsreg = can_run('dsreg') or (warn "Can't find 'dsreg' program" and exit($PS_EXIT_CONFIG_ERROR));83 112 my $ipprc = PS::IPP::Config->new($camera) or (warn "Can't get camera configuration" and exit($PS_EXIT_CONFIG_ERROR)); 84 113 85 114 if ($batchType eq "init") {$initBatch = 1;} 86 115 else {$initBatch = 0;} 87 process(); 116 117 if (!process()) {print "* Finished unsuccessfully\n";} 118 else {print "* Finished successfully\n";} 88 119 89 120 ####################################################################################### … … 114 145 my ($resultsFile, $resultsFilePath) = tempfile( "/tmp/ippToPsps_results.XXXX", UNLINK => !$save_temps); 115 146 my $lastExpId = $ippToPspsDb->getLastExpId(); 116 my $ rows = undef;147 my $exposures; 117 148 118 149 my $query; 119 150 if ($initBatch) { 120 121 my @row = (0, 'NULL', 'ThreePi'); 122 @{$rows} = (\@row); 123 } 124 elsif ($singleExpId) { $rows = $gpc1Db->getExposureListFromExpId($singleExpId); } 125 else { $rows = $gpc1Db->getExposureListFromSurvey($survey); } 126 127 # TODO check if there are no exposures and give a warning 151 152 my @exposure = (0, 'NULL', 'ThreePi'); 153 @{$exposures} = (\@exposure); 154 } 155 # get single exposure 156 elsif ($singleExpId) { 157 158 if (!$gpc1Db->getSingleExposureFromDvoDb($dvoDb, $singleExpId, \$exposures)) {return 0;} 159 } 160 # get all exposures in this DVO Db 161 else { 162 163 if (!$gpc1Db->getExposureListFromDvoDb($dvoDb, \$exposures)) {return 0;} 164 } 128 165 129 166 my $batchId = 0; … … 132 169 133 170 #my $batchId = -1; 134 my $row; 135 foreach $row ( @{$rows} ) { 136 my ($expId, $expName, $distGroup) = @{$row}; 137 # print "JHGHGHGHGH2 $expId, $expName, $distGroup\n"; 138 139 # loop round exposures 140 #while (my @row = $query->fetchrow_array()) { 141 # my ($expId, $expName, $distGroup) = @row; 171 my $exposure; 172 foreach $exposure ( @{$exposures} ) { 173 my ($expId, $expName, $distGroup) = @{$exposure}; 142 174 143 175 if (!$initBatch && $ippToPspsDb->isExposureAlreadyProcessed($expId)) { 144 145 if ($force) {print "* Forcing....\n";}146 else {next};176 177 if ($force) {print "* Forcing....\n";} 178 else {next}; 147 179 } 148 180 … … 150 182 if (!$surveyType) {next;} 151 183 152 $batchId = $ippToPspsDb-> getNewBatchId($expId, $surveyType, $batchType);184 $batchId = $ippToPspsDb->createNewBatch($expId, $distGroup, $pspsBatchType, $dvoDb, (defined $datastore) ? $datastoreProduct : "NONE"); 153 185 154 186 # TODO quit here if no sensible batch ID … … 156 188 # generate batch path from batch IDs 157 189 my $batch = sprintf("B%08d", $batchId); 158 my $batchDir = sprintf("$output/$batch"); 190 my $dvoDir = "$output/$dvoDb"; 191 my $batchDir = "$dvoDir/$batch"; 192 193 # make directories 194 unless(-d $dvoDir) {mkdir($dvoDir, 0777);} 159 195 mkdir($batchDir, 0777); 196 160 197 $published = 0; 161 198 … … 171 208 if (writeBatchManifest($batchDir, $batch, $batchType, $surveyType, $filename, $minObjId, $maxObjId)) { 172 209 210 # tar n' zip 173 211 if (!$dontTarNZip) { 174 my $tarball = tarAndZipBatch($output, $batch); 175 if ($tarball && $datastoreProduct && publishToDatastore($batch, $output, $tarball)) {$published = 1;} 212 my $tarball = tarAndZipBatch($dvoDir, $batch); 213 214 # and publish 215 if ($tarball && defined $datastore ) { 216 217 $published = $datastore->register($batch, $dvoDir, $tarball, "IPP_PSPS", "tgz"); 218 } 176 219 } 177 220 } 178 221 179 $ippToPspsDb->update Db($batchId, $expId, 1, $published, $totalDetections);222 $ippToPspsDb->updateBatch($batchId, $expId, 1, $published, $totalDetections, $minObjId, $maxObjId); 180 223 } 181 224 … … 330 373 my $timeStamp = sprintf "%4d-%02d-%02d %02d:%02d:%02d", $year+1900,$mon+1,$mday,$hour,$min,$sec; 331 374 332 # determine batch 'type'333 my $type;334 if ($batchType eq 'init') {$type = "IN";}335 elsif ($batchType eq 'det') {$type = "P2";}336 elsif ($batchType eq 'stack') {$type = "ST";}337 elsif ($batchType eq 'diff') {$type = "OB";}338 else {$type = "UNKNOWN";}339 340 375 # create XML file 341 376 my $writer = new XML::Writer(OUTPUT => $output, DATA_MODE => 1, DATA_INDENT=>2); … … 372 407 $writer->startTag('manifest', 373 408 "name" => "$batch", 374 "type" => $ type,409 "type" => $pspsBatchType, 375 410 "survey" => $pspsSurvey, 376 411 "timestamp" => "$timeStamp", … … 382 417 $writer->startTag('manifest', 383 418 "name" => "$batch", 384 "type" => $ type,419 "type" => $pspsBatchType, 385 420 "timestamp" => "$timeStamp"); 386 421 } … … 404 439 405 440 ####################################################################################### 406 #407 # register new job with the datastore408 #409 ########################################################################################410 sub publishToDatastore {411 my ($batch, $path, $tarball) = @_;412 413 my ($tempFile, $tempName) = tempfile( "/tmp/ippToPsps_dsregList.XXXX", UNLINK => !$save_temps);414 415 print $tempFile $tarball . '|||tgz' . "\n";416 417 # build dsreg command command418 my $command = "$dsreg";419 $command .= " --add $batch";420 $command .= " --copy";421 $command .= " --datapath $path";422 $command .= " --type IPP_PSPS";423 $command .= " --product $datastoreProduct";424 $command .= " --list $tempName";425 426 # run command427 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =428 run(command => $command, verbose => $verbose);429 430 if (!$success) { print "* Unable to publish $tarball to datastore\n" and return 0 };431 432 print "* Successfully published $tarball to datastore\n";433 434 close($tempFile);435 436 return 1;437 }438 439 #######################################################################################440 441 # 441 442 # runs ippToPsps to produce init batch … … 457 458 my ($expId, $expName, $surveyType, $outputPath, $resultsFilePath) = @_; 458 459 459 my $nebPath = $gpc1Db->getCameraStageSmf ($expId);460 my $nebPath = $gpc1Db->getCameraStageSmfForThisDvoDb($dvoDb, $expId); 460 461 if (!$nebPath) { return 0; } 461 462 … … 527 528 $command .= " -input $input"; 528 529 $command .= " -output $output"; 529 $command .= " -D CATDIR $ dvodb";530 $command .= " -D CATDIR $fullDvoPath"; 530 531 $command .= " -config ../config"; # TODO 531 $command .= " -expid $expid";532 $command .= " -expid $expid"; 532 533 $command .= " -expname $expName"; 533 534 $command .= " -survey $surveyType"; -
branches/eam_branches/ipp-20100621/ippTools/share/Makefile.am
r28794 r28980 6 6 addtool_checkminidvodbaddrun.sql \ 7 7 addtool_donecleanup.sql \ 8 addtool_find_cam_id_dvo.sql \ 8 9 addtool_find_cam_id.sql \ 9 10 addtool_find_pendingexp.sql \ … … 26 27 bgtool_definechip.sql \ 27 28 bgtool_definewarp.sql \ 29 bgtool_listchip.sql \ 30 bgtool_listwarp.sql \ 28 31 bgtool_revertchip.sql \ 29 32 bgtool_revertwarp.sql \ … … 150 153 disttool_definebyquery_fake.sql \ 151 154 disttool_definebyquery_raw.sql \ 155 disttool_definebyquery_sky.sql \ 152 156 disttool_definebyquery_stack.sql \ 153 157 disttool_definebyquery_warp.sql \ … … 163 167 disttool_pending_fake.sql \ 164 168 disttool_pending_raw.sql \ 169 disttool_pending_sky.sql \ 165 170 disttool_pending_stack.sql \ 166 171 disttool_pending_warp.sql \ … … 172 177 disttool_processedcomponent.sql \ 173 178 disttool_queuercrun.sql \ 179 disttool_rerun_select.sql \ 174 180 disttool_revertrcrun.sql \ 175 181 disttool_revertrun.sql \ … … 324 330 staticskytool_definebyquery_select.sql \ 325 331 staticskytool_definebyquery_inputs.sql \ 332 staticskytool_export_run.sql \ 333 staticskytool_export_input.sql \ 334 staticskytool_export_result.sql \ 326 335 staticskytool_inputs.sql \ 327 336 staticskytool_todo.sql \ -
branches/eam_branches/ipp-20100621/ippTools/share/chiptool_setimfiletoupdate.sql
r28022 r28980 5 5 AND component = class_id) 6 6 SET chipRun.state = 'update', 7 chipProcessedImfile.data_state = 'update' 7 chipProcessedImfile.data_state = 'update', 8 chipProcessedImfile.fault = 0 8 9 -- set hook %s 9 10 WHERE chip_id = %lld -
branches/eam_branches/ipp-20100621/ippTools/share/disttool_toadvance.sql
r28794 r28980 240 240 AND distComponent.fault = 0 241 241 UNION 242 -- staticsky stage 243 -- NOTE this assumes that there is only one component per staticskyRun 244 -- (one skycell) 245 SELECT 246 distRun.dist_id, 247 stage, 248 stage_id, 249 outroot, 250 label, 251 clean 252 FROM distRun 253 JOIN staticskyResult on stage_id = sky_id 254 LEFT JOIN distComponent 255 ON distRun.dist_id = distComponent.dist_id 256 WHERE 257 distRun.state = 'new' 258 AND distRun.fault = 0 259 AND distRun.stage = 'sky' 260 AND distComponent.component IS NOT NULL 261 AND distComponent.fault = 0 262 UNION 242 263 -- SSdiff stage 243 264 SELECT -
branches/eam_branches/ipp-20100621/ippTools/share/magicdstool_torevert_chip.sql
r27945 r28980 2 2 magic_ds_id, 3 3 magicDSRun.state, 4 exp_id,4 rawExp.exp_id, 5 5 re_place, 6 6 camera, … … 19 19 JOIN camProcessedExp using(cam_id) 20 20 JOIN chipRun ON (stage_id = chipRun.chip_id) 21 -- JOIN chipProcessedImfile ON (stage_id = chipProcessedImfile.chip_id AND component = class_id) 22 JOIN chipProcessedImfile USING(chip_id, exp_id) 23 JOIN rawExp using(exp_id) 21 JOIN chipProcessedImfile ON (stage_id = chipProcessedImfile.chip_id AND component = class_id) 22 JOIN rawExp ON chipRun.exp_id = rawExp.exp_id 24 23 WHERE magicDSRun.stage = 'chip' 25 24 AND ((magicDSRun.state = 'new' AND magicDSFile.fault > 0) -
branches/eam_branches/ipp-20100621/ippTools/share/pxadmin_create_tables.sql
r28794 r28980 987 987 projection_cell VARCHAR(64) NOT NULL, 988 988 path_base VARCHAR(255) NOT NULL, 989 PRIMARY KEY(warp_id), 990 KEY(projection_cell), 989 PRIMARY KEY(warp_id, projection_cell), 991 990 FOREIGN KEY(warp_id) REFERENCES warpRun(warp_id) 992 991 ) ENGINE=innodb DEFAULT CHARSET=latin1; … … 1086 1085 projection_cell VARCHAR(64) NOT NULL, 1087 1086 path_base VARCHAR(255) NOT NULL, 1088 PRIMARY KEY(sass_id), 1089 KEY(projection_cell), 1087 PRIMARY KEY(sass_id, projection_cell), 1090 1088 FOREIGN KEY(sass_id) REFERENCES stackAssociation(sass_id) 1091 1089 ) ENGINE=innodb DEFAULT CHARSET=latin1; … … 1192 1190 projection_cell VARCHAR(64) NOT NULL, 1193 1191 path_base VARCHAR(255) NOT NULL, 1194 PRIMARY KEY(diff_id), 1195 KEY(projection_cell), 1192 PRIMARY KEY(diff_id, projection_cell), 1196 1193 FOREIGN KEY(diff_id) REFERENCES diffRun(diff_id) 1197 1194 ) ENGINE=innodb DEFAULT CHARSET=latin1; -
branches/eam_branches/ipp-20100621/ippTools/share/staticskytool_result.sql
r28091 r28980 1 SELECT 1 SELECT DISTINCT 2 2 staticskyResult.*, 3 3 staticskyRun.state, 4 staticskyRun.tess_id,5 staticskyRun.skycell_id,6 staticskyRun.filter,7 4 staticskyRun.workdir, 8 5 staticskyRun.label, 6 stackRun.tess_id, 7 stackRun.skycell_id, 8 stackRun.filter 9 9 FROM staticskyRun 10 JOIN staticskyResult 11 USING(stack_id) 10 JOIN staticskyResult USING(sky_id) 11 JOIN staticskyInput USING(sky_id) 12 JOIN stackRun using(stack_id) -
branches/eam_branches/ipp-20100621/ippTools/src/addtool.c
r28295 r28980 144 144 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 145 145 146 147 148 // find the cam_id of all the exposures that we want to queue up.149 psString bare_query = pxDataGet("addtool_find_cam_id.sql");150 if (!bare_query) {151 psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement");152 psFree(where);153 return false;154 }155 156 146 // prevent queueing an addRun if a given exposure has already been added to 157 147 // the given dvo database 158 148 psString dvodb_string = NULL; 149 psString bare_query = NULL; 159 150 if (dvodb) { 160 // user supplied dvodb 161 psStringAppend(&dvodb_string, "(previous_dvodb = '%s')", dvodb); 151 psTrace("addtool.c", PS_LOG_INFO, "dvodb argument found (%s) using addtool_find_cam_id_dvo.sql\n", dvodb); 152 // find the cam_id of all the exposures that we want to queue up. 153 bare_query = pxDataGet("addtool_find_cam_id_dvo.sql"); 154 // user supplied dvodb 155 psStringAppend(&dvodb_string, "addRun.dvodb = '%s'", dvodb); 162 156 } else { 157 psTrace("addtool.c", PS_LOG_INFO, "dvodb argument not found using addtool_find_cam_id.sql\n"); 158 // find the cam_id of all the exposures that we want to queue up. 159 bare_query = pxDataGet("addtool_find_cam_id.sql"); 163 160 // inherit dvodb from camRun, avoid matching NULL 164 161 psStringAppend(&dvodb_string, "(camRun.dvodb IS NOT NULL AND previous_dvodb = camRun.dvodb)"); 162 } 163 if (!bare_query) { 164 psError(PXTOOLS_ERR_SYS, false, "failed to retrieve SQL statement"); 165 psFree(where); 166 return false; 165 167 } 166 168 // Take the bare query and add the dvodb selector -
branches/eam_branches/ipp-20100621/ippTools/src/bgtool.c
r28794 r28980 39 39 static bool advancechipMode(pxConfig *config); 40 40 static bool revertchipMode(pxConfig *config); 41 static bool listchipMode(pxConfig *config); 41 42 static bool definewarpMode(pxConfig *config); 42 43 static bool updatewarpMode(pxConfig *config); … … 47 48 static bool advancewarpMode(pxConfig *config); 48 49 static bool revertwarpMode(pxConfig *config); 50 static bool listwarpMode(pxConfig *config); 49 51 static bool tocleanchipMode(pxConfig *config); 50 52 static bool cleanedchipMode(pxConfig *config); … … 100 102 MODECASE(BGTOOL_MODE_ADVANCECHIP, advancechipMode); 101 103 MODECASE(BGTOOL_MODE_REVERTCHIP, revertchipMode); 104 MODECASE(BGTOOL_MODE_LISTCHIP, listchipMode); 102 105 MODECASE(BGTOOL_MODE_DEFINEWARP, definewarpMode); 103 106 MODECASE(BGTOOL_MODE_UPDATEWARP, updatewarpMode); … … 108 111 MODECASE(BGTOOL_MODE_ADVANCEWARP, advancewarpMode); 109 112 MODECASE(BGTOOL_MODE_REVERTWARP, revertwarpMode); 113 MODECASE(BGTOOL_MODE_LISTWARP, listwarpMode); 110 114 MODECASE(BGTOOL_MODE_TOCLEANCHIP, tocleanchipMode); 111 115 MODECASE(BGTOOL_MODE_CLEANEDCHIP, cleanedchipMode); … … 907 911 int numDeleted = psDBAffectedRows(config->dbh); 908 912 psLogMsg("bgtool", PS_LOG_INFO, "Deleted %d chipBackgroundImfiles", numDeleted); 913 914 return true; 915 } 916 static bool listchipMode(pxConfig *config) 917 { 918 PS_ASSERT_PTR_NON_NULL(config, false); 919 920 psMetadata *where = psMetadataAlloc(); 921 PXOPT_COPY_S64(config->args, where, "-chip_bg_id", "chipBackgroundRun.chip_bg_id", "=="); 922 PXOPT_COPY_STR(config->args, where, "-class_id", "chipProcessedImfile.class_id", "=="); 923 924 // chip_bg_id is required 925 PXOPT_LOOKUP_S64(chip_bg_id, config->args, "-chip_bg_id", true, false); 926 927 PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false); 928 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 929 930 psString query = pxDataGet("bgtool_listchip.sql"); 931 if (!query) { 932 psError(psErrorCodeLast(), false, "failed to retreive SQL statement"); 933 return false; 934 } 935 936 psString whereStr = psStringCopy(""); 937 psString whereClause = psDBGenerateWhereConditionSQL(where, NULL); 938 psStringAppend(&query, "\nWHERE %s", whereClause); 939 psFree(whereClause); 940 psFree(where); 941 942 if (limit) { 943 psString limitString = psDBGenerateLimitSQL(limit); 944 psStringAppend(&query, " %s", limitString); 945 psFree(limitString); 946 } 947 948 if (!p_psDBRunQuery(config->dbh, query)) { 949 psError(psErrorCodeLast(), false, "database error"); 950 psFree(query); 951 return false; 952 } 953 psFree(whereStr); 954 psFree(query); 955 956 psArray *output = p_psDBFetchResult(config->dbh); 957 if (!output) { 958 psError(psErrorCodeLast(), false, "Unable to fetch result of query %s", query); 959 return false; 960 } 961 if (!psArrayLength(output)) { 962 psTrace("bgtool", PS_LOG_INFO, "no rows found"); 963 psFree(output); 964 return true; 965 } 966 967 if (psArrayLength(output)) { 968 if (!ippdbPrintMetadatas(stdout, output, "chipProcessedImfile", !simple)) { 969 psError(psErrorCodeLast(), false, "failed to print array"); 970 psFree(output); 971 return false; 972 } 973 } 974 975 psFree(output); 909 976 910 977 return true; … … 1686 1753 return true; 1687 1754 } 1755 static bool listwarpMode(pxConfig *config) 1756 { 1757 PS_ASSERT_PTR_NON_NULL(config, false); 1758 1759 psMetadata *where = psMetadataAlloc(); 1760 PXOPT_COPY_S64(config->args, where, "-warp_bg_id", "warpBackgroundRun.warp_bg_id", "=="); 1761 PXOPT_COPY_STR(config->args, where, "-skycell_id", "warpSkyfile.skycell_id", "=="); 1762 1763 PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false); 1764 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 1765 1766 psString query = pxDataGet("bgtool_listwarp.sql"); 1767 if (!query) { 1768 psError(psErrorCodeLast(), false, "failed to retreive SQL statement"); 1769 return false; 1770 } 1771 1772 psString whereStr = psStringCopy(""); 1773 psString whereClause = psDBGenerateWhereConditionSQL(where, NULL); 1774 psStringAppend(&query, "\nWHERE %s", whereClause); 1775 psFree(whereClause); 1776 psFree(where); 1777 1778 if (limit) { 1779 psString limitString = psDBGenerateLimitSQL(limit); 1780 psStringAppend(&query, " %s", limitString); 1781 psFree(limitString); 1782 } 1783 1784 if (!p_psDBRunQuery(config->dbh, query)) { 1785 psError(psErrorCodeLast(), false, "database error"); 1786 psFree(query); 1787 return false; 1788 } 1789 psFree(whereStr); 1790 psFree(query); 1791 1792 psArray *output = p_psDBFetchResult(config->dbh); 1793 if (!output) { 1794 psError(psErrorCodeLast(), false, "Unable to fetch result of query %s", query); 1795 return false; 1796 } 1797 if (!psArrayLength(output)) { 1798 psTrace("bgtool", PS_LOG_INFO, "no rows found"); 1799 psFree(output); 1800 return true; 1801 } 1802 1803 if (psArrayLength(output)) { 1804 if (!ippdbPrintMetadatas(stdout, output, "warpSkyfile", !simple)) { 1805 psError(psErrorCodeLast(), false, "failed to print array"); 1806 psFree(output); 1807 return false; 1808 } 1809 } 1810 1811 psFree(output); 1812 1813 return true; 1814 } 1688 1815 1689 1816 static bool tocleanwarpMode(pxConfig *config) -
branches/eam_branches/ipp-20100621/ippTools/src/bgtool.h
r28794 r28980 34 34 BGTOOL_MODE_ADVANCECHIP, 35 35 BGTOOL_MODE_REVERTCHIP, 36 BGTOOL_MODE_LISTCHIP, 36 37 // Warp stage 37 38 BGTOOL_MODE_DEFINEWARP, … … 43 44 BGTOOL_MODE_ADVANCEWARP, 44 45 BGTOOL_MODE_REVERTWARP, 46 BGTOOL_MODE_LISTWARP, 45 47 // Cleanups 46 48 BGTOOL_MODE_TOCLEANCHIP, -
branches/eam_branches/ipp-20100621/ippTools/src/bgtoolConfig.c
r28794 r28980 184 184 psMetadataAddS16(revertchipArgs, PS_LIST_TAIL, "-fault", 0, "search by fault code", 0); 185 185 psMetadataAddBool(revertchipArgs, PS_LIST_TAIL, "-all", 0, "allow everything to be queued without search terms", false); 186 187 // -listchip 188 psMetadata *listchipArgs = psMetadataAlloc(); 189 psMetadataAddS64(listchipArgs, PS_LIST_TAIL, "-chip_bg_id", 0, "search by chip_bg_id (required)", 0); 190 psMetadataAddStr(listchipArgs, PS_LIST_TAIL, "-class_id", 0, "search by class_id", NULL); 191 psMetadataAddBool(listchipArgs, PS_LIST_TAIL, "-simple", 0, "use the simple output format", false); 192 psMetadataAddU64(listchipArgs, PS_LIST_TAIL, "-limit", 0, "limit result set to N items", 0); 186 193 187 194 // -tocleanchip … … 347 354 psMetadataAddBool(revertwarpArgs, PS_LIST_TAIL, "-all", 0, "allow everything to be queued without search terms", false); 348 355 356 // -listwarp 357 psMetadata *listwarpArgs = psMetadataAlloc(); 358 psMetadataAddS64(listwarpArgs, PS_LIST_TAIL, "-warp_bg_id", 0, "search by warp_bg_id (required)", 0); 359 psMetadataAddStr(listwarpArgs, PS_LIST_TAIL, "-skycell_id", 0, "search by skycell_id", NULL); 360 psMetadataAddBool(listwarpArgs, PS_LIST_TAIL, "-simple", 0, "use the simple output format", false); 361 psMetadataAddU64(listwarpArgs, PS_LIST_TAIL, "-limit", 0, "limit result set to N items", 0); 362 349 363 // -tocleanwarp 350 364 psMetadata *tocleanwarpArgs = psMetadataAlloc(); … … 382 396 PXOPT_ADD_MODE("-advancechip", "", BGTOOL_MODE_ADVANCECHIP, advancechipArgs); 383 397 PXOPT_ADD_MODE("-revertchip", "", BGTOOL_MODE_REVERTCHIP, revertchipArgs); 398 PXOPT_ADD_MODE("-listchip", "", BGTOOL_MODE_LISTCHIP, listchipArgs); 384 399 PXOPT_ADD_MODE("-tocleanchip", "", BGTOOL_MODE_TOCLEANCHIP, tocleanchipArgs); 385 400 PXOPT_ADD_MODE("-cleanedchip", "", BGTOOL_MODE_CLEANEDCHIP, cleanedchipArgs); … … 395 410 PXOPT_ADD_MODE("-advancewarp", "", BGTOOL_MODE_ADVANCEWARP, advancewarpArgs); 396 411 PXOPT_ADD_MODE("-revertwarp", "", BGTOOL_MODE_REVERTWARP, revertwarpArgs); 412 PXOPT_ADD_MODE("-listwarp", "", BGTOOL_MODE_LISTWARP, listwarpArgs); 397 413 PXOPT_ADD_MODE("-tocleanwarp", "", BGTOOL_MODE_TOCLEANWARP, tocleanwarpArgs); 398 414 PXOPT_ADD_MODE("-cleanedwarp", "", BGTOOL_MODE_CLEANEDWARP, cleanedwarpArgs); -
branches/eam_branches/ipp-20100621/ippTools/src/disttool.c
r28794 r28980 34 34 static bool updaterunMode(pxConfig *config); 35 35 static bool revertrunMode(pxConfig *config); 36 static bool rerunMode(pxConfig *config); 36 37 static bool pendingcomponentMode(pxConfig *config); 37 38 static bool addprocessedcomponentMode(pxConfig *config); … … 83 84 MODECASE(DISTTOOL_MODE_UPDATERUN, updaterunMode); 84 85 MODECASE(DISTTOOL_MODE_REVERTRUN, revertrunMode); 86 MODECASE(DISTTOOL_MODE_RERUN, rerunMode); 85 87 MODECASE(DISTTOOL_MODE_PENDINGCOMPONENT, pendingcomponentMode); 86 88 MODECASE(DISTTOOL_MODE_ADDPROCESSEDCOMPONENT, addprocessedcomponentMode); … … 327 329 // stack stage doesn't require magic 328 330 no_magic = true; 331 } else if (!strcmp(stage, "sky")) { 332 magicRunType = "staticskyRun"; 333 query = pxDataGet("disttool_definebyquery_sky.sql"); 334 if (!query) { 335 psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement"); 336 psFree(where); 337 return false; 338 } 339 340 if (label) { 341 psStringAppend(&query, " AND (staticskyRun.label = '%s')", label); 342 } 343 if (dist_group) { 344 psStringAppend(&query, " AND (sticskyRun.dist_group = '%s')", dist_group); 345 } 346 // (static)sky stage doesn't require magic 347 no_magic = true; 329 348 } else if (!strcmp(stage, "SSdiff")) { 330 349 magicRunType = "diffRun"; … … 587 606 } 588 607 608 static bool rerunMode(pxConfig *config) 609 { 610 psMetadata *where = psMetadataAlloc(); 611 PXOPT_COPY_S64(config->args, where, "-dist_id", "distRun.dist_id", "=="); 612 PXOPT_COPY_STR(config->args, where, "-stage", "stage", "==");; 613 PXOPT_COPY_S64(config->args, where, "-stage_id", "stage_id", "=="); 614 PXOPT_COPY_STR(config->args, where, "-label", "label", "=="); 615 PXOPT_COPY_STR(config->args, where, "-data_group", "data_group", "=="); 616 617 // require data_group or dist_id to be supplied 618 PXOPT_LOOKUP_STR(data_group, config->args, "-data_group", true, false); 619 PXOPT_LOOKUP_S64(dist_id, config->args, "-dist_id", false, false); 620 if (!data_group && !dist_id) { 621 psError(PXTOOLS_ERR_CONFIG, true, "data_group or dist_id is required"); 622 return false; 623 } 624 PXOPT_LOOKUP_STR(set_label, config->args, "-set_label", false, false); 625 626 psString label_hook = psStringCopy(""); 627 if (set_label) { 628 psStringAppend(&label_hook, ", label = '%s'", set_label); 629 } 630 631 PXOPT_LOOKUP_BOOL(pretend, config->args, "-pretend", false); 632 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 633 PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false); 634 635 636 // It might be useful to be able to query by the parameters of the underlying runs 637 638 if (!psListLength(where->list)) { 639 psFree(where); 640 psError(PXTOOLS_ERR_CONFIG, false, "search parameters are required"); 641 return false; 642 } 643 644 psString query = pxDataGet("disttool_rerun_select.sql"); 645 if (!query) { 646 psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement"); 647 if (!psDBRollback(config->dbh)) { 648 psError(PS_ERR_UNKNOWN, false, "database error"); 649 } 650 return false; 651 } 652 653 if (psListLength(where->list)) { 654 psString whereClause = psDBGenerateWhereConditionSQL(where, NULL); 655 psStringAppend(&query, " AND %s", whereClause); 656 psFree(whereClause); 657 } 658 psFree(where); 659 660 if (limit) { 661 psString limitString = psDBGenerateLimitSQL(limit); 662 psStringAppend(&query, " %s", limitString); 663 psFree(limitString); 664 } 665 666 if (!p_psDBRunQuery(config->dbh, query)) { 667 psError(PS_ERR_UNKNOWN, false, "database error"); 668 psFree(query); 669 return false; 670 } 671 psFree(query); 672 673 psArray *output = p_psDBFetchResult(config->dbh); 674 if (!output) { 675 psError(PS_ERR_UNKNOWN, false, "database error"); 676 return false; 677 } 678 if (!psArrayLength(output)) { 679 psTrace("disttool", PS_LOG_INFO, "no rows found"); 680 psFree(output); 681 return true; 682 } 683 684 685 if (pretend) { 686 if (!ippdbPrintMetadatas(stdout, output, "distRunsToUpdate", true)) { 687 psError(PS_ERR_UNKNOWN, false, "failed to print array"); 688 psFree(output); 689 return false; 690 } 691 psFree(output); 692 return true; 693 } 694 695 query = "DELETE FROM distComponent where dist_id = %" PRId64; 696 697 for (long i=0; i < psArrayLength(output); i++) { 698 psMetadata *md = output->data[i]; 699 psS64 dist_id = psMetadataLookupS64(NULL, md, "dist_id"); 700 701 if (!psDBTransaction(config->dbh)) { 702 psError(PS_ERR_UNKNOWN, false, "database error"); 703 return false; 704 } 705 706 if (!p_psDBRunQueryF(config->dbh, query, dist_id)) { 707 psError(PS_ERR_UNKNOWN, false, "database error"); 708 psFree(query); 709 if (!psDBRollback(config->dbh)) { 710 psError(PS_ERR_UNKNOWN, false, "database error"); 711 } 712 return false; 713 } 714 715 if (!p_psDBRunQueryF(config->dbh, 716 "UPDATE distRun SET state = 'new', fault=0 %s WHERE dist_id =%" PRId64, 717 label_hook, dist_id)) { 718 psError(PS_ERR_UNKNOWN, false, "database error"); 719 psFree(query); 720 if (!psDBRollback(config->dbh)) { 721 psError(PS_ERR_UNKNOWN, false, "database error"); 722 } 723 return false; 724 } 725 if (!psDBCommit(config->dbh)) { 726 psError(PS_ERR_UNKNOWN, false, "database error"); 727 return false; 728 } 729 printf("re-running distRun %" PRId64 "\n", dist_id); 730 } 731 732 psFree(output); 733 734 return true; 735 } 589 736 static bool revertrunMode(pxConfig *config) 590 737 { -
branches/eam_branches/ipp-20100621/ippTools/src/disttool.h
r26193 r28980 28 28 DISTTOOL_MODE_UPDATERUN, 29 29 DISTTOOL_MODE_REVERTRUN, 30 DISTTOOL_MODE_RERUN, 30 31 DISTTOOL_MODE_PENDINGCOMPONENT, 31 32 DISTTOOL_MODE_ADDPROCESSEDCOMPONENT, -
branches/eam_branches/ipp-20100621/ippTools/src/disttoolConfig.c
r28259 r28980 85 85 psMetadataAddS16(updaterunArgs, PS_LIST_TAIL, "-fault", 0, "define fault code", 0); 86 86 87 // -rerun 88 psMetadata *rerunArgs = psMetadataAlloc(); 89 psMetadataAddStr(rerunArgs, PS_LIST_TAIL, "-data_group", 0, "define data_group (required)", NULL); 90 psMetadataAddS64(rerunArgs, PS_LIST_TAIL, "-dist_id", 0, "search by dist_id", 0); 91 psMetadataAddStr(rerunArgs, PS_LIST_TAIL, "-stage", 0, "search by stage", NULL); 92 psMetadataAddS64(rerunArgs, PS_LIST_TAIL, "-stage_id", 0, "search by stage_id", 0); 93 psMetadataAddStr(rerunArgs, PS_LIST_TAIL, "-label", 0, "search by label", NULL); 94 psMetadataAddStr(rerunArgs, PS_LIST_TAIL, "-set_label", 0, "define new label", NULL); 95 psMetadataAddBool(rerunArgs, PS_LIST_TAIL, "-pretend", 0, "don't queue runs just display what would be selected", false); 96 psMetadataAddU64(rerunArgs, PS_LIST_TAIL, "-limit", 0, "limit result set to N items", 0); 97 psMetadataAddBool(rerunArgs, PS_LIST_TAIL, "-simple", 0, "use the simple output format", false); 98 87 99 // -revertrun 88 100 psMetadata *revertrunArgs = psMetadataAlloc(); … … 327 339 psMetadata *modes = psMetadataAlloc(); 328 340 329 PXOPT_ADD_MODE("-definebyquery", "", DISTTOOL_MODE_DEFINEBYQUERY, definebyqueryArgs); 330 PXOPT_ADD_MODE("-updaterun", "", DISTTOOL_MODE_UPDATERUN, updaterunArgs); 331 PXOPT_ADD_MODE("-revertrun", "", DISTTOOL_MODE_REVERTRUN, revertrunArgs); 341 PXOPT_ADD_MODE("-definebyquery", "define distribution run", DISTTOOL_MODE_DEFINEBYQUERY, definebyqueryArgs); 342 PXOPT_ADD_MODE("-updaterun", "update distRun", DISTTOOL_MODE_UPDATERUN, updaterunArgs); 343 PXOPT_ADD_MODE("-rerun", "reprocess a cleaned distribution run", DISTTOOL_MODE_RERUN, rerunArgs); 344 PXOPT_ADD_MODE("-revertrun", "revert distRun.faults", DISTTOOL_MODE_REVERTRUN, revertrunArgs); 332 345 PXOPT_ADD_MODE("-pendingcomponent", "", DISTTOOL_MODE_PENDINGCOMPONENT, pendingcomponentArgs); 333 346 PXOPT_ADD_MODE("-addprocessedcomponent", "", DISTTOOL_MODE_ADDPROCESSEDCOMPONENT, addprocessedcomponentArgs); 334 PXOPT_ADD_MODE("-revertcomponent", " ", DISTTOOL_MODE_REVERTCOMPONENT, revertcomponentArgs);347 PXOPT_ADD_MODE("-revertcomponent", "revert faulted components", DISTTOOL_MODE_REVERTCOMPONENT, revertcomponentArgs); 335 348 PXOPT_ADD_MODE("-processedcomponent", "", DISTTOOL_MODE_PROCESSEDCOMPONENT, processedcomponentArgs); 336 349 PXOPT_ADD_MODE("-toadvance", "", DISTTOOL_MODE_TOADVANCE, toadvanceArgs); … … 340 353 PXOPT_ADD_MODE("-updatefileset", "", DISTTOOL_MODE_UPDATEFILESET, updatefilesetArgs); 341 354 PXOPT_ADD_MODE("-listfilesets", "", DISTTOOL_MODE_LISTFILESETS, listfilesetsArgs); 342 PXOPT_ADD_MODE("-revertfileset", " ", DISTTOOL_MODE_REVERTFILESET, revertfilesetArgs);355 PXOPT_ADD_MODE("-revertfileset", "revert faulted filesets", DISTTOOL_MODE_REVERTFILESET, revertfilesetArgs); 343 356 PXOPT_ADD_MODE("-queuercrun", "", DISTTOOL_MODE_QUEUERCRUN, queuercrunArgs); 344 357 PXOPT_ADD_MODE("-updatercrun", "", DISTTOOL_MODE_UPDATERCRUN, updatercrunArgs); -
branches/eam_branches/ipp-20100621/ippTools/src/magicdstool.c
r28794 r28980 613 613 PXOPT_COPY_S64(config->args, where, "-magic_ds_id", "magicDSRun.magic_ds_id", "=="); 614 614 PXOPT_COPY_S64(config->args, where, "-magic_id", "magic_id", "=="); 615 PXOPT_COPY_S64(config->args, where, "-stage_id", "stage_id", "=="); 615 616 pxAddLabelSearchArgs (config, where, "-label", "magicDSRun.label", "=="); 616 617 -
branches/eam_branches/ipp-20100621/ippTools/src/magicdstoolConfig.c
r28794 r28980 120 120 psMetadataAddS64(todestreakArgs, PS_LIST_TAIL, "-magic_ds_id", 0, "search by magic Destreak ID", 0); 121 121 psMetadataAddS64(todestreakArgs, PS_LIST_TAIL, "-magic_id", 0, "search by magic ID", 0); 122 psMetadataAddS64(todestreakArgs, PS_LIST_TAIL, "-stage_id", 0, "search by stage ID", 0); 122 123 psMetadataAddStr(todestreakArgs, PS_LIST_TAIL, "-label", PS_META_DUPLICATE_OK, "define label", NULL); 123 124 psMetadataAddU64(todestreakArgs, PS_LIST_TAIL, "-limit", 0, "limit result set to N items", 0); -
branches/eam_branches/ipp-20100621/ippTools/src/pstamptool.c
r28794 r28980 1220 1220 PXOPT_COPY_S64(config->args, where, "-stage_id", "stage_id", "=="); 1221 1221 PXOPT_COPY_S64(config->args, where, "-dep_id", "dep_id", "=="); 1222 PXOPT_COPY_S64(config->args, where, "-job_id", "job_id", "=="); 1223 PXOPT_COPY_S64(config->args, where, "-req_id", "req_id", "=="); 1222 1224 PXOPT_COPY_STR(config->args, where, "-rlabel", "rlabel", "=="); 1223 1225 pxAddLabelSearchArgs(config, where, "-label", "pstampRequest.label", "=="); -
branches/eam_branches/ipp-20100621/ippTools/src/pstamptoolConfig.c
r28794 r28980 211 211 psMetadataAddStr(pendingdependentArgs, PS_LIST_TAIL, "-component", 0, "define component for dependent", NULL); 212 212 psMetadataAddS64(pendingdependentArgs, PS_LIST_TAIL, "-dep_id", 0, "define dep_id for dependent", 0); 213 psMetadataAddS64(pendingdependentArgs, PS_LIST_TAIL, "-job_id", 0, "define job_id for dependent", 0); 214 psMetadataAddS64(pendingdependentArgs, PS_LIST_TAIL, "-req_id", 0, "define eqp_id for dependent", 0); 213 215 psMetadataAddStr(pendingdependentArgs, PS_LIST_TAIL, "-label", PS_META_DUPLICATE_OK, "define label for pstampRequest", NULL); 214 216 psMetadataAddStr(pendingdependentArgs, PS_LIST_TAIL, "-rlabel", 0, "define label for dependent", NULL); -
branches/eam_branches/ipp-20100621/ippTools/src/staticskytool.c
r28154 r28980 727 727 bool exportrunMode(pxConfig *config) 728 728 { 729 # if (0)730 729 typedef struct ExportTable { 731 730 char tableName[80]; … … 737 736 PS_ASSERT_PTR_NON_NULL(config, NULL); 738 737 739 PXOPT_LOOKUP_S64(det_id, config->args, "-s tack_id", true, false);738 PXOPT_LOOKUP_S64(det_id, config->args, "-sky_id", true, false); 740 739 PXOPT_LOOKUP_STR(outfile, config->args, "-outfile", true, false); 741 740 PXOPT_LOOKUP_BOOL(clean, config->args, "-clean", false); … … 753 752 } 754 753 psMetadata *where = psMetadataAlloc(); 755 PXOPT_COPY_S64(config->args, where, "-s tack_id", "stack_id", "==");754 PXOPT_COPY_S64(config->args, where, "-sky_id", "sky_id", "=="); 756 755 757 756 ExportTable tables [] = { 758 {"sta ckRun", "staticskytool_export_run.sql"},759 {"sta ckInputSkyfile", "staticskytool_export_input_skyfile.sql"},760 {"sta ckSumSkyfile", "staticskytool_export_sum_skyfile.sql"},757 {"staticskyRun", "staticskytool_export_run.sql"}, 758 {"staticskyInput", "staticskytool_export_input.sql"}, 759 {"staticskyResult", "staticskytool_export_result.sql"}, 761 760 }; 762 761 … … 800 799 801 800 if (clean) { 802 if (!strcmp(tables[i].tableName, "sta ckRun")) {803 if (!pxSetStateCleaned("sta ckRun", "state", output)) {801 if (!strcmp(tables[i].tableName, "staticskyRun")) { 802 if (!pxSetStateCleaned("staticskyRun", "state", output)) { 804 803 psFree(output); 805 804 psError(PS_ERR_UNKNOWN, false, "pxSetStateClean failed for table %s", tables[i].tableName); … … 821 820 fclose (f); 822 821 823 # endif824 822 return true; 825 823 } -
branches/eam_branches/ipp-20100621/pstamp/scripts/detect_query_create
r28043 r28980 17 17 $query_id, 18 18 $nostage, 19 $version, 19 20 ); 20 21 … … 22 23 'input|i=s' => \$input, 23 24 'output|o=s' => \$output, 24 'query_id|q=s' => \$query_id, 25 'query_id|q=s' => \$query_id, 26 'version|v=s' => \$version, 25 27 'nostage' => \$nostage, 26 28 ) or pod2usage( 2 ); … … 30 32 -exitval => 3) unless defined $input and defined $output; 31 33 32 # The header kewords 34 # Read what we've been given 35 my $in; 36 if ($input eq '-') { 37 $in = \*STDIN; 38 } else { 39 open $in, "<$input" or die "cannot open $input for reading"; 40 } 41 my %colData; 42 my %headerData; 43 my $numRows = read_data_for_table($in,'\s+', \%colData, \%headerData); 44 if (!$numRows) { 45 print STDERR "no data in $input\n"; 46 exit 1; 47 } 48 49 # The header keywords 33 50 my $header = [ 34 51 { name => 'QUERY_ID', … … 62 79 value => undef 63 80 }, 64 { name => 'STAGE',81 { name => 'STAGE', 65 82 writetype => TSTRING, 66 83 comment => 'processing stage to examine', 67 84 value => undef 68 }85 } 69 86 ]; 70 unless(defined($nostage)) { 71 push @{ $header }, { name => 'STAGE', 72 writetype => TSTRING, 73 comment => 'processing stage to examine', 74 value => undef 75 }; 87 88 # Validate header. 89 90 if (defined($query_id)) { 91 $headerData{QUERY_ID} = $query_id; 92 } 93 unless (exists($headerData{QUERY_ID})) { 94 die "No QUERY_ID specified for header."; 95 } 96 97 unless (exists($headerData{EXTVER})) { 98 die "No EXTVER specified for header."; 99 } 100 if ($headerData{EXTVER} == 1) { 101 unless (exists($headerData{STAGE})) { 102 warn "No STAGE value specified in header. Assuming default value of 'diff'"; 103 $headerData{STAGE} = 'diff'; 104 } 105 foreach my $entry_ref (@{ $header }) { 106 my $name = $entry_ref->{name}; 107 unless (exists($headerData{$name})) { 108 die "Required header value $name not specified (try EXTVER=2?)."; 109 } 110 $entry_ref->{value} = $headerData{$name}; 111 } 112 } 113 elsif ($headerData{EXTVER} == 2) { 114 unless (exists($headerData{STAGE})) { 115 warn "No STAGE value specified in header. Assuming default value of 'diff'"; 116 $headerData{STAGE} = 'diff'; 117 } 118 my $tmp_header; 119 foreach my $entry_ref (@{ $header }) { 120 my $name = $entry_ref->{name}; 121 if (exists($headerData{$name})) { 122 $entry_ref->{value} = $headerData{$name}; 123 push @{ $tmp_header }, $entry_ref; 124 } 125 } 126 $header = $tmp_header; 127 } 128 else { 129 die "Unknown EXTVER = $headerData{EXTVER}."; 76 130 } 77 131 … … 91 145 { name => 'MAG', type => 'D', writetype => TDOUBLE }, 92 146 ]; 93 94 my $in; 95 if ($input eq '-') { 96 $in = \*STDIN; 97 } else { 98 open $in, "<$input" or die "cannot open $input for reading"; 99 } 100 101 my @colData; 102 foreach (@$columns) { 103 push @colData, []; 104 } 105 106 107 my $numRows = read_data_for_table($in,'\s+', \@colData, $header); 108 if (!$numRows) { 109 print STDERR "no data in $input\n"; 110 exit 1; 111 } 112 113 # overwrite the QUERY_ID value from the input file with the command 114 # line argument 115 116 if ($query_id) { 117 $header->[0]->{value} = $query_id; 118 } 119 120 my $status = make_fits_table($output, EXTNAME, $numRows, \@colData, $columns, $header); 147 my $columns_v2 = [ 148 { name => 'FPA_ID', type => '20A', writetype => TSTRING }, 149 { name => 'MJD-OBS', type => 'D', writetype => TDOUBLE }, 150 { name => 'FILTER', type => '20A', writetype => TSTRING }, 151 { name => 'OBSCODE', type => '20A', writetype => TSTRING }, 152 { name => 'STAGE', type => '20A', writetype => TSTRING } 153 ]; 154 # Validate the data. 155 if ($headerData{EXTVER} == 1) { 156 foreach my $entry_ref (@{ $columns }) { 157 my $name = $entry_ref->{name}; 158 unless (exists($colData{$name})) { 159 die "Required data column $name not found (try EXTVER=2?)."; 160 } 161 } 162 } 163 if ($headerData{EXTVER} == 2) { 164 my $tmp_columns; 165 foreach my $entry_ref (@{ $columns }) { 166 my $name = $entry_ref->{name}; 167 if (exists($colData{$name})) { 168 push @{ $tmp_columns }, $entry_ref; 169 } 170 } 171 foreach my $entry_ref (@{ $columns_v2 }) { 172 my $name = $entry_ref->{name}; 173 if (exists($colData{$name})) { 174 push @{ $tmp_columns }, $entry_ref; 175 } 176 } 177 $columns = $tmp_columns; 178 } 179 180 # Construct the array of arrays 181 my @colDataAoA = (); 182 foreach my $col_def (@{ $columns }) { 183 my $name = $col_def->{name}; 184 push @colDataAoA, $colData{$name}; 185 } 186 187 # foreach (@$columns) { 188 # push @colData, []; 189 # } 190 191 192 193 my $status = make_fits_table($output, EXTNAME, $numRows, \@colDataAoA, $columns, $header); 121 194 122 195 exit $status; … … 230 303 231 304 my $line_num = 0; 232 233 # read data for header if any data is expected 234 if ($header) { 235 my $nhead = @$header; 236 while (my $line = <$in>) { 237 $line_num++; 238 chomp $line; 239 next if !$line; # skip blank lines 240 next if ($line =~ /^#/); # skip comment lines 241 my @vals = split /$sep/, $line; 242 my $nvals = @vals; 243 die "number of header columns in input $nvals does not equal expected number of header words $nhead" 244 if (@vals != @$header); 245 246 for (my $i=0; $i < @$header; $i++) { 247 $header->[$i]->{value} = $vals[$i]; 248 } 249 250 last; # only one header line 251 } 252 } 253 254 my $row_num = 0; 255 my $ncols = @$colData; 256 while (my $line = <$in>) { 257 chomp $line; 258 $line_num++; 259 next if !$line; # skip blank lines 260 next if ($line =~ /^#/); # skip comment lines 261 262 my @vals = split /$sep/, $line; 263 my $nvals = @vals; 264 die "number of columns $nvals in input does not equal expected number of header " 265 . " words $ncols on line $line_num" if ($nvals != $ncols); 266 267 for (my $col = 0; $col < @$colData; $col++) { 268 $colData->[$col]->[$row_num] = $vals[$col]; 269 } 270 $row_num++; 271 } 272 305 my @keywords = (); 306 my $row_num; 307 while (<$in>) { 308 chomp; 309 if ($line_num == 0) { 310 # Parse header information keywords 311 $_ =~ s/#//g; 312 @keywords = split /\s+/; 313 if ($keywords[0] eq '') { 314 shift(@keywords); 315 } 316 } 317 elsif ($line_num == 1) { 318 # Parse header information values 319 my @values = split /\s+/; 320 if ($#values != $#keywords) { 321 die "Number of header columns in input does not equal expected number of header words"; 322 } 323 for (my $i = 0; $i <= $#values; $i++) { 324 $header->{$keywords[$i]} = $values[$i]; 325 } 326 } 327 elsif ($line_num == 2) { 328 # Parse table information keywords, dumping old keywords 329 $_ =~ s/#//g; 330 @keywords = split /\s+/; 331 if ($keywords[0] eq '') { 332 shift(@keywords); 333 } 334 } 335 else { 336 # Parse table information values 337 unless ($_ =~ /^#/) { 338 my @values = split /\s+/; 339 if ($#values != $#keywords) { 340 die "Number of header columns in input does not equal expected number of header words"; 341 } 342 for (my $i = 0; $i <= $#values; $i++) { 343 push @{ $colData{$keywords[$i]} }, $values[$i]; 344 $row_num = $#{ $colData{$keywords[$i] } } + 1; 345 } 346 } 347 } 348 $line_num++; 349 } 273 350 # we return the number of rows read 274 351 return $row_num; -
branches/eam_branches/ipp-20100621/pstamp/scripts/detect_query_read
r28794 r28980 20 20 use Math::Trig; 21 21 use Data::Dumper; 22 use IPC::Cmd 0.36 qw( can_run run ); 22 23 23 24 use constant EXTNAME => 'MOPS_DETECTABILITY_QUERY'; # Extension name for table … … 31 32 $output, # Name of output table 32 33 $save_temps, # Save temporary files? 34 $dbname, # needed to do camtool lookups. 33 35 ); 36 37 my $regtool = can_run('regtool') or (die "Can't find regtool"); 38 my $camtool = can_run('camtool') or (die "Can't find regtool"); 39 34 40 35 41 GetOptions( 36 42 'input|i=s' => \$input, 37 43 'output|o=s' => \$output, 44 'dbname=s' => \$dbname, 38 45 'nolabel|l' => \$no_print_label, 39 46 'noheader|h' => \$no_print_header, … … 65 72 66 73 # The keywords found in the header 67 # my $header = {68 # 'EXTVER' => { name => 'EXTVER',69 # writetype => TSTRING,70 # comment => 'Extension version',71 # value => undef72 # },73 # 'EXTNAME' => { name => 'EXTNAME',74 # writetype => TSTRING,75 # comment => 'name of this binary table extension',76 # value => undef77 # },78 # 'QUERY_ID' => { name => 'QUERY_ID',79 # writetype => TSTRING,80 # comment => 'MOPS Query ID for this batch query',81 # value => undef82 # },83 # 'FPA_ID' => { name => 'FPA_ID',84 # writetype => TSTRING,85 # comment => 'orginal FPA_ID used at ingest',86 # value => undef87 # },88 # 'MJD_OBS' => { name => 'MJD-OBS',89 # writetype => TDOUBLE,90 # comment => 'starting time of the exposure, MJD',91 # value => undef92 # },93 # 'FILTER' => { name => 'FILTER',94 # writetype => TSTRING,95 # comment => 'effective filter use for the exposure',96 # value => undef97 # },98 # 'OBSCODE' => { name => 'OBSCODE',99 # writetype => TSTRING,100 # comment => 'site identifier (MPC observatory code)',101 # value => undef102 # },103 # 'STAGE' => {104 # name => 'STAGE',105 # writetype => TSTRING,106 # comment => 'processing stage to examine',107 # value => undef108 # }109 # };110 74 111 75 my $parse_error = 0; 112 # Parse the header to determine what we expect to find. 76 # Parse the header to determine what we have to work with. 77 # Clean up empty space and remove unneeded single quotes. 113 78 foreach my $header_key (keys %{ $inHeader }) { 114 79 $inHeader->{$header_key} =~ s/\s+//g; 115 80 $inHeader->{$header_key} =~ s/\'//g; 116 81 } 117 my ($EXTVER,$headerEXTNAME,$QUERY_ID,$FPA_ID,$MJD_OBS,$FILTER,$OBSCODE,$STAGE) = 118 ($inHeader->{EXTVER},$inHeader->{EXTNAME},$inHeader->{QUERY_ID},$inHeader->{FPA_ID}, 119 $inHeader->{'MJD-OBS'},$inHeader->{FILTER},$inHeader->{OBSCODE},$inHeader->{STAGE}); 82 my ($EXTVER,$headerEXTNAME,$QUERY_ID, 83 $FPA_ID,$MJD_OBS,$FILTER, 84 $OBSCODE,$STAGE) = 85 ($inHeader->{EXTVER},$inHeader->{EXTNAME},$inHeader->{QUERY_ID}, 86 $inHeader->{FPA_ID},$inHeader->{'MJD-OBS'},$inHeader->{FILTER}, 87 $inHeader->{OBSCODE},$inHeader->{STAGE}); 88 120 89 unless(defined($EXTVER) && defined($headerEXTNAME) && 121 90 (($EXTVER == 1)||($EXTVER == 2)) && 122 ($headerEXTNAME eq EXTNAME)) { 91 ($headerEXTNAME eq EXTNAME)&& 92 (defined($QUERY_ID))) { 123 93 $parse_error = 1; 124 94 } … … 143 113 # apparent magnitude 144 114 { name => 'MAG', type => 'D', writetype => TDOUBLE, version => 1 }, 145 # v2 query_id: MOPS query ID for this batch query115 # v2 query_id: needs to be here. 146 116 { name => 'QUERY_ID', type => '20A', writetype => TSTRING, version => 2, default => $QUERY_ID }, 147 117 # v2 fpa_id: original FPA_ID used at ingest … … 172 142 173 143 if ($col->{version} > $EXTVER) { 174 @{ $colData{$col->{name}} } = map { $col->{default} } (0 .. $numRows );144 @{ $colData{$col->{name}} } = map { $col->{default} } (0 .. $numRows - 1); 175 145 next; 176 146 } 177 $inFits->get_colnum(0, $col->{name}, $col_num, $status) and check_fitsio($status); 178 $inFits->get_coltype($col_num, $col_type, undef, undef, $status) and check_fitsio($status); 179 $inFits->read_col($col_type, $col_num, 1, 1, $numRows, 0, $col_data, undef, $status) 180 and check_fitsio($status); 181 $colData{$col->{name}} = $col_data; 182 if ($col->{name} eq 'MJD-OBS') { 183 print @{ $col_data } . "\n"; 147 else { 148 if (defined($col->{default})) { 149 @{ $colData{$col->{name}} } = map { $col->{default} } (0 .. $numRows - 1); 150 next; 151 } 152 } 153 154 $inFits->get_colnum(0, $col->{name}, $col_num, $status); 155 if ($status == 0) { 156 $inFits->get_coltype($col_num, $col_type, undef, undef, $status) and check_fitsio($status); 157 $inFits->read_col($col_type, $col_num, 1, 1, $numRows, 0, $col_data, undef, $status) 158 and check_fitsio($status); 159 $colData{$col->{name}} = $col_data; 160 if ($col->{name} eq 'QUERY_ID') { 161 print @{ $col_data } . "\n"; 162 } 163 164 } 165 elsif ($status == 219) { 166 @{ $colData{$col->{name}} } = map { "Not Set" } (0 .. $numRows - 1); 167 $status = 0; 168 } 169 } 170 171 # Set things that aren't set. 172 for (my $i = 0; $i < $numRows; $i++) { 173 # Simple stuff first. 174 my %known_filters = (); 175 if ($colData{STAGE}[$i] eq "Not Set") { 176 $colData{STAGE}[$i] = 'diff'; 177 } 178 if ($colData{OBSCODE}[$i] eq "Not Set") { 179 $colData{OBSCODE}[$i] = 566; 180 } 181 # Define filter and MJD from FPA_ID 182 if (($colData{FILTER}[$i] eq "Not Set")&&($colData{FPA_ID}[$i] ne "Not Set")) { 183 if (exists($known_filters{$colData{FPA_ID}[$i]})) { 184 $colData{FILTER}[$i] = $known_filters{$colData{FPA_ID}[$i]}; 185 } 186 else { 187 my $cmd = "$regtool -processedexp -dbname $dbname -exp_name $colData{FPA_ID}[$i]"; 188 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 189 run(command => $cmd, verbose => 0); 190 unless ($success) { 191 # This is a problem, because I'm not sure how we handle a failure to read something. 192 # We need to return a $PSTAMP_INVALID_REQUEST, I think, but if we can't read it, 193 # we can't send that response back. 194 die("Unable to perform $cmd error code: $error_code"); 195 } 196 foreach my $entry (split /\n/, (join "", @$full_buf)) { 197 $entry =~ s/^\s+//; 198 my @line = split /\s+/, $entry; 199 if (scalar(@line) != 3) { 200 next; 201 } 202 my ($key,$type,$value) = @line; 203 # print "$entry => $key / $type / $value \n"; 204 if ($key =~ /filter/i) { 205 $value =~ s/.00000//; 206 $colData{FILTER}[$i] = $value; 207 $known_filters{$colData{FPA_ID}[$i]} = $value; 208 } 209 } 210 } 211 } 212 if (($colData{'MJD-OBS'}[$i] eq "Not Set")&&($colData{FPA_ID}[$i] ne "Not Set")) { 213 # HACK! 214 my $mjd = $colData{FPA_ID}[$i]; 215 $mjd =~ s/o(....)g.*/$1/; 216 $mjd += 50000; 217 $colData{'MJD-OBS'}[$i] = $mjd; 218 } 219 if (($colData{FPA_ID}[$i] eq "Not Set")&&(($colData{'FILTER'}[$i] ne "Not Set")&& 220 ($colData{'MJD-OBS'}[$i] ne "Not Set"))) { 221 my $dateobs_begin = mjd_to_dateobs($colData{'MJD-OBS'}[$i]); 222 my $dateobs_end = mjd_to_dateobs($colData{'MJD-OBS'}[$i] + 1); 223 my $ra = $colData{'RA1_DEG'}[$i]; 224 my $dec = $colData{'DEC1_DEG'}[$i]; 225 my $filter = $colData{'FILTER'}[$i] . ".00000"; 226 my $cmd = "$camtool -processedexp -dbname $dbname -filter $filter "; 227 $cmd .= " -dateobs_begin $dateobs_begin -dateobs_end $dateobs_end "; 228 $cmd .= " -ra $ra -decl $dec -radius 1.5 -limit 1"; 229 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 230 run(command => $cmd, verbose => 0); 231 unless ($success) { 232 # This is a problem, because I'm not sure how we handle a failure to read something. 233 # We need to return a $PSTAMP_INVALID_REQUEST, I think, but if we can't read it, 234 # we can't send that response back. 235 die("Unable to perform $cmd error code: $error_code"); 236 } 237 foreach my $entry (split /\n/, (join "", @$full_buf)) { 238 $entry =~ s/^\s+//; 239 my @line = split /\s+/, $entry; 240 if (scalar(@line) != 3) { 241 next; 242 } 243 my ($key,$type,$value) = @line; 244 # print "$entry => $key / $type / $value \n"; 245 if ($key =~ /exp_name/i) { 246 $colData{FPA_ID}[$i] = $value; 247 } 248 } 184 249 } 185 250 } … … 189 254 foreach my $colName (@unique_fields) { 190 255 my %counter = (); 256 my $i = 0; 191 257 foreach my $row (@{ $colData{$colName} }) { 192 258 $counter{$row} = 1; … … 232 298 my $msg; # Message to output 233 299 Astro::FITS::CFITSIO::fits_get_errstatus( $status , $msg ); 234 die "CFITSIO error: $ msg\n";300 die "CFITSIO error: $status => $msg\n"; 235 301 } 236 302 } … … 252 318 } 253 319 320 # Stolen from PStamp/Job.pm. Thanks, Bill. 321 sub mjd_to_dateobs { 322 my $mjd = shift; 323 324 my $ticks = ($mjd - 40587.0) * 86400; 325 326 my ($sec, $min, $hr, $day, $mon, $year) = gmtime($ticks); 327 328 return sprintf "'%4d-%02d-%02dT%02d:%02d:%02dZ'", $year+1900, $mon+1, $day, $hr, $min, $sec; 329 } 330 254 331 255 332 -
branches/eam_branches/ipp-20100621/pstamp/scripts/detectability_respond.pl
r28794 r28980 108 108 # Parse input request file using detect_query_read (as it's already written). 109 109 # 110 my $dqr_command = "$detect_query_read -- input $request_file";110 my $dqr_command = "$detect_query_read --dbname $imagedb --input $request_file"; 111 111 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 112 112 run(command => $dqr_command, verbose => $verbose); … … 308 308 } 309 309 close(WISDOM); 310 311 # If there is anything that needs to be updated, create the update request list, and then exit the program. 310 312 my $exit_code = 0; 311 313 my $update_request_file = "${workdir}/update_request.dat"; … … 316 318 $exit_code = 25; 317 319 } 320 elsif ($fault != 0) { 321 $exit_code = 21; 322 } 318 323 my $update_request = join ' ', @{ $update_request{$images}{$fault} }; 319 324 print UPDATE_REQUEST "$update_request\n"; … … 321 326 } 322 327 close(UPDATE_REQUEST); 323 #if ($exit_code != 0) {324 #exit($exit_code);325 #}328 if ($exit_code != 0) { 329 exit($exit_code); 330 } 326 331 327 332 # This duplicates stuff returned by PSTAMP, but my thought is to convert that ---^ into a conditional, in which I read … … 338 343 } 339 344 } 340 #exit(10);341 345 342 346 # run ppCoord and psphotForced to calculate the required data. … … 569 573 $columns = [ 570 574 # matching rownum from detectability original request 571 { name => 'ROWNUM', type => ' V', writetype => TULONG },575 { name => 'ROWNUM', type => '20A', writetype => TSTRING }, 572 576 # any errors that occurred during processing 573 577 { name => 'ERROR_CODE', type => 'V', writetype => TULONG }, … … 715 719 # print STDERR "$writeType $i $numRows $colName $status @{ $colData{$colName} }\n"; 716 720 $outFits->write_col( $writeType, $i + 1, 1, 1, $numRows, $colData{$colName}, $status ); 721 # print "$writeType $i $numRows $colName $status\n"; 717 722 check_fitsio( $status ); 718 719 723 } 720 724 $outFits->close_file( $status ); … … 730 734 my $msg; # Message to output 731 735 Astro::FITS::CFITSIO::fits_get_errstatus( $status , $msg ); 736 carp("CFITSIO error: $status => $msg"); 732 737 die "CFITSIO error: $msg\n"; 733 738 } -
branches/eam_branches/ipp-20100621/pstamp/scripts/dqueryparse.pl
r28794 r28980 158 158 } 159 159 } 160 els e{160 elsif ($fault == $PSTAMP_NOT_AVAILABLE) { 161 161 # Failed to run correctly, which means that we need to queue a job and flag data for updating. 162 162 # Get the dependency id for the data we're requesting be updated. … … 191 191 close(UPDATE_REQUEST); 192 192 } 193 else { 194 my_die ("Parse fault!!", $PS_EXIT_UNKNOWN_ERROR); 195 } 193 196 194 197 # This does not set the request state to stop. That will happen with the request_finish.pl script, -
branches/eam_branches/ipp-20100621/pstamp/scripts/pstamp_checkdependent.pl
r28794 r28980 147 147 # been updated we need to go and queue it. 148 148 149 if ( $it->{fault}) {149 if (($it->{state} ne 'cleaned') and $it->{fault}) { 150 150 my_die("Component faulted on update dep_id: $dep_id", 151 151 $PS_EXIT_SYS_ERROR); -
branches/eam_branches/ipp-20100621/pstamp/scripts/pstamp_job_run.pl
r28794 r28980 93 93 94 94 $argString .= " -file $params->{image}"; 95 $argString .= " -mask $params->{mask}"; 96 my @file_list = ($params->{image}, $params->{mask}); 95 my @file_list = ($params->{image}); 96 97 my $nan_masked = 1; 98 if (!$params->{magicked}) { 99 $nan_masked = 0; 100 } 101 if ($nan_masked or ($options & $PSTAMP_SELECT_MASK)) { 102 $argString .= " -mask $params->{mask}"; 103 push @file_list, $params->{mask}; 104 } 97 105 if ($options & $PSTAMP_SELECT_VARIANCE) { 98 106 $argString .= " -variance $params->{weight}"; … … 351 359 foreach my $f (@_) { 352 360 if (!$ipprc->file_exists($f)) { 353 my_die( "file $f does not exist:", $job_id, $PS _EXIT_SYS_ERROR);361 my_die( "file $f does not exist:", $job_id, $PSTAMP_GONE, 'stop'); 354 362 } 355 363 } … … 361 369 my $job_id = shift; # job identifier 362 370 my $exit_code = shift; # Exit code to add 371 my $job_state = shift; # new pstampJob.state 363 372 364 373 $exit_code = $PS_EXIT_PROG_ERROR unless $exit_code; 374 $job_state = 'run' unless $job_state; 365 375 366 376 carp($msg); … … 370 380 $command .= " -set_fault $exit_code"; 371 381 # XXX: fix pstamptool to not require -state when -fault with nonzero value is provided 372 $command .= " -set_state run";382 $command .= " -set_state $job_state"; 373 383 $command .= " -dbname $dbname" if defined $dbname; 374 384 $command .= " -dbserver $dbserver" if defined $dbserver; -
branches/eam_branches/ipp-20100621/pstamp/scripts/pstampparse.pl
r28794 r28980 386 386 $need_magic = $proj_hash->{need_magic}; 387 387 388 # Temporary hack so that MOPScan get at non-magicked data388 # Temporary hack so that IFA can get at non-magicked data 389 389 my $allow_mops_unmagicked = 1; 390 390 if ($allow_mops_unmagicked) { 391 391 if ($product and (($product eq "mops-pstamp-results") or 392 ($product eq "mops-pstamp-results2"))) { 392 ($product eq "mops-pstamp-results2") or 393 ($product eq "ifa-pstamp-results"))) { 393 394 $need_magic = 0; 394 395 } -
branches/eam_branches/ipp-20100621/pstamp/src/ppstampMakeStamp.c
r28310 r28980 229 229 230 230 static int makeStamp(pmConfig *config, ppstampOptions *options, pmFPAfile *input, 231 pmChip *inChip, pmFPAview *view, pmAstromObj *center )231 pmChip *inChip, pmFPAview *view, pmAstromObj *center, pmFPAfile *astrom) 232 232 { 233 233 int status = false; … … 266 266 srcFile = input; 267 267 *srcView = *view; 268 } 269 270 if (astrom->camera != srcFile->camera) { 271 psError(PS_ERR_UNKNOWN, true, "Input camera and astrometry camera do not match"); 272 return PS_EXIT_CONFIG_ERROR; 268 273 } 269 274 … … 583 588 if (!astrom) { 584 589 astrom = input; 585 } else if (astrom->camera != input->camera) {586 psError(PS_ERR_UNKNOWN, true, "Input camera and astrometry camera do not match");587 return PS_EXIT_CONFIG_ERROR;588 590 } 589 591 … … 636 638 case PPSTAMP_ON: 637 639 case PPSTAMP_PARTIALLY_ON: 638 returnval = makeStamp(config, options, input, chip, view, center );640 returnval = makeStamp(config, options, input, chip, view, center, astrom); 639 641 allDone = true; 640 642 foundOverlap = true; -
branches/eam_branches/ipp-20100621/tools/czarplot.pl
r28794 r28980 21 21 my $histogram = undef; 22 22 my $timeSeries = undef; 23 my $nebulous = undef; 23 24 my $savingToFile = undef; 24 25 … … 32 33 "output|o=s" => \$path, 33 34 "histogram|h" => \$histogram, 35 "nebulous|n" => \$nebulous, 34 36 "timeseries|t" => \$timeSeries, 35 37 "verbose|v" => \$verbose, … … 41 43 if (!$timeSeries) { 42 44 print "* OPTIONAL: plot timeseries -t (default=on)\n";} 45 if (!$nebulous) { 46 print "* OPTIONAL: plot nebulous disk space -n (default=off)\n";} 43 47 if (!$label) { 44 print "* OPTIONAL: choose a label -l <labellName> (default='all_ labels')\n";}48 print "* OPTIONAL: choose a label -l <labellName> (default='all_stdscience_labels')\n";} 45 49 if (!$stage) { 46 50 print "* OPTIONAL: choose a stage -s <chip|cam|warp|etc> (default=none)\n";} … … 57 61 58 62 # default values 59 if (!$label) {$label = "all_ labels";}60 if (!$ histogram && !$timeSeries) {$timeSeries = 1; $histogram = 1;}63 if (!$label) {$label = "all_stdscience_labels";} 64 if (!$nebulous && !$histogram && !$timeSeries) {$timeSeries = 1; $histogram = 0;} 61 65 if (!$verbose) {$verbose = 0;} 62 66 if (!$save_temps) {$save_temps = 0;} … … 67 71 $czarDb->setDateFormat("%Y%m%d-%H%i%s"); 68 72 69 my $czarplot = new czartool::Czarplot($czarDb, "%Y%m%d-%H%M%S", $savingToFile ? "png " : "X11", $path, $save_temps);73 my $czarplot = new czartool::Czarplot($czarDb, "%Y%m%d-%H%M%S", $savingToFile ? "png font \"/usr/share/fonts/corefonts/arial.ttf\" 8" : "X11", $path, $save_temps); 70 74 71 75 my @allStages = ("chip", "cam", "fake", "warp", "stack", "diff", "magic", "magicDS", "dist"); … … 78 82 } 79 83 80 if ($timeSeries) {$czarplot->createTimeSeries($label, $stage, $begin, $end);} 84 my $diskUsage = 1; # TODO 85 86 if (!$nebulous && $timeSeries) {$czarplot->createTimeSeries($label, $stage, $begin, $end);} 81 87 if ($histogram) {$czarplot->createHistogram($label, $begin, $end);} 88 if ($nebulous && $timeSeries) {$czarplot->plotStorageTimeSeries($begin, $end);} 89 elsif ($nebulous) {$czarplot->plotDiskUsageHistogram();} 82 90 -
branches/eam_branches/ipp-20100621/tools/czartool.pl
r28794 r28980 64 64 65 65 if ($key eq "s") {checkServers();} 66 elsif ($key eq "l") {checkAllLabels(" new");}67 elsif ($key eq "u") { serverStatus("stdscience");}66 elsif ($key eq "l") {checkAllLabels("stdscience");} 67 elsif ($key eq "u") {$pantasks->getServerCurrentStatus("stdscience");} 68 68 elsif ($key =~ m/[0-9]/) {my $key2=getc; checkOneLabel($stdscienceLabels[($key.$key2)-1]);} 69 69 printInstructions(); … … 99 99 100 100 return \@diff; 101 }102 103 ###########################################################################104 #105 # Prints the status of a given pantasks server106 #107 ###########################################################################108 sub serverStatus {109 my ($server) = @_;110 111 my @cmdOut = `echo "status;quit" | pantasks_client -c ~ipp/$server/ptolemy.rc 2>&1`;112 my $line;113 foreach $line (@cmdOut) {114 115 chomp($line);116 117 print "$line\n";118 }119 101 } 120 102 … … 263 245 my $new = $gpc1Db->countExposures($label, $stage, $state); 264 246 265 if ($state ne "new") {return $new;}266 267 my $faults = $gpc1Db->countFaults($label, $stage );247 #if ($state ne "new") {return $new;} 248 249 my $faults = $gpc1Db->countFaults($label, $stage, $state); 268 250 269 251 if ($faults < 1) {return $new;} -
branches/eam_branches/ipp-20100621/tools/czartool/CzarDb.pm
r28794 r28980 16 16 17 17 # Call the constructor of the parent class, Person. 18 my $self = $class->SUPER::new( $_[1], $_[2], $_[3], $_[4], $_[5], $_[6]);18 my $self = $class->SUPER::new($_[1], $_[2], $_[3], $_[4], $_[5], $_[6]); 19 19 20 20 bless $self, $class; … … 66 66 67 67 $query->execute; 68 } 69 70 ########################################################################### 71 # 72 # Gets revert status for this stage 73 # 74 ########################################################################### 75 sub getRevertStatus { 76 my ($self, $stage, $reverting) = @_; 77 78 my $query = $self->{_db}->prepare(<<SQL); 79 SELECT reverting 80 FROM reverts 81 WHERE stage LIKE '$stage'; 82 SQL 83 84 $query->execute; 85 return scalar $query->fetchrow_array(); 86 } 87 88 ########################################################################### 89 # 90 # Updates revert status for this stage 91 # 92 ########################################################################### 93 sub updateRevertStatus { 94 my ($self, $stage, $reverting) = @_; 95 96 my $query = $self->{_db}->prepare(<<SQL); 97 UPDATE reverts 98 SET reverting = $reverting 99 WHERE stage LIKE '$stage'; 100 SQL 101 102 $query->execute; 68 103 } 69 104 … … 117 152 } 118 153 } 154 155 ########################################################################### 156 # 157 # Updates hosts table 158 # 159 ########################################################################### 160 sub updateHost { 161 my ($self, $host, $total, $available, $used, $readable, $writable) = @_; 162 163 my $query = $self->{_db}->prepare(<<SQL); 164 DELETE FROM hosts WHERE host LIKE '$host'; 165 SQL 166 167 $query->execute; 168 $query = $self->{_db}->prepare(<<SQL); 169 INSERT INTO hosts 170 (host, total, available, used, readable, writable) 171 VALUES 172 ('$host', $total, $available, $used, $readable, $writable); 173 SQL 174 $query->execute; 175 176 } 177 178 ########################################################################### 179 # 180 # Inserts new cluster space info 181 # 182 ########################################################################### 183 sub insertNewClusterSpace { 184 my ($self, $total, $available, $used, $hostsOver98) = @_; 185 186 my $query = $self->{_db}->prepare(<<SQL); 187 INSERT INTO cluster_space 188 (total, available, used, hostsOver98) 189 VALUES 190 ( $total, $available, $used, $hostsOver98); 191 SQL 192 193 $query->execute; 194 } 195 119 196 ########################################################################### 120 197 # … … 123 200 ########################################################################### 124 201 sub insertNewTimeData { 125 my ($self, $stage, $label, $pending, $processed, $faults , $reverting) = @_;202 my ($self, $stage, $label, $pending, $processed, $faults) = @_; 126 203 127 204 my $query = $self->{_db}->prepare(<<SQL); 128 205 INSERT INTO $stage 129 (label, pending, processed, faults , reverting)206 (label, pending, processed, faults) 130 207 VALUES 131 ('$label', $pending, $processed, $faults , $reverting);208 ('$label', $pending, $processed, $faults); 132 209 SQL 133 210 … … 158 235 SQL 159 236 160 161 162 237 if (!$query->execute) {return undef;} 163 238 164 my $minProcessed ;239 my $minProcessed = undef; 165 240 166 241 ($minProcessed, ${$maxY}, ${$minY}, ${$maxX}, ${$minX}, ${$timeDiff}) = $query->fetchrow_array(); 167 242 168 if (! $minProcessed) {return undef;}243 if (!defined $minProcessed) {return undef;} 169 244 170 245 $query = $self->{_db}->prepare(<<SQL); … … 273 348 ########################################################################### 274 349 # 350 # Gets host data and stores it to temp file 351 # 352 ########################################################################### 353 sub createHostsData { 354 my ($self, $limit) = @_; 355 356 my $dataFile = "/tmp/czarplot_hosts_space.dat"; 357 open (GNUDAT, ">$dataFile"); 358 359 my $query = $self->{_db}->prepare(<<SQL); 360 SELECT 361 host, used, available, writable, readable 362 FROM hosts 363 ORDER BY host; 364 SQL 365 366 $query->execute; 367 368 my $underLimit; 369 370 # loop round results 371 while (my @row = $query->fetchrow_array()) { 372 373 my ($host, $used, $available, $writable, $readable) = @row; 374 375 if (($used/($used+$available))*100 > $limit) {$underLimit = 0;} 376 else {$underLimit = 1;} 377 378 # Col 1: host 379 print GNUDAT "$host"; 380 381 # Col 2: available, readable used space under limit 382 if ($readable && $underLimit) {print GNUDAT " $used";} 383 else {print GNUDAT " 0";} 384 385 # Col 3: available, readable used space OVER limit 386 if ($readable && !$underLimit) {print GNUDAT " $used";} 387 else {print GNUDAT " 0";} 388 389 # Col 4: NOT available used space 390 if (!$readable) {print GNUDAT " $used";} 391 else {print GNUDAT " 0";} 392 393 # Col 5: available writable space 394 if($writable) {print GNUDAT " $available";} 395 else {print GNUDAT " 0";} 396 397 # Col 6: NOT available writable space 398 if(!$writable) {print GNUDAT " $available";} 399 else {print GNUDAT " 0";} 400 401 print GNUDAT "\n"; 402 } 403 close(GNUDAT); 404 405 return $dataFile; 406 } 407 408 ########################################################################### 409 # 410 # Gets total used cluster space as a percentage 411 # 412 ############################################################################ 413 sub getTotalClusterStorageAsPercentage { 414 my ($self) = @_; 415 416 my $query = $self->{_db}->prepare(<<SQL); 417 SELECT used/total*100 418 FROM cluster_space 419 ORDER BY timestamp DESC LIMIT 1; 420 SQL 421 $query->execute; 422 return scalar $query->fetchrow_array(); 423 } 424 425 ########################################################################### 426 # 427 # Gets time series data for cluster storage and saves it to file 428 # 429 ########################################################################### 430 sub createStorageTimeSeriesData { 431 my ($self, $fromTime, $toTime, $minX, $maxX, $minY, $maxY, $timeDiff) = @_; 432 433 my $dataFile = "/tmp/czarplot_gnuplot_storage_timeseries.dat"; 434 open (GNUDAT, ">$dataFile"); 435 436 my $query = $self->{_db}->prepare(<<SQL); 437 SELECT 438 MAX(available), MIN(available), 439 DATE_FORMAT(MAX(timestamp),'$self->{_dateFormat}'), 440 DATE_FORMAT(MIN(timestamp),'$self->{_dateFormat}'), 441 TIME_TO_SEC(TIMEDIFF(max(timestamp ), min(timestamp))) 442 FROM cluster_space 443 WHERE timestamp >= '$fromTime' AND timestamp <= '$toTime'; 444 SQL 445 446 447 if (!$query->execute) {return undef;} 448 449 (${$maxY}, ${$minY}, ${$maxX}, ${$minX}, ${$timeDiff}) = $query->fetchrow_array(); 450 451 452 $query = $self->{_db}->prepare(<<SQL); 453 SELECT 454 DATE_FORMAT(timestamp, '$self->{_dateFormat}'), available 455 FROM cluster_space 456 WHERE timestamp >= '$fromTime' AND timestamp <= '$toTime' 457 ORDER BY timestamp; 458 SQL 459 460 $query->execute; 461 462 # loop round results 463 while (my @row = $query->fetchrow_array()) { 464 465 my ($timestamp, $available) = @row; 466 print GNUDAT "$timestamp $available\n"; 467 } 468 close(GNUDAT); 469 470 return $dataFile; 471 } 472 ########################################################################### 473 # 275 474 # Determines how much has been processed in the provided interval of time 276 475 # (format: 1 HOUR, 1 MINUTE 1 DAY etc) … … 301 500 302 501 my $currentRevision = -1; 303 my $latestRevision = 7;502 my $latestRevision = 10; 304 503 305 504 while ($currentRevision != $latestRevision) { … … 315 514 elsif ($currentRevision == 5) {$self->createRevision_6();} 316 515 elsif ($currentRevision == 6) {$self->createRevision_7();} 317 } 516 elsif ($currentRevision == 7) {$self->createRevision_8();} 517 elsif ($currentRevision == 8) {$self->createRevision_9();} 518 elsif ($currentRevision == 9) {$self->createRevision_10();} 519 } 520 } 521 522 ####################################################################################### 523 # 524 # Sets current revision of ippToPsps database 525 # 526 ####################################################################################### 527 sub setRevision { 528 my ($self, $revision) = @_; 529 530 my $query = $self->{_db}->prepare(<<SQL); 531 INSERT INTO revision (revision) VALUES ($revision); 532 SQL 533 $query->execute; 534 } 535 536 ####################################################################################### 537 # 538 # Gets current revision of ippToPsps database 539 # 540 ####################################################################################### 541 sub getRevision { 542 my ($self) = @_; 543 544 if (!$self->SUPER::doesTableExist("revision")) {return 0;} 545 546 my $query = $self->{_db}->prepare(<<SQL); 547 SELECT revision 548 FROM revision 549 ORDER BY revision DESC LIMIT 1; 550 SQL 551 552 $query->execute; 553 my @row = $query->fetchrow_array(); 554 555 return $row[0]; 318 556 } 319 557 … … 500 738 ####################################################################################### 501 739 # 502 # Sets current revision of ippToPsps database 503 # 504 ####################################################################################### 505 sub setRevision { 506 my ($self, $revision) = @_; 507 508 my $query = $self->{_db}->prepare(<<SQL); 509 INSERT INTO revision (revision) VALUES ($revision); 510 SQL 511 $query->execute; 512 } 513 514 ####################################################################################### 515 # 516 # Gets current revision of ippToPsps database 517 # 518 ####################################################################################### 519 sub getRevision { 520 my ($self) = @_; 521 522 if (!$self->SUPER::doesTableExist("revision")) {return 0;} 523 524 my $query = $self->{_db}->prepare(<<SQL); 525 SELECT revision 526 FROM revision 527 ORDER BY revision DESC LIMIT 1; 528 SQL 529 530 $query->execute; 531 my @row = $query->fetchrow_array(); 532 533 return $row[0]; 740 # Create revision 8 of the database 741 # 742 ####################################################################################### 743 sub createRevision_8 { 744 my ($self) = @_; 745 746 print "* Creating revision 8 of '$self->{_dbName}'\n"; 747 748 # drop reverting column from all stages tables 749 my $stage = undef; 750 foreach $stage (@stages) { 751 752 my $query = $self->{_db}->prepare(<<SQL); 753 ALTER TABLE $stage 754 DROP COLUMN reverting; 755 SQL 756 757 $query->execute; 758 } 759 760 # create new 'revert' table 761 my $query = $self->{_db}->prepare(<<SQL); 762 CREATE TABLE reverts ( 763 stage VARCHAR(128), 764 reverting TINYINT); 765 SQL 766 767 $query->execute; 768 769 # insert stages into revert table 770 foreach $stage (@stages) { 771 my $query = $self->{_db}->prepare(<<SQL); 772 INSERT INTO reverts 773 (stage, reverting) 774 VALUES 775 ('$stage', 0); 776 SQL 777 $query->execute; 778 } 779 780 $self->setRevision(8); 781 } 782 783 ####################################################################################### 784 # 785 # Create revision 9 of the database 786 # 787 ####################################################################################### 788 sub createRevision_9 { 789 my ($self) = @_; 790 791 print "* Creating revision 9 of '$self->{_dbName}'\n"; 792 793 my $query = $self->{_db}->prepare(<<SQL); 794 CREATE TABLE cluster_space ( 795 timestamp TIMESTAMP DEFAULT NOW(), 796 total FLOAT, 797 available FLOAT, 798 used FLOAT, 799 hostsOver98 SMALLINT); 800 SQL 801 802 $query->execute; 803 $query = $self->{_db}->prepare(<<SQL); 804 CREATE TABLE hosts ( 805 host VARCHAR(128), 806 total FLOAT, 807 available FLOAT, 808 used FLOAT); 809 SQL 810 811 $query->execute; 812 813 $query = $self->{_db}->prepare(<<SQL); 814 CREATE INDEX clusterSpaceIndex ON cluster_space (timestamp); 815 SQL 816 817 $query->execute; 818 819 $self->setRevision(9); 820 } 821 822 ####################################################################################### 823 # 824 # Create revision 10 of the database 825 # 826 ####################################################################################### 827 sub createRevision_10 { 828 my ($self) = @_; 829 830 print "* Creating revision 10 of '$self->{_dbName}'\n"; 831 832 my $query = $self->{_db}->prepare(<<SQL); 833 ALTER TABLE hosts 834 ADD COLUMN writable TINYINT NOT NULL DEFAULT 0, 835 ADD COLUMN readable TINYINT NOT NULL DEFAULT 0; 836 SQL 837 838 $query->execute; 839 840 $self->setRevision(10); 534 841 } 535 842 -
branches/eam_branches/ipp-20100621/tools/czartool/Czarplot.pm
r28794 r28980 154 154 my ($self, $minY, $maxY) = @_; 155 155 156 ${$maxY} = ${$maxY} + (${$maxY}/10); 157 ${$minY} = ${$minY} - (${$minY}/10); 156 my $tmp; 157 if (${$maxY} < ${$minY}) { 158 159 $tmp = ${$maxY}; 160 ${$maxY} = ${$minY}; 161 ${$minY} = $tmp; 162 } 163 164 my $border = (${$maxY} - ${$minY})/10; 165 166 ${$maxY} += $border; 167 ${$minY} -= $border ; 158 168 if (${$maxY} == 0) {${$maxY} = 1;} 159 169 if (${$minY} == 0) {${$minY} = -1;} 160 170 } 161 171 172 173 ########################################################################### 174 # 175 # Figures out suitable spacing for time tics on time-series pliots 176 # 177 ########################################################################### 178 sub getTimeSpacing { 179 my ($self, $timeDiff, $divX, $timeFormat) = @_; 180 181 # if less than a couple of hour's data plotted, show 30 mins tics 182 if ($timeDiff < 7200) { 183 ${$timeFormat} = "%H:%M"; 184 ${$divX} = 1800; 185 } 186 # if less than half a day's data plotted, show hourly tics 187 elsif ($timeDiff < 43200) { 188 ${$timeFormat} = "%H:%M"; 189 ${$divX} = 3600; 190 } 191 # if less than one day's data plotted, show 2 hourly tics 192 elsif ($timeDiff < 86400) { 193 ${$timeFormat} = "%H:%M"; 194 ${$divX} = 7200; 195 } 196 # if less than 1 week's data is data plotted, show daily tics 197 elsif ($timeDiff < 604800) { 198 199 ${$timeFormat} = "%m/%d"; 200 ${$divX} = 86400; 201 } 202 else { 203 204 ${$timeFormat} = "%m/%d"; 205 ${$divX} = 172800; 206 } 207 } 208 162 209 ########################################################################### 163 210 # … … 171 218 172 219 my $timeFormat = undef; 173 174 my $divX = $timeDiff/4; 175 176 # if less than a couple of hour's data plotted, show 30 mins tics 177 if ($timeDiff < 7200) { 178 $timeFormat = "%H:%M"; 179 $divX = 1800; 180 } 181 # if less than half a day's data plotted, show hourly tics 182 elsif ($timeDiff < 43200) { 183 $timeFormat = "%H:%M"; 184 $divX = 3600; 185 } 186 # if less than one day's data plotted, show 2 hourly tics 187 elsif ($timeDiff < 86400) { 188 $timeFormat = "%H:%M"; 189 $divX = 7200; 190 } 191 # if more than one day's data plotted, show daily tics 192 else { 193 194 $timeFormat = "%m/%d %H:%M"; 195 $divX = 86400; 196 } 220 my $divX = undef; 221 222 $self->getTimeSpacing($timeDiff, \$divX, \$timeFormat); 197 223 198 224 my $numOfPlots = keys %$gnuplotFiles; 225 my $title = undef; 226 227 # sort out plot title 228 if ($numOfPlots == 1) {foreach my $stage (keys %$gnuplotFiles) {$title = "'".$stage."'";}} 229 else {$title = "'All stages'"} 230 231 $title .= " for '$label', '$fromTime' to '$toTime'"; 199 232 200 233 open (GP, "|/usr/bin/gnuplot -persist") or die "no gnuplot"; … … 205 238 "set term $self->{_outputFormat};" . 206 239 "set output \"$outputFile\";" . 207 "set title \" All stages for '$label' since $fromTime\";" .240 "set title \"$title\";" . 208 241 "set key left top;" . 209 242 "set xdata time;" . 210 243 "set timefmt \"$self->{_dateFormat}\";" . 244 # "set yrange [\"$minY\":\"$maxY\"];" . 211 245 "set xrange [\"$minX\":\"$maxX\"];" . 212 246 "set format x \"$timeFormat\";" . … … 224 258 if ($numOfPlots == 1) { 225 259 226 print GP "'" . $gnuplotFiles->{$stage} . "' using 1:4 title \" processed\" with lines lt 2,";227 print GP "'" . $gnuplotFiles->{$stage} . "' using 1:2 title \" pending\" with lines lt 3,";228 print GP "'" . $gnuplotFiles->{$stage} . "' using 1:3 title \" faults\" with lines lt 1";260 print GP "'" . $gnuplotFiles->{$stage} . "' using 1:4 title \"Processed\" with lines lt 2,"; 261 print GP "'" . $gnuplotFiles->{$stage} . "' using 1:2 title \"Pending\" with lines lt 4,"; 262 print GP "'" . $gnuplotFiles->{$stage} . "' using 1:3 title \"Faults\" with lines lt 7"; 229 263 } 230 264 # when plotting multiple stages, show only processed … … 241 275 ########################################################################### 242 276 # 243 # Plots a histogram of processed stuff 244 # 245 ########################################################################### 246 sub plotHistogram { 247 my ($self, $inputFile, $outputFile, $label, $fromTime, $toTime) = @_; 277 # Plots a time-series of cluster storage 278 # 279 ########################################################################### 280 sub plotStorageTimeSeries { 281 my ($self, $fromTime, $toTime) = @_; 282 283 my $prefix = $self->{_outputPath} ? $self->{_outputPath} : "."; 284 my $outputFile = "$prefix/czarplot_cluster.png"; 285 my ($minX, $maxX, $minY, $maxY, $timeDiff); 286 287 my $gnuplotFile = $self->{_czarDb}->createStorageTimeSeriesData($fromTime, $toTime, \$minX, \$maxX, \$minY, \$maxY, \$timeDiff); 288 289 $self->sortOutMaxMinY(\$minY, \$maxY); 290 291 my $timeFormat = undef; 292 my $divX = undef; 293 294 $self->getTimeSpacing($timeDiff, \$divX, \$timeFormat); 248 295 249 296 open (GP, "|/usr/bin/gnuplot -persist") or die "no gnuplot"; … … 254 301 "set term $self->{_outputFormat};" . 255 302 "set output \"$outputFile\";" . 256 "set title \"Processing status for '$label' since $fromTime\";" . 303 "set title \"Total available cluster space over time\";" . 304 "set key left top;" . 305 "set xdata time;" . 306 "set timefmt \"$self->{_dateFormat}\";" . 307 "set xrange [\"$minX\":\"$maxX\"];" . 308 "set yrange [\"$minY\":\"$maxY\"];" . 309 "set format x \"$timeFormat\";" . 310 "set xtics \"$minX\", $divX, \"$maxX\";" . 311 "set grid xtics;" . 312 "set xlabel \"Time\";" . 313 "set ylabel \"Available (TB)\";" . 314 "plot " . 315 # "'$gnuplotFile' using 1:2 title \"Total\" with lines lt 1," . 316 "'$gnuplotFile' using 1:2 title \"Available\" with lines lt 2\n"; 317 318 print GP "\n"; 319 close GP; 320 } 321 322 ########################################################################### 323 # 324 # Plots a histogram of processed stuff 325 # 326 ########################################################################### 327 sub plotHistogram { 328 my ($self, $inputFile, $outputFile, $label, $fromTime, $toTime) = @_; 329 330 open (GP, "|/usr/bin/gnuplot -persist") or die "no gnuplot"; 331 use FileHandle; 332 GP->autoflush(1); 333 334 print GP 335 "set term $self->{_outputFormat};" . 336 "set output \"$outputFile\";" . 337 "set title \"'$label', '$fromTime' to '$toTime'\";" . 257 338 "set grid;" . 258 339 "set boxwidth;" . … … 262 343 "set bmargin 5;" . 263 344 "set ylabel \"Exposures\";" . 264 "plot '$inputFile' using 2:xtic(1) title \"Processed\" lt 2, '' using 3 title \"Pending\" lt 3, '' using 4 title \"Faults\" lt 1\n"; 345 "plot '$inputFile' using 2:xtic(1) title \"Processed\" lt 2, '' using 3 title \"Pending\" lt 4, '' using 4 title \"Faults\" lt 7;" . 346 "\n"; 265 347 266 348 close GP; 267 349 } 268 350 351 ########################################################################### 352 # 353 # Plots disk usage across cluster as a stacked histogram 354 # 355 ########################################################################### 356 sub plotDiskUsageHistogram { 357 my ($self) = @_; 358 359 my $prefix = $self->{_outputPath} ? $self->{_outputPath} : "."; # TODO should be function for this 360 my $outputFile = "$prefix/czarplot_hosts_space.png"; 361 my $limit = 97.0; 362 my $inputFile = $self->{_czarDb}->createHostsData($limit); 363 364 my $totalUsed = $self->{_czarDb}->getTotalClusterStorageAsPercentage(); 365 366 my $totalPercent = sprintf("%.1f%%", $totalUsed); 367 368 open (GP, "|/usr/bin/gnuplot -persist") or die "no gnuplot"; 369 use FileHandle; 370 GP->autoflush(1); 371 372 print GP 373 "set term $self->{_outputFormat};" . 374 "set output \"$outputFile\";" . 375 "set title \"Nebulous disk use across IPP cluster ($totalPercent of total allocated)\";" . 376 "set style fill solid 1.00 border -1;" . 377 "set style histogram rowstacked;" . 378 "set style data histograms;" . 379 "set ylabel \"Space (TB)\";" . 380 "set xtic rotate by -90 scale 0;" . 381 "plot '$inputFile' " . 382 "using 2:xtic(1) t \"Used\" lt 7," . 383 "'' using 3 t \"Over $limit% used\" lt 1," . 384 "'' using 4 t \"Unavailable\" fs solid 0.50 lt -1 ," . 385 "'' using 5 t \"Free\" lt 2," . 386 "'' using 6 notitle fs solid 0.50 lt -1" . 387 ";" . 388 389 "\n"; 390 391 close GP; 392 } 269 393 1; -
branches/eam_branches/ipp-20100621/tools/czartool/Gpc1Db.pm
r28794 r28980 8 8 use czartool::MySQLDb; 9 9 our @ISA = qw(czartool::MySQLDb); # inherits from MySQLDb 10 11 ########################################################################### 12 # 13 # Returns the right join table and ID to join on for for a given stage TODO make private 14 # 15 ########################################################################### 16 sub getJoinTableAndId { 17 my ($self, $stage, $joinTable, $id) = @_; 18 19 ${$id} = $stage."_id"; 20 21 if ($stage eq "chip") {${$joinTable}="chipProcessedImfile";} 22 elsif ($stage eq "cam") {${$joinTable}="camProcessedExp";} 23 elsif ($stage eq "fake") {${$joinTable}="fakeProcessedImfile";} 24 elsif ($stage eq "warp") {${$joinTable}="warpSkyfile";} 25 elsif ($stage eq "stack") {${$joinTable}="stackSumSkyfile";} 26 elsif ($stage eq "diff") {${$joinTable}="diffSkyfile";} 27 elsif ($stage eq "magic") {${$joinTable}="magicNodeResult";} 28 elsif ($stage eq "magicDS") {${$id} = "magic_ds_id"; ${$joinTable}="magicDSFile";} 29 elsif ($stage eq "dist") {${$joinTable}="distComponent";} 30 else { 31 32 print "* ERROR: could nod find joinTable and ID for '$stage' stage\n"; 33 return 0; 34 } 35 36 return 1; 37 } 10 38 11 39 ########################################################################### … … 30 58 } 31 59 32 33 60 ########################################################################### 34 61 # … … 37 64 ########################################################################### 38 65 sub countFaults { 39 my ($self, $label, $stage ) = @_;66 my ($self, $label, $stage, $state) = @_; 40 67 41 42 my $table = getTableForStage($self, $stage); 43 my $joinTable; 44 my $id = $stage."_id"; 45 46 if ($stage eq "chip") {$joinTable="chipProcessedImfile";} 47 elsif ($stage eq "cam") {$joinTable="camProcessedExp";} 48 elsif ($stage eq "fake") {$joinTable="fakeProcessedImfile";} 49 elsif ($stage eq "warp") {$joinTable="warpSkyfile";} 50 elsif ($stage eq "stack") {$joinTable="stackSumSkyfile";} 51 elsif ($stage eq "diff") {$joinTable="diffSkyfile";} 52 elsif ($stage eq "magic") {$joinTable="magicNodeResult";} 53 elsif ($stage eq "magicDS") {$id = "magic_ds_id"; $joinTable="magicDSFile";} 54 elsif ($stage eq "dist") {$joinTable="distComponent";} 55 else {return -1;} 68 my $table = undef; 69 my $joinTable = undef; 70 my $id = undef; 71 $table = getTableForStage($self, $stage); 72 if (!getJoinTableAndId($self, $stage, \$joinTable, \$id)) {return -1;} 56 73 57 74 my $faultCol = $joinTable.".fault"; … … 64 81 WHERE label LIKE '$label' 65 82 AND $faultCol != 0 66 AND $stateCol = ' new'83 AND $stateCol = '$state' 67 84 SQL 68 85 … … 85 102 SQL 86 103 87 $query->execute;104 $query->execute; 88 105 my $priority = scalar $query->fetchrow_array(); 89 106 if (!$priority) {return 50000;} # assume labels not given priority in gpc1 Db have highest priority … … 100 117 101 118 my $table = getTableForStage($self, $stage); 102 if ($state eq "fault") {return countFaults($stage);} 119 my $query = undef; 120 121 if ($state eq "update") { 122 123 if ($stage eq "dist") {return 0;} 124 my $joinTable = undef; 125 my $id = undef; 126 if (!getJoinTableAndId($self, $stage, \$joinTable, \$id)) {return -1;} 127 128 if ($stage eq "chip" || $stage eq "fake" || $stage eq "warp" || $stage eq "diff" || $stage eq "magicDS") { 129 $query = $self->{_db}->prepare(<<SQL); 130 SELECT COUNT(state) 131 FROM $table JOIN $joinTable 132 USING($id) 133 WHERE label LIKE '$label' 134 AND state = 'update' 135 AND data_state = 'update'; 136 SQL 137 } 138 else { 139 140 $query = $self->{_db}->prepare(<<SQL); 141 SELECT COUNT(state) 142 FROM $table JOIN $joinTable 143 USING($id) 144 WHERE label LIKE '$label' 145 AND state = 'update'; 146 SQL 147 } 148 149 } 150 else { 151 152 $query = $self->{_db}->prepare(<<SQL); 153 SELECT COUNT(state) 154 FROM $table 155 WHERE label LIKE '$label' 156 AND state = '$state' 157 SQL 158 } 103 159 104 160 105 my $query = $self->{_db}->prepare(<<SQL); 106 SELECT count(state) 107 FROM $table 108 WHERE label LIKE '$label' 109 AND state = '$state' 110 SQL 111 112 $query->execute; 161 $query->execute; 113 162 return scalar $query->fetchrow_array(); 114 163 } -
branches/eam_branches/ipp-20100621/tools/czartool/Pantasks.pm
r28794 r28980 5 5 6 6 package czartool::Pantasks; 7 8 7 9 8 my @servers = ( … … 21 20 ); 22 21 22 ########################################################################### 23 # 24 # Constructor TODO put in check that we can run pantasks_client 25 # 26 ########################################################################### 27 sub new { 28 my $class = shift; 29 my $self = {}; 30 31 bless $self, $class; 32 return $self; 33 } 23 34 24 35 ########################################################################### … … 35 46 ########################################################################### 36 47 # 37 # Constructor38 #39 ###########################################################################40 sub new {41 my $class = shift;42 my $self = {};43 44 bless $self, $class;45 return $self;46 }47 48 ###########################################################################49 #50 48 # Returns the correct server for this processing stage 51 49 # … … 58 56 } 59 57 58 ########################################################################### 59 # 60 # Checks for a meaningful response from pantasks client 61 # 62 ########################################################################### 63 sub outputOk { 64 my ($self, $output) = @_; 65 66 if ( 67 $output =~ m/.*show\.labels.*/i || 68 $output =~ m/.*Connection reset by peer.*/i || 69 $output =~ m/.*server is busy.*/i ) { 70 71 print "* WARNING: pantasks returned '$output'\n"; 72 return 0; 73 } 74 return 1; 75 } 60 76 61 77 ########################################################################### … … 75 91 76 92 chomp($line); 77 if ($line =~ m/pantasks:\s+(.*)/) { 78 79 # HACK quit if we get 'show.labels: Command not found.' 80 if ($1 =~ m/.*show\.labels.*/i) {return \@labels;}; 81 # HACK quit if we get 'Connection reset by peer' 82 if ($1 =~ m/.*Connection reset by peer.*/i) {return \@labels;}; 83 # HACK quit if we get 'server is busy' message 84 if ($1 =~ m/.*server is busy.*/i) {return \@labels;}; 85 # HACK to get around 'dummy' label in stdscience 86 if ($1 !~ m/.*dummy.*/) {push(@labels, $1);}; 87 $passedHeader=1; 88 next; 89 } 90 93 if (!$self->outputOk($line)) {return \@labels;} 94 if ($line =~ m/pantasks:\s+/) {$passedHeader=1; next;} 91 95 if ($passedHeader) {push(@labels, $line);} 92 96 } … … 113 117 if ($line =~ m/Scheduler is running/) {${$running} = 1; ${$alive}=1;last;} 114 118 if ($line =~ m/Task Status/) {last;} 115 116 119 } 117 120 } … … 125 128 my ($self, $server) = @_; 126 129 130 my @cmdOut = `echo "status;quit" | pantasks_client -c ~ipp/$server/ptolemy.rc 2>&1`; 131 my $line; 132 my $passedHeader=0; 133 print "\n"; 134 foreach $line (@cmdOut) { 135 136 if ($line =~ m/.*Task Status.*/) {$passedHeader=1;next;} 137 if ($passedHeader){print "$line";} 138 } 139 } 140 141 ########################################################################### 142 # 143 # Gets revert status for this stage 144 # 145 ########################################################################### 146 sub getRevertStatus { 147 my ($self, $stage, $reverting) = @_; 148 149 my $server = $self->getServerForThisStage($stage); 150 151 if ($stage eq "cam") {$stage = "camera";} 127 152 128 153 my @cmdOut = `echo "status;quit" | pantasks_client -c ~ipp/$server/ptolemy.rc 2>&1`; 129 154 my $line; 130 my $passedHeader=0;131 155 foreach $line (@cmdOut) { 132 156 133 157 chomp($line); 134 if ($line =~ m/.*Task Status.*/) {$passedHeader=1;next;} 135 if ($passedHeader){print "$line<br>";} 158 if ($line =~ m/\s+([+-])[+-]\s+$stage\.revert.*/) { 159 160 if ($1 =~ m/-/) {${$reverting} = 0;} 161 elsif ($1 =~ m/\+/) {${$reverting}=1;} 162 } 136 163 } 137 164 } 138 139 165 1; -
branches/eam_branches/ipp-20100621/tools/examine_burntool_pcontrol.pl
r27070 r28980 33 33 while(<LAZY>) { 34 34 chomp; 35 if ($_ =~ /BURNTOOL.STATE.GOOD /) {35 if ($_ =~ /BURNTOOL.STATE.GOOD\s/) { 36 36 @line = split /\s+/; 37 37 $burntoolStateGood = $line[2]; -
branches/eam_branches/ipp-20100621/tools/psstatus
r28355 r28980 10 10 use File::Temp qw(tempfile); 11 11 12 my $limit = 20;12 my $limit = 0; 13 13 my $running; 14 my $finished; 14 15 my $req_faulted; 15 16 my $job_faulted; … … 23 24 GetOptions( 24 25 'running|r', \$running, 26 'finished|f', \$finished, 25 27 'req_faulted', \$req_faulted, 26 28 'job_faulted', \$job_faulted, … … 32 34 pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV; 33 35 34 my $no_args = ! (defined $running or defined $req_faulted or defined $job_faulted ); 36 my $no_args = ! (defined $running or defined $finished or defined $req_faulted or defined $job_faulted ); 37 38 die "cannot supply --running and --finished\n" if ($running and $finished); 39 35 40 36 41 my $ipprc = PS::IPP::Config->new(); 37 42 my $dbh = getDBHandle(); 38 43 39 my $select = "SELECT req_id, name, label, reqType, pstampRequest.state, pstampRequest.fault, count(job_id) AS numJobs, timestamp"; 44 my $jobLabel = $running ? "Running jobs" : "Num Jobs"; 45 my $select = "SELECT req_id, name, label, reqType, pstampRequest.state, pstampRequest.fault, count(job_id) AS '$jobLabel', timestamp"; 40 46 41 47 $select .= ", outdir" if ($verbose); … … 45 51 my $sql = $select . $from . $where; 46 52 47 if ($no_args and $limit) { 53 $limit = 20 if ($no_args); 54 # if ($no_args and $limit) { 55 if (0 and $limit) { 48 56 # use mysql to get the last_req_id 49 57 # this works but it prints out the @last_req_id value which is distracting. Use dbi for the query 50 my $stmt = $dbh->prepare("SELECT req_id FROM pstampRequest ORDER BY req_id DESC LIMIT 1"); 58 my $where = ""; 59 if ($running) { 60 $where = " WHERE pstampRequest.state = 'run' OR pstampRequest.state = 'new'"; 61 } elsif ($finished) { 62 $where = " WHERE pstampRequest.state = 'stop'"; 63 } 64 my $stmt = $dbh->prepare("SELECT req_id FROM pstampRequest $where ORDER BY req_id DESC LIMIT 1"); 51 65 $stmt->execute(); 52 66 my $row = $stmt->fetchrow_hashref(); … … 59 73 } 60 74 if ($running) { 61 $sql .= " AND (pstampRequest.state = 'new' OR pstampRequest.state = 'run')" 75 $sql .= " AND (pstampRequest.state = 'new' OR pstampRequest.state = 'run') AND (pstampJob.state = 'run' OR pstampJob.state IS NULL)"; 76 } elsif ($finished) { 77 $sql .= " AND (pstampRequest.state = 'stop') AND date_add(timestamp, interval 1 day) >=utc_timestamp()" 62 78 } 63 79 if ($req_faulted) { … … 69 85 $sql .= " GROUP BY req_id"; 70 86 87 if ($finished) { 88 $sql .= " ORDER BY timestamp DESC"; 89 } 71 90 if ($limit and !$no_args) { 72 91 $sql .= " LIMIT $limit"; -
branches/eam_branches/ipp-20100621/tools/roboczar.pl
r28794 r28980 10 10 use czartool::Gpc1Db; 11 11 use czartool::Pantasks; 12 use czartool::Nebulous; 12 13 use czartool::Czarplot; 13 14 14 15 15 my $period = 60; … … 24 24 my $czarDb = new czartool::CzarDb($czarDbName, "ippdb01", "ipp", "ipp", 0, $save_temps); # TODO last arg here is save_temps, should get as arg 25 25 my $gpc1Db = new czartool::Gpc1Db("gpc1", "ippdb01", "ippuser", "ippuser"); 26 my $nebulous = new czartool::Nebulous($czarDb); 26 27 my $pantasks = new czartool::Pantasks(); 27 my $czarplot = new czartool::Czarplot($czarDb, "%Y%m%d-%H%M%S", "png ", "/tmp", $save_temps);28 my $czarplot = new czartool::Czarplot($czarDb, "%Y%m%d-%H%M%S", "png font \"/usr/share/fonts/corefonts/arial.ttf\" 8", "/tmp", $save_temps); # TODO hardcoded font path 28 29 $czarDb->setDateFormat("%Y%m%d-%H%i%s"); 29 30 … … 41 42 42 43 print "* Updating labels\n"; 43 my @servers = ("stdscience", "distribution", "publishing" );44 my @servers = ("stdscience", "distribution", "publishing", "update"); 44 45 45 46 my $server = undef; … … 91 92 my $faults; 92 93 my $stage; 93 my ($totalNew,$totalFull,$totalFaults);94 94 my $query = undef; 95 95 my $str = undef; 96 my $reverting = 0; 97 my $server = undef; 98 my $rows = undef; 96 my $labels = undef; 97 my $updateLabels = undef; 99 98 my $row = undef; 100 99 my $begin = undef; 101 100 my $end = undef; 102 101 my $priority = undef; 102 my $newState = undef; 103 103 104 104 while (1) { 105 106 updateServerStatus();107 updateLabels();108 if (!$czarDb->getCurrentLabels("stdscience", \$rows)) {next;}109 110 my $size = @{$rows};111 if($size < 1) {112 113 print "* WARNING: no stdscience labels found in Db\n";114 next;115 }116 117 # get priority118 foreach $row ( @{$rows} ) {119 my ($label) = @{$row};120 $priority = $gpc1Db->getPriority($label);121 $czarDb->setLabelPriority($label, $priority);122 }123 105 124 106 # sort out times … … 131 113 } 132 114 133 foreach $stage (@stages) { 134 135 $server = $pantasks->getServerForThisStage($stage); 136 $str = `czartool_revert.pl -s $server -t $stage`; 137 if ($str =~ m/on/) {$reverting = 1;} 138 else {$reverting = 0;} 139 print "* Checking labels for $stage stage\n"; 140 141 $totalNew=$totalFaults=$totalFull=0; 142 foreach $row ( @{$rows} ) { 143 my ($label) = @{$row}; 144 145 chomp($label); 146 147 $new = $gpc1Db->countExposures($label, $stage, "new"); 148 $full = $gpc1Db->countExposures($label, $stage, "full"); 149 $faults = $gpc1Db->countFaults($label, $stage); 150 151 #printf("%ld, %s, %s, %d, %d\n", $currentTime, $label, $stage, $new, $faults); 152 $totalNew += $new; 153 $totalFull += $full; 154 $totalFaults += $faults; 155 156 $czarDb->insertNewTimeData($stage, $label, $new, $full, $faults, $reverting); 157 $czarplot->createTimeSeries($label, $stage, $begin, $end); 115 # check nebulous 116 print "* Checking Nebulous\n"; 117 $nebulous->updateClusterSpaceInfo(); 118 $czarplot->plotDiskUsageHistogram(); 119 updateServerStatus(); 120 121 # check labels 122 updateLabels(); 123 124 # servers to check 125 my @serversToCheck = ("stdscience", "update"); 126 127 my $thisServer = undef; 128 foreach $thisServer (@serversToCheck) { 129 130 if ($thisServer eq "update") {$newState = "update";} 131 else {$newState = "new";} 132 133 # deal with stdscience labels 134 if (!$czarDb->getCurrentLabels($thisServer, \$labels)) {next;} 135 my $size = @{$labels}; 136 if($size > 0) { 137 138 # get priority 139 foreach $row ( @{$labels} ) { 140 my ($label) = @{$row}; 141 $priority = $gpc1Db->getPriority($label); 142 $czarDb->setLabelPriority($label, $priority); 143 } 144 145 updateAllStages($thisServer, $newState, $labels, $begin, $end); 146 createPlots($thisServer, $labels, $begin, $end); 158 147 } 159 160 $czarDb->insertNewTimeData($stage, "all_labels", $totalNew, $totalFull, $totalFaults, $reverting); 161 } 162 163 print "* Generating plots\n"; 164 foreach $row ( @{$rows} ) { 165 my ($label) = @{$row}; 166 167 $czarplot->createTimeSeries($label, undef, $begin, $end); 168 $czarplot->createHistogram($label, $begin, $end); 169 170 #routineChecks($label, "1 HOUR"); 171 } 172 $czarplot->createTimeSeries("all_labels", undef, $begin, $end); 173 $czarplot->createHistogram("all_labels", $begin, $end); 174 foreach $stage (@stages) { 175 176 $czarplot->createTimeSeries("all_labels", $stage, $begin, $end); # TODO must be a neater way... 177 } 148 else { print "* WARNING: no $thisServer labels found in Db\n";} 149 } 150 178 151 print "--------------------------------------------------------------------------\n"; 179 152 print "* Going to sleep\n"; … … 183 156 #sendEmail("roydhenderson\@gmail.com", "roboczar\@ipp.com", "Roboczar update", "Some content"); 184 157 }; 158 } 159 160 ########################################################################### 161 # 162 # Loops through labels and creates time series and histogram plots 163 # 164 ########################################################################### 165 sub createPlots { 166 my ($server, $rows, $begin, $end) = @_; 167 168 my $stage = undef; 169 my $row = undef; 170 171 print "* Generating plots\n"; 172 173 # create plots for each label for each stage 174 foreach $stage (@stages) { 175 foreach $row ( @{$rows} ) { 176 my ($label) = @{$row}; 177 178 chomp($label); 179 $czarplot->createTimeSeries($label, $stage, $begin, $end); 180 } 181 } 182 183 # create plots for each label for all stages 184 foreach $row ( @{$rows} ) { 185 my ($label) = @{$row}; 186 187 $czarplot->createTimeSeries($label, undef, $begin, $end); 188 $czarplot->createHistogram($label, $begin, $end); 189 190 #routineChecks($label, "1 HOUR"); 191 } 192 $czarplot->createTimeSeries("all_".$server."_labels", undef, $begin, $end); 193 $czarplot->createHistogram("all_".$server."_labels", $begin, $end); 194 foreach $stage (@stages) { 195 196 $czarplot->createTimeSeries("all_".$server."_labels", $stage, $begin, $end); # TODO must be a neater way... 197 } 198 } 199 200 ########################################################################### 201 # 202 # Loops through some labels and updates processed/pending/faults in the Db 203 # 204 ########################################################################### 205 sub updateAllStages { 206 my ($labelServer, $newState, $rows, $begin, $end) = @_; 207 208 print "* Updating stage data\n"; 209 my $totalNew = undef; 210 my $totalFaults = undef; 211 my $totalFull = undef; 212 my $stage = undef; 213 my $reverting = 0; 214 my $row = undef; 215 my $new = undef; 216 my $full = undef; 217 my $faults = undef; 218 my $server = undef; 219 my $state = undef; 220 221 foreach $stage (@stages) { 222 223 $server = $pantasks->getServerForThisStage($stage); 224 $pantasks->getRevertStatus($stage, \$reverting); 225 $czarDb->updateRevertStatus($stage, $reverting); 226 227 print "* Checking labels for $stage stage\n"; 228 229 $totalNew=$totalFaults=$totalFull=0; 230 foreach $row ( @{$rows} ) { 231 my ($label) = @{$row}; 232 233 chomp($label); 234 235 $new = $gpc1Db->countExposures($label, $stage, $newState); 236 $full = $gpc1Db->countExposures($label, $stage, "full"); 237 $faults = $gpc1Db->countFaults($label, $stage, $newState); 238 239 #printf("%s %s, %s, %d, %d\n", $labelServer, $label, $stage, $new, $faults); 240 $totalNew += $new; 241 $totalFull += $full; 242 $totalFaults += $faults; 243 244 $czarDb->insertNewTimeData($stage, $label, $new, $full, $faults); 245 } 246 247 $czarDb->insertNewTimeData($stage, "all_".$labelServer."_labels", $totalNew, $totalFull, $totalFaults); 248 } 185 249 } 186 250
Note:
See TracChangeset
for help on using the changeset viewer.
