Changeset 25423
- Timestamp:
- Sep 16, 2009, 5:05:19 PM (17 years ago)
- Location:
- trunk
- Files:
-
- 1 deleted
- 11 edited
-
ippScripts/scripts/magic_destreak_revert.pl (modified) (3 diffs)
-
ippTasks/destreak.pro (modified) (7 diffs)
-
ippTools/share/Makefile.am (modified) (2 diffs)
-
ippTools/share/magicdstool_torestore.sql (deleted)
-
ippTools/share/magicdstool_torevert_camera.sql (modified) (2 diffs)
-
ippTools/share/magicdstool_torevert_chip.sql (modified) (2 diffs)
-
ippTools/share/magicdstool_torevert_diff.sql (modified) (2 diffs)
-
ippTools/share/magicdstool_torevert_raw.sql (modified) (2 diffs)
-
ippTools/share/magicdstool_torevert_warp.sql (modified) (2 diffs)
-
ippTools/src/magicdstool.c (modified) (11 diffs)
-
ippTools/src/magicdstool.h (modified) (1 diff)
-
ippTools/src/magicdstoolConfig.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippScripts/scripts/magic_destreak_revert.pl
r25383 r25423 191 191 } 192 192 193 revert_files($ image, $mask, $weight, $sources, $astrom, $bimage, $bmask, $bweight, $bsources, $bastrom);193 revert_files($replace, $image, $mask, $weight, $sources, $astrom, $bimage, $bmask, $bweight, $bsources, $bastrom); 194 194 195 195 if ($stage eq "diff") { … … 203 203 $bweight = $ipprc->filename("$name.VARIANCE", $backup_path_base); 204 204 $bsources = $ipprc->filename("$name.SOURCES", $backup_path_base); 205 revert_files($ image, $mask, $weight, $sources, undef, $bimage, $bmask, $bweight, $bsources, undef);205 revert_files($replace, $image, $mask, $weight, $sources, undef, $bimage, $bmask, $bweight, $bsources, undef); 206 206 } 207 207 208 208 # now revert the row in the database 209 209 { 210 my $command = "$magicdstool -revertdestreakedfile ";210 my $command = "$magicdstool -revertdestreakedfile -i_am_sure"; 211 211 $command .= " -magic_ds_id $magic_ds_id"; 212 212 $command .= " -component $component"; … … 231 231 232 232 sub revert_files { 233 my $replace = shift; 234 return if !$replace; 235 233 236 my $image = shift; 234 237 my $mask = shift; -
trunk/ippTasks/destreak.pro
r25419 r25423 11 11 book init magicDSToRevert 12 12 13 ### Database lists13 ### indexes into Database lists 14 14 $magicToDS_DB = 0 15 15 $magicDSToRevert_DB = 0 16 $magicDSCompletedRevert_DB = 0 16 17 17 18 #list of stages … … 28 29 ### Check status of tasks 29 30 macro magic.status 30 book listbook magicToDS31 book listbook magicDSToRevert31 book listbook magicToDS 32 book listbook magicDSToRevert 32 33 end 33 34 34 35 ### Reset tasks 35 36 macro magic.reset 36 book init magicToDS37 book init magicDSToRevert37 book init magicToDS 38 book init magicDSToRevert 38 39 end 39 40 40 41 ### Turn tasks on 41 42 macro destreak.on 42 task destreak.load43 active true44 end45 task destreak.run46 active true47 end43 task destreak.load 44 active true 45 end 46 task destreak.run 47 active true 48 end 48 49 end 49 50 … … 55 56 active true 56 57 end 57 end 58 task destreak.completed.revert 59 active true 60 end 61 end 62 58 63 ### Turn tasks off 59 64 macro destreak.off 60 task destreak.load61 active false62 end63 task destreak.run64 active false65 end65 task destreak.load 66 active false 67 end 68 task destreak.run 69 active false 70 end 66 71 end 67 72 … … 71 76 end 72 77 task destreak.revert.run 78 active false 79 end 80 task destreak.completed.revert 73 81 active false 74 82 end … … 363 371 364 372 task destreak.completed.revert 373 # task to finish processing for magicDSRuns being reverted or restored 365 374 host local 366 375 367 376 periods -poll $LOADPOLL 368 periods -exec $LOADEXEC 377 #periods -exec $LOADEXEC 378 periods -exec 30 369 379 periods -timeout 20 370 380 npending 1 … … 380 390 else 381 391 # save the DB name for the exit tasks 382 option $DB:$magicDSToRevert_DB 383 $run = $run -dbname $DB:$magicDSToRevert_DB 392 option $DB:$magicDSCompletedRevert_DB 393 394 $run = $run -dbname $DB:$magicDSCompletedRevert_DB 395 396 if ($magicDSCompletedRevert_DB >= $DB:n) set magicDSCompletedRevert_DB = 0 384 397 end 385 398 add_poll_args run … … 390 403 # success 391 404 task.exit 0 392 # convert 'stdout' to book format393 ipptool2book stdout magicDSToRevert -key magic_ds_id:component -uniq -setword dbname $options:0 -setword pantaskState INIT394 if ($VERBOSE > 2)395 book listbook magicDSToRevert396 end397 398 # delete existing entries in the appropriate pantaskStates399 process_cleanup magicDSToRevert400 405 end 401 406 -
trunk/ippTools/share/Makefile.am
r25419 r25423 173 173 magicdstool_getrunids.sql \ 174 174 magicdstool_getskycells.sql \ 175 magicdstool_revertdestreakedfile.sql \ 175 176 magicdstool_todestreak_camera.sql \ 176 177 magicdstool_todestreak_chip.sql \ … … 179 180 magicdstool_todestreak_warp.sql \ 180 181 magicdstool_toremove.sql \ 181 magicdstool_torestore.sql \182 182 magicdstool_torevert_raw.sql \ 183 183 magicdstool_torevert_chip.sql \ -
trunk/ippTools/share/magicdstool_torevert_camera.sql
r25419 r25423 1 1 SELECT 2 2 magic_ds_id, 3 magicDSRun.state, 3 4 exp_id, 4 5 re_place, … … 20 21 WHERE magicDSRun.stage = 'camera' 21 22 AND ((magicDSRun.state = 'new' AND magicDSFile.fault > 0) 22 OR magicDSRun.state = 'goto_censored' 23 OR magicDSRun.state = 'goto_restored') 23 OR ((magicDSRun.state = 'goto_censored' OR magicDSRun.state = 'goto_restored') 24 AND (backup_path_base IS NOT NULL) 25 ) 26 ) -
trunk/ippTools/share/magicdstool_torevert_chip.sql
r25419 r25423 1 1 SELECT 2 2 magic_ds_id, 3 magicDSRun.state, 3 4 exp_id, 4 5 re_place, … … 19 20 WHERE magicDSRun.stage = 'chip' 20 21 AND ((magicDSRun.state = 'new' AND magicDSFile.fault > 0) 21 OR magicDSRun.state = 'goto_censored' 22 OR magicDSRun.state = 'goto_restored') 22 OR ((magicDSRun.state = 'goto_censored' OR magicDSRun.state = 'goto_restored') 23 AND ((backup_path_base IS NOT NULL) OR (recovery_path_base IS NOT NULL)) 24 ) 25 ) -
trunk/ippTools/share/magicdstool_torevert_diff.sql
r25419 r25423 1 1 SELECT 2 2 magic_ds_id, 3 magicDSRun.state, 3 4 exp_id, 4 5 re_place, … … 19 20 WHERE magicDSRun.stage = 'diff' 20 21 AND ((magicDSRun.state = 'new' AND magicDSFile.fault > 0) 21 OR magicDSRun.state = 'goto_censored' 22 OR magicDSRun.state = 'goto_restored') 22 OR ((magicDSRun.state = 'goto_censored' OR magicDSRun.state = 'goto_restored') 23 AND ((backup_path_base IS NOT NULL) OR (recovery_path_base IS NOT NULL)) 24 ) 25 ) -
trunk/ippTools/share/magicdstool_torevert_raw.sql
r25419 r25423 1 1 SELECT 2 2 magic_ds_id, 3 magicDSRun.state, 3 4 exp_id, 4 5 re_place, … … 15 16 JOIN magicDSFile using(magic_ds_id) 16 17 JOIN rawImfile ON (stage_id = exp_id AND component = class_id) 17 JOIN summitImfile ON (rawImfile.exp_name = summitImfile.exp_name18 AND rawImfile.tmp_class_id = summitImfile.class_id)19 18 WHERE magicDSRun.stage = 'raw' 20 19 AND ((magicDSRun.state = 'new' AND magicDSFile.fault > 0) 21 OR magicDSRun.state = 'goto_censored' 22 OR magicDSRun.state = 'goto_restored') 20 OR ((magicDSRun.state = 'goto_censored' OR magicDSRun.state = 'goto_restored') 21 AND ((backup_path_base IS NOT NULL) OR (recovery_path_base IS NOT NULL)) 22 ) 23 ) -
trunk/ippTools/share/magicdstool_torevert_warp.sql
r25419 r25423 1 1 SELECT 2 2 magic_ds_id, 3 magicDSRun.state, 3 4 exp_id, 4 5 re_place, … … 22 23 WHERE magicDSRun.stage = 'warp' 23 24 AND ((magicDSRun.state = 'new' AND magicDSFile.fault > 0) 24 OR magicDSRun.state = 'goto_censored' 25 OR magicDSRun.state = 'goto_restored') 25 OR ((magicDSRun.state = 'goto_censored' OR magicDSRun.state = 'goto_restored') 26 AND ((backup_path_base IS NOT NULL) OR (recovery_path_base IS NOT NULL)) 27 ) 28 ) -
trunk/ippTools/src/magicdstool.c
r25419 r25423 40 40 static bool getskycellsMode(pxConfig *config); 41 41 static bool toremoveMode(pxConfig *config); 42 static bool torestoreMode(pxConfig *config);43 42 static bool torevertMode(pxConfig *config); 44 43 static bool completedrevertMode(pxConfig *config); … … 74 73 MODECASE(MAGICDSTOOL_MODE_GETSKYCELLS, getskycellsMode); 75 74 MODECASE(MAGICDSTOOL_MODE_TOREMOVE, toremoveMode); 76 MODECASE(MAGICDSTOOL_MODE_TORESTORE, torestoreMode);77 75 MODECASE(MAGICDSTOOL_MODE_TOREVERT, torevertMode); 78 76 MODECASE(MAGICDSTOOL_MODE_COMPLETEDREVERT, completedrevertMode); … … 401 399 402 400 psMetadata *where = psMetadataAlloc(); 403 PXOPT_COPY_S64(config->args, where, "-magic_ds_id", "magic _ds_id", "==");401 PXOPT_COPY_S64(config->args, where, "-magic_ds_id", "magicDSRun.magic_ds_id", "=="); 404 402 PXOPT_COPY_S64(config->args, where, "-magic_id", "magic_id", "=="); 405 403 pxAddLabelSearchArgs (config, where, "-label", "magicDSRun.label", "=="); … … 803 801 PS_ASSERT_PTR_NON_NULL(config, false); 804 802 803 PXOPT_LOOKUP_BOOL(i_am_sure, config->args, "-i_am_sure", true); 804 if (!i_am_sure) { 805 psError(PS_ERR_UNKNOWN, true, "Reverting destreaked files must be done carefully. -i_am_sure is required."); 806 return false; 807 } 808 805 809 psMetadata *where = psMetadataAlloc(); 806 810 PXOPT_COPY_S64(config->args, where, "-magic_ds_id", "magicDSRun.magic_ds_id", "=="); … … 809 813 pxAddLabelSearchArgs (config, where, "-label", "label", "=="); 810 814 811 psString query = p sStringCopy("DELETE FROM magicDSFile USING magicDSFile, magicDSRun WHERE (magicDSRun.magic_ds_id = magicDSFile.magic_ds_id) AND magicDSFile.fault != 0");815 psString query = pxDataGet("magicdstool_revertdestreakedfile.sql"); 812 816 813 817 if (psListLength(where->list)) { … … 815 819 psStringAppend(&query, " AND %s", whereClause); 816 820 psFree(whereClause); 821 } else { 822 psError(PS_ERR_UNKNOWN, true, "search arguments are required"); 823 return false; 817 824 } 818 825 psFree(where); … … 820 827 if (!p_psDBRunQuery(config->dbh, query)) { 821 828 psError(PS_ERR_UNKNOWN, false, "failed to revert"); 822 return false; 823 } 829 psFree(query); 830 return false; 831 } 832 psFree(query); 824 833 return true; 825 834 } … … 891 900 } 892 901 char *query2 = "UPDATE magicDSRun SET state = '%s' WHERE magic_ds_id = %" PRId64; 893 if (!p_psDBRunQueryF(config->dbh, query2, magic_ds_id, new_state)) {902 if (!p_psDBRunQueryF(config->dbh, query2, new_state, magic_ds_id)) { 894 903 psError(PS_ERR_UNKNOWN, false, "failed to set run magicDSRun.state to %s", new_state); 895 904 return false; … … 971 980 972 981 // check that state is a valid string value 973 if (!( 974 (strncmp(state, "new", 4) == 0) 975 || (strncmp(state, "full", 5) == 0) 976 ) 977 ) { 982 if (!((strcmp(state, "new") == 0) || 983 (strcmp(state, "full") == 0) || 984 (strcmp(state, "restored") == 0) || 985 (strcmp(state, "censored") == 0) || 986 (strcmp(state, "purged") == 0) || 987 (strcmp(state, "goto_restored") == 0) || 988 (strcmp(state, "goto_censored") == 0) || 989 (strcmp(state, "goto_purged") == 0)) 990 ) { 978 991 psError(PS_ERR_UNKNOWN, false, 979 992 "invalid magicDSRun state: %s", state); … … 1064 1077 return true; 1065 1078 } 1066 static bool torestoreMode(pxConfig *config) 1079 1080 static bool torevertMode(pxConfig *config) 1067 1081 { 1068 1082 PS_ASSERT_PTR_NON_NULL(config, false); 1069 1083 1070 1084 psMetadata *where = psMetadataAlloc(); 1085 PXOPT_LOOKUP_STR(stage, config->args, "-stage", true, false); 1086 1071 1087 PXOPT_COPY_S64(config->args, where, "-magic_ds_id", "magic_ds_id", "=="); 1072 1088 PXOPT_COPY_S64(config->args, where, "-magic_id", "magic_id", "=="); 1073 pxAddLabelSearchArgs (config, where, "-label", " label", "==");1089 pxAddLabelSearchArgs (config, where, "-label", "magicDSRun.label", "=="); 1074 1090 1075 1091 PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false); 1076 1092 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 1077 1093 1078 // look for "inputs" that need to processed 1079 psString query = pxDataGet("magicdstool_torestore.sql"); 1094 psString sql_file = NULL; 1095 psStringAppend(&sql_file, "magicdstool_torevert_%s.sql", stage); 1096 1097 psString query = pxDataGet(sql_file); 1080 1098 if (!query) { 1081 psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement"); 1082 return false; 1083 } 1099 psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement from %s", sql_file); 1100 psFree(sql_file); 1101 return false; 1102 } 1103 psFree(sql_file); 1084 1104 1085 1105 if (psListLength(where->list)) { 1086 1106 psString whereClause = psDBGenerateWhereConditionSQL(where, NULL); 1087 psStringAppend(&query, " WHERE%s", whereClause);1107 psStringAppend(&query, " AND %s", whereClause); 1088 1108 psFree(whereClause); 1089 1109 } … … 1126 1146 if (psArrayLength(output)) { 1127 1147 // negative simple so the default is true 1128 if (!ippdbPrintMetadatas(stdout, output, "torestore", !simple)) {1129 psError(PS_ERR_UNKNOWN, false, "failed to print array");1130 psFree(output);1131 return false;1132 }1133 }1134 1135 psFree(output);1136 1137 return true;1138 }1139 1140 1141 static bool torevertMode(pxConfig *config)1142 {1143 PS_ASSERT_PTR_NON_NULL(config, false);1144 1145 psMetadata *where = psMetadataAlloc();1146 PXOPT_LOOKUP_STR(stage, config->args, "-stage", true, false);1147 1148 PXOPT_COPY_S64(config->args, where, "-magic_ds_id", "magic_ds_id", "==");1149 PXOPT_COPY_S64(config->args, where, "-magic_id", "magic_id", "==");1150 pxAddLabelSearchArgs (config, where, "-label", "magicDSRun.label", "==");1151 1152 PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false);1153 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false);1154 1155 psString sql_file = NULL;1156 psStringAppend(&sql_file, "magicdstool_torevert_%s.sql", stage);1157 1158 psString query = pxDataGet(sql_file);1159 if (!query) {1160 psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement from %s", sql_file);1161 psFree(sql_file);1162 return false;1163 }1164 psFree(sql_file);1165 1166 if (psListLength(where->list)) {1167 psString whereClause = psDBGenerateWhereConditionSQL(where, NULL);1168 psStringAppend(&query, " AND %s", whereClause);1169 psFree(whereClause);1170 }1171 psFree(where);1172 1173 // treat limit == 0 as "no limit"1174 if (limit) {1175 psString limitString = psDBGenerateLimitSQL(limit);1176 psStringAppend(&query, " %s", limitString);1177 psFree(limitString);1178 }1179 1180 if (!p_psDBRunQuery(config->dbh, query)) {1181 psError(PS_ERR_UNKNOWN, false, "database error");1182 psFree(query);1183 return false;1184 }1185 psFree(query);1186 1187 psArray *output = p_psDBFetchResult(config->dbh);1188 if (!output) {1189 psErrorCode err = psErrorCodeLast();1190 switch (err) {1191 case PS_ERR_DB_CLIENT:1192 psError(PXTOOLS_ERR_SYS, false, "database error");1193 case PS_ERR_DB_SERVER:1194 psError(PXTOOLS_ERR_PROG, false, "database error");1195 default:1196 psError(PXTOOLS_ERR_PROG, false, "unknown error");1197 }1198 1199 return false;1200 }1201 if (!psArrayLength(output)) {1202 psTrace("magicdstool", PS_LOG_INFO, "no rows found");1203 psFree(output);1204 return true;1205 }1206 1207 if (psArrayLength(output)) {1208 // negative simple so the default is true1209 1148 if (!ippdbPrintMetadatas(stdout, output, "torevert", !simple)) { 1210 1149 psError(PS_ERR_UNKNOWN, false, "failed to print array"); -
trunk/ippTools/src/magicdstool.h
r25419 r25423 33 33 MAGICDSTOOL_MODE_GETSKYCELLS, 34 34 MAGICDSTOOL_MODE_TOREMOVE, 35 MAGICDSTOOL_MODE_TORESTORE,36 35 MAGICDSTOOL_MODE_TOREVERT, 37 36 MAGICDSTOOL_MODE_COMPLETEDREVERT, -
trunk/ippTools/src/magicdstoolConfig.c
r25419 r25423 114 114 psMetadataAddStr(revertdestreakedfileArgs, PS_LIST_TAIL, "-component", 0, "search by component", NULL); 115 115 psMetadataAddS16(revertdestreakedfileArgs, PS_LIST_TAIL, "-fault", 0, "search by fault code", 0); 116 psMetadataAddBool(revertdestreakedfileArgs, PS_LIST_TAIL, "-i_am_sure", 0, "confirm that you know what you are doing", false); 116 117 psMetadataAddStr(revertdestreakedfileArgs, PS_LIST_TAIL, "-label", PS_META_DUPLICATE_OK, "define label", NULL); 117 118 118 119 // -getskycells 119 120 psMetadata *getskycellsArgs = psMetadataAlloc(); 120 psMetadataAddS64(getskycellsArgs, PS_LIST_TAIL, "-magic_ds_id", 0, "define magic de-streak ID (required)", 0);121 psMetadataAddS64(getskycellsArgs, PS_LIST_TAIL, "-magic_ds_id", 0, "define magic de-streak ID", 0); 121 122 psMetadataAddStr(getskycellsArgs, PS_LIST_TAIL, "-class_id", 0, "define class identifier", NULL); 122 123 psMetadataAddStr(getskycellsArgs, PS_LIST_TAIL, "-skycell_id", 0, "define skycell identifier", NULL); … … 130 131 psMetadataAddU64(toremoveArgs, PS_LIST_TAIL, "-limit", 0, "limit result set to N items", 0); 131 132 psMetadataAddBool(toremoveArgs, PS_LIST_TAIL, "-simple", 0, "use the simple output format", false); 132 133 // -torestore134 psMetadata *torestoreArgs = psMetadataAlloc();135 psMetadataAddS64(torestoreArgs, PS_LIST_TAIL, "-magic_ds_id", 0, "search by magic Destreak ID", 0);136 psMetadataAddS64(torestoreArgs, PS_LIST_TAIL, "-magic_id", 0, "search by magic ID", 0);137 psMetadataAddStr(torestoreArgs, PS_LIST_TAIL, "-label", PS_META_DUPLICATE_OK, "define label", NULL);138 psMetadataAddU64(torestoreArgs, PS_LIST_TAIL, "-limit", 0, "limit result set to N items", 0);139 psMetadataAddBool(torestoreArgs, PS_LIST_TAIL, "-simple", 0, "use the simple output format", false);140 133 141 134 // -torevert … … 175 168 PXOPT_ADD_MODE("-toremove", "backup images pending removal", 176 169 MAGICDSTOOL_MODE_TOREMOVE, toremoveArgs); 177 PXOPT_ADD_MODE("-torestore", "images pending restore of exicsed streak pixels", 178 MAGICDSTOOL_MODE_TORESTORE, torestoreArgs); 179 PXOPT_ADD_MODE("-torevert", "faulted images to revert", 170 PXOPT_ADD_MODE("-torevert", "images to restore or revert", 180 171 MAGICDSTOOL_MODE_TOREVERT, torevertArgs); 181 172
Note:
See TracChangeset
for help on using the changeset viewer.
