Changeset 29625
- Timestamp:
- Nov 1, 2010, 12:51:37 PM (16 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 3 edited
- 1 copied
-
ippScripts/scripts/magic_process.pl (modified) (4 diffs)
-
ippTools/share/Makefile.am (modified) (2 diffs)
-
ippTools/share/magictool_deletemask.sql (added)
-
ippTools/share/magictool_setfull.sql (copied) (copied from trunk/ippTools/share/magictool_addmask.sql )
-
ippTools/src/magictool.c (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippScripts/scripts/magic_process.pl
r29524 r29625 325 325 } 326 326 327 ### Input result into database328 {329 my $command = "$magictool -addresult";330 $command .= " -magic_id $magic_id";331 $command .= " -node $node";332 $command .= " -path_base $outroot";333 $command .= " -dbname $dbname" if defined $dbname;334 335 # Add the processed file to the database336 unless ($no_update) {337 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =338 run(command => $command, verbose => $verbose);339 unless ($success) {340 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);341 &my_die("Unable to perform magictool -addresult: $error_code", $magic_id, $node, $error_code);342 }343 } else {344 print "Skipping command: $command\n";345 }346 }347 327 348 328 if ($node eq "root") { … … 376 356 my $exposures = $mdcParser->parse_list(join "", @$stdout_buf); 377 357 my $exp = $$exposures[0]; # Exposure of interest (should only be one) 358 if (!$exp) { 359 &my_die("magictool -exposure returned no output", $magic_id, $node, $PS_EXIT_UNKNOWN_ERROR); 360 } 378 361 379 362 $exp_id = $exp->{exp_id}; … … 429 412 unless ($success) { 430 413 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 431 # XXX: This my_die isn't going to work because the result for the root node was already432 # added to the database up above.433 # There is a magicMask has a fault column. Maybe we should434 # use that and add a new revert mode that deletes the magicMask and the magicNodeResult435 # for the root node.436 414 &my_die("Unable to perform magictool -addmask: $error_code", $magic_id, $node, $error_code); 437 415 } … … 439 417 print "Skipping command: $command\n"; 440 418 } 419 } 420 } 421 422 ### Input result into database 423 { 424 my $command = "$magictool -addresult"; 425 $command .= " -magic_id $magic_id"; 426 $command .= " -node $node"; 427 $command .= " -path_base $outroot"; 428 $command .= " -dbname $dbname" if defined $dbname; 429 430 # Add the processed file to the database 431 unless ($no_update) { 432 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 433 run(command => $command, verbose => $verbose); 434 unless ($success) { 435 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 436 # XXX: if this is the root node we need to revert delete the magicMask object 437 # inserted above 438 &my_die("Unable to perform magictool -addresult: $error_code", $magic_id, $node, $error_code); 439 } 440 } else { 441 print "Skipping command: $command\n"; 441 442 } 442 443 } -
trunk/ippTools/share/Makefile.am
r29611 r29625 213 213 flatcorr_dropchip.sql \ 214 214 flatcorr_dropcamera.sql \ 215 magictool_ addmask.sql \215 magictool_deletemask.sql \ 216 216 magictool_restore_camera.sql \ 217 217 magictool_restore_chip.sql \ … … 237 237 magictool_revertnode.sql \ 238 238 magictool_exposure.sql \ 239 magictool_setfull.sql \ 239 240 magicdstool_clearstatefaults.sql \ 240 241 magicdstool_change_file_data_state.sql \ -
trunk/ippTools/src/magictool.c
r29553 r29625 1059 1059 PXOPT_LOOKUP_S16(fault, config->args, "-fault", false, false); 1060 1060 1061 if (!psDBTransaction(config->dbh)) { 1062 psError(PS_ERR_UNKNOWN, false, "database error"); 1063 return false; 1064 } 1065 1061 1066 if (!magicNodeResultInsert(config->dbh, 1062 1067 magic_id, … … 1069 1074 } 1070 1075 1076 if (fault == 0 && !strcmp(node, "root")) { 1077 // Set the magicRun state 1078 psString query = pxDataGet("magictool_setfull.sql"); 1079 if (!query) { 1080 psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement"); 1081 if (!psDBRollback(config->dbh)) { 1082 psError(PS_ERR_UNKNOWN, false, "database error"); 1083 } 1084 return false; 1085 } 1086 1087 // manually add constraint 1088 psStringAppend(&query, " AND magic_id = %" PRId64, magic_id); 1089 1090 if (!p_psDBRunQuery(config->dbh, query)) { 1091 psError(PS_ERR_UNKNOWN, false, "database error"); 1092 psFree(query); 1093 if (!psDBRollback(config->dbh)) { 1094 psError(PS_ERR_UNKNOWN, false, "database error"); 1095 } 1096 return false; 1097 } 1098 psFree(query); 1099 } 1100 if (!psDBCommit(config->dbh)) { 1101 psError(PS_ERR_UNKNOWN, false, "database error"); 1102 return false; 1103 } 1104 1071 1105 return true; 1072 1106 } … … 1082 1116 pxAddLabelSearchArgs (config, where, "-label", "magicRun.label", "=="); 1083 1117 1084 psString query = pxDataGet("magictool_revertnode.sql"); 1118 if (!psListLength(where->list)) { 1119 psError(PS_ERR_UNKNOWN, false, "search parameters are required"); 1120 psFree(where); 1121 return false; 1122 } 1123 psString whereClause = psDBGenerateWhereConditionSQL(where, NULL); 1124 psFree(where); 1125 1126 // don't need a transaction because it is ok if the first query succeeds 1127 // but the second query does not 1128 psString query = pxDataGet("magictool_deletemask.sql"); 1085 1129 if (!query) { 1086 1130 psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement"); 1087 1131 return false; 1088 1132 } 1089 1090 if (psListLength(where->list)) { 1091 psString whereClause = psDBGenerateWhereConditionSQL(where, NULL); 1092 psStringAppend(&query, " AND %s", whereClause); 1133 psStringAppend(&query, " AND %s", whereClause); 1134 if (!p_psDBRunQuery(config->dbh, query)) { 1093 1135 psFree(whereClause); 1094 } else { 1095 psError(PS_ERR_UNKNOWN, false, "search parameters are required"); 1096 psFree(where); 1097 return false; 1098 } 1099 psFree(where); 1136 psFree(query); 1137 psError(PS_ERR_UNKNOWN, false, "failed to delete faulted masks"); 1138 return false; 1139 } 1140 psFree(query); 1141 1142 query = pxDataGet("magictool_revertnode.sql"); 1143 if (!query) { 1144 psFree(whereClause); 1145 psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement"); 1146 return false; 1147 } 1148 psStringAppend(&query, " AND %s", whereClause); 1149 psFree(whereClause); 1100 1150 1101 1151 if (!p_psDBRunQuery(config->dbh, query)) { 1152 psFree(query); 1102 1153 psError(PS_ERR_UNKNOWN, false, "failed to revert"); 1103 1154 return false; 1104 1155 } 1156 psFree(query); 1105 1157 1106 1158 psS32 numUpdated = psDBAffectedRows(config->dbh); … … 1180 1232 // required 1181 1233 PXOPT_LOOKUP_S64(magic_id, config->args, "-magic_id", true, false); 1234 PXOPT_LOOKUP_STR(path_base, config->args, "-path_base", true, false); 1182 1235 1183 1236 // optional 1184 // PXOPT_LOOKUP_STR(uri, config->args, "-uri", false, false);1185 PXOPT_LOOKUP_STR(path_base, config->args, "-path_base", true, false);1186 1237 PXOPT_LOOKUP_S32(streaks, config->args, "-streaks", false, false); 1187 1188 // default values1189 1238 PXOPT_LOOKUP_S16(fault, config->args, "-fault", false, false); 1190 1191 if (!psDBTransaction(config->dbh)) {1192 psError(PS_ERR_UNKNOWN, false, "database error");1193 return false;1194 }1195 1239 1196 1240 if (!magicMaskInsert(config->dbh, … … 1205 1249 psError(PS_ERR_UNKNOWN, false, "database error"); 1206 1250 } 1207 return false;1208 }1209 1210 // Set the magicRun state1211 psString query = pxDataGet("magictool_addmask.sql");1212 if (!query) {1213 psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement");1214 if (!psDBRollback(config->dbh)) {1215 psError(PS_ERR_UNKNOWN, false, "database error");1216 }1217 return false;1218 }1219 1220 // manually add constraint1221 psStringAppend(&query, " AND magic_id = %" PRId64, magic_id);1222 1223 if (!p_psDBRunQuery(config->dbh, query)) {1224 psError(PS_ERR_UNKNOWN, false, "database error");1225 psFree(query);1226 if (!psDBRollback(config->dbh)) {1227 psError(PS_ERR_UNKNOWN, false, "database error");1228 }1229 return false;1230 }1231 psFree(query);1232 1233 if (!psDBCommit(config->dbh)) {1234 psError(PS_ERR_UNKNOWN, false, "database error");1235 1251 return false; 1236 1252 }
Note:
See TracChangeset
for help on using the changeset viewer.
