Changeset 24683
- Timestamp:
- Jul 6, 2009, 12:52:22 PM (17 years ago)
- Location:
- trunk/ippTools
- Files:
-
- 4 added
- 6 edited
-
share/Makefile.am (modified) (1 diff)
-
share/magicdstool_completed_runs.sql (modified) (3 diffs)
-
share/magicdstool_todestreak.sql (modified) (1 diff)
-
share/magicdstool_torevert_chip.sql (added)
-
share/magicdstool_torevert_diff.sql (added)
-
share/magicdstool_torevert_raw.sql (added)
-
share/magicdstool_torevert_warp.sql (added)
-
src/magicdstool.c (modified) (7 diffs)
-
src/magicdstool.h (modified) (1 diff)
-
src/magicdstoolConfig.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippTools/share/Makefile.am
r24512 r24683 159 159 magicdstool_toremove.sql \ 160 160 magicdstool_torestore.sql \ 161 magicdstool_torevert_raw.sql \ 162 magicdstool_torevert_chip.sql \ 163 magicdstool_torevert_warp.sql \ 164 magicdstool_torevert_diff.sql \ 161 165 pstamptool_addjob_otherjob.sql \ 162 166 pstamptool_addjob_stampjob.sql \ -
trunk/ippTools/share/magicdstool_completed_runs.sql
r24421 r24683 16 16 GROUP BY 17 17 magicDSRun.magic_ds_id, 18 rawImfile.exp_id18 stage_id 19 19 HAVING 20 20 COUNT(rawImfile.class_id) = COUNT(magicDSFile.component) … … 35 35 GROUP BY 36 36 magic_ds_id, 37 chip_id37 stage_id 38 38 HAVING 39 39 COUNT(chipProcessedImfile.class_id) = COUNT(magicDSFile.component) 40 40 AND SUM(magicDSFile.fault) = 0 41 UNION 42 -- camera stage 43 SELECT 44 magicDSRun.magic_ds_id 45 FROM magicDSRun 46 JOIN camProcessedExp ON stage_id = camProcessedExp.cam_id 47 LEFT JOIN magicDSFile 48 ON magicDSFile.magic_ds_id = magicDSRun.magic_ds_id 49 AND magicDSFile.component IS NOT NULL 50 WHERE 51 magicDSRun.state = 'new' 52 AND magicDSRun.stage = 'camera' 53 AND camProcessedExp.quality = 0 54 AND magicDSFile.fault = 0 55 GROUP BY 56 magic_ds_id, 57 stage_id 41 58 UNION 42 59 -- warp stage … … 55 72 GROUP BY 56 73 magicDSRun.magic_ds_id, 57 warp_id74 stage_id 58 75 HAVING 59 76 COUNT(warpSkyfile.skycell_id) = COUNT(magicDSFile.component) -
trunk/ippTools/share/magicdstool_todestreak.sql
r24174 r24683 67 67 AND chipProcessedImfile.fault = 0 68 68 AND chipProcessedImfile.quality = 0 69 AND magicDSFile.component IS NULL 70 UNION 71 -- camProcessedExp 72 SELECT DISTINCT 73 magicDSRun.magic_ds_id, 74 magicDSRun.magic_id, 75 chipRun.exp_id, 76 magicDSRun.label, 77 camera, 78 magicMask.uri as streaks_uri, 79 stage, 80 stage_id, 81 'exposure' as component, 82 NULL AS uri, 83 camProcessedExp.path_base, 84 magicRun.inverse, 85 camProcessedExp.path_base as cam_path_base, 86 outroot, 87 recoveryroot, 88 re_place, 89 remove 90 FROM magicDSRun 91 JOIN magicMask USING (magic_id) 92 JOIN magicRun USING(magic_id) 93 JOIN camRun ON magicDSRun.stage_id = camRun.cam_id 94 JOIN camProcessedExp ON camRun.cam_id = camProcessedExp.cam_id 95 JOIN chipRun USING(chip_id) 96 JOIN rawExp ON chipRun.exp_id = rawExp.exp_id 97 LEFT JOIN magicDSFile 98 ON magicDSRun.magic_ds_id = magicDSFile.magic_ds_id 99 WHERE 100 magicDSRun.state = 'new' 101 AND magicDSRun.stage = 'camera' 102 AND camRun.state = 'full' 103 AND chipRun.state = 'full' 104 AND chipRun.magicked 105 AND camProcessedExp.fault = 0 106 AND camProcessedExp.quality = 0 69 107 AND magicDSFile.component IS NULL 70 108 UNION -
trunk/ippTools/src/magicdstool.c
r24552 r24683 40 40 static bool toremoveMode(pxConfig *config); 41 41 static bool torestoreMode(pxConfig *config); 42 static bool torevertMode(pxConfig *config); 42 43 43 44 static bool setmagicDSRunState(pxConfig *config, psS64 magic_id, const char *state); … … 72 73 MODECASE(MAGICDSTOOL_MODE_TOREMOVE, toremoveMode); 73 74 MODECASE(MAGICDSTOOL_MODE_TORESTORE, torestoreMode); 75 MODECASE(MAGICDSTOOL_MODE_TOREVERT, torevertMode); 74 76 default: 75 77 psAbort("invalid option (this should not happen)"); … … 502 504 psS64 stage_id = psMetadataLookupS64(NULL, row, "stage_id"); 503 505 506 if (!strcmp(stage, "camera")) { 507 // no there is no magicked column in camProcessedExp 508 psFree(output); 509 return true; 510 } 504 511 505 512 // chose the appropriate query based on the stage … … 570 577 } else if (!strcmp(stage, "chip")) { 571 578 query = "UPDATE chipRun SET magicked = %" PRId64 " where chip_id = %" PRId64; 579 } else if (!strcmp(stage, "camera")) { 580 query = "UPDATE camRun SET magicked = %" PRId64 " where cam_id = %" PRId64; 572 581 } else if (!strcmp(stage, "warp")) { 573 582 query = "UPDATE warpRun SET magicked = %" PRId64 " where warp_id = %" PRId64; … … 674 683 } else if (!strcmp(stage, "chip")) { 675 684 stageNum = 1; 685 } else if (!strcmp(stage, "camera")) { 686 stageNum = 2; 676 687 } else if (!strcmp(stage, "warp")) { 677 stageNum = 2;688 stageNum = 3; 678 689 } else { 679 690 psError(PXTOOLS_ERR_DATA, true, "%s is not a valid value for stage", stage); … … 718 729 *stage_id = psMetadataLookupS64(NULL, row, "chip_id"); 719 730 } else if (stageNum == 2) { 731 *stage_id = *cam_id; 732 } else if (stageNum == 3) { 720 733 *stage_id = psMetadataLookupS64(NULL, row, "warp_id"); 721 734 } … … 1039 1052 return true; 1040 1053 } 1054 1055 1056 static bool torevertMode(pxConfig *config) 1057 { 1058 PS_ASSERT_PTR_NON_NULL(config, false); 1059 1060 psMetadata *where = psMetadataAlloc(); 1061 PXOPT_LOOKUP_STR(stage, config->args, "-stage", true, false); 1062 1063 PXOPT_COPY_S64(config->args, where, "-magic_ds_id", "magic_ds_id", "=="); 1064 PXOPT_COPY_S64(config->args, where, "-magic_id", "magic_id", "=="); 1065 pxAddLabelSearchArgs (config, where, "-label", "magicDSRun.label", "=="); 1066 1067 PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false); 1068 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 1069 1070 psString sql_file = NULL; 1071 psStringAppend(&sql_file, "magicdstool_torevert_%s.sql", stage); 1072 1073 psString query = pxDataGet(sql_file); 1074 if (!query) { 1075 psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement from %s", sql_file); 1076 psFree(sql_file); 1077 return false; 1078 } 1079 psFree(sql_file); 1080 1081 if (psListLength(where->list)) { 1082 psString whereClause = psDBGenerateWhereConditionSQL(where, NULL); 1083 psStringAppend(&query, " AND %s", whereClause); 1084 psFree(whereClause); 1085 } 1086 psFree(where); 1087 1088 // treat limit == 0 as "no limit" 1089 if (limit) { 1090 psString limitString = psDBGenerateLimitSQL(limit); 1091 psStringAppend(&query, " %s", limitString); 1092 psFree(limitString); 1093 } 1094 1095 if (!p_psDBRunQuery(config->dbh, query)) { 1096 psError(PS_ERR_UNKNOWN, false, "database error"); 1097 psFree(query); 1098 return false; 1099 } 1100 psFree(query); 1101 1102 psArray *output = p_psDBFetchResult(config->dbh); 1103 if (!output) { 1104 psErrorCode err = psErrorCodeLast(); 1105 switch (err) { 1106 case PS_ERR_DB_CLIENT: 1107 psError(PXTOOLS_ERR_SYS, false, "database error"); 1108 case PS_ERR_DB_SERVER: 1109 psError(PXTOOLS_ERR_PROG, false, "database error"); 1110 default: 1111 psError(PXTOOLS_ERR_PROG, false, "unknown error"); 1112 } 1113 1114 return false; 1115 } 1116 if (!psArrayLength(output)) { 1117 psTrace("magicdstool", PS_LOG_INFO, "no rows found"); 1118 psFree(output); 1119 return true; 1120 } 1121 1122 if (psArrayLength(output)) { 1123 // negative simple so the default is true 1124 if (!ippdbPrintMetadatas(stdout, output, "torevert", !simple)) { 1125 psError(PS_ERR_UNKNOWN, false, "failed to print array"); 1126 psFree(output); 1127 return false; 1128 } 1129 } 1130 1131 psFree(output); 1132 1133 return true; 1134 } 1135 1136 -
trunk/ippTools/src/magicdstool.h
r24284 r24683 34 34 MAGICDSTOOL_MODE_TOREMOVE, 35 35 MAGICDSTOOL_MODE_TORESTORE, 36 MAGICDSTOOL_MODE_TOREVERT, 36 37 } MAGICDStoolMode; 37 38 -
trunk/ippTools/src/magicdstoolConfig.c
r24284 r24683 130 130 psMetadataAddBool(torestoreArgs, PS_LIST_TAIL, "-simple", 0, "use the simple output format", false); 131 131 132 // -torevert 133 psMetadata *torevertArgs = psMetadataAlloc(); 134 psMetadataAddS64(torevertArgs, PS_LIST_TAIL, "-magic_ds_id", 0, "search by magic Destreak ID", 0); 135 psMetadataAddS64(torevertArgs, PS_LIST_TAIL, "-magic_id", 0, "search by magic ID", 0); 136 psMetadataAddStr(torevertArgs, PS_LIST_TAIL, "-stage", 0, "define output directory (required)", NULL); 137 psMetadataAddStr(torevertArgs, PS_LIST_TAIL, "-label", PS_META_DUPLICATE_OK, "define label", NULL); 138 psMetadataAddU64(torevertArgs, PS_LIST_TAIL, "-limit", 0, "limit result set to N items", 0); 139 psMetadataAddBool(torevertArgs, PS_LIST_TAIL, "-simple", 0, "use the simple output format", false); 140 132 141 psFree(now); 133 142 … … 153 162 PXOPT_ADD_MODE("-torestore", "images pending restore of exicsed streak pixels", 154 163 MAGICDSTOOL_MODE_TORESTORE, torestoreArgs); 164 PXOPT_ADD_MODE("-torevert", "faulted images to revert", 165 MAGICDSTOOL_MODE_TOREVERT, torevertArgs); 155 166 156 167 if (!pxGetOptions(stderr, argc, argv, config, modes, argSets)) {
Note:
See TracChangeset
for help on using the changeset viewer.
