Changeset 16102
- Timestamp:
- Jan 16, 2008, 4:46:28 PM (18 years ago)
- File:
-
- 1 edited
-
branches/end_stage/ippTools/src/magictool.c (modified) (20 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/end_stage/ippTools/src/magictool.c
r15504 r16102 262 262 PS_ASSERT_PTR_NON_NULL(config, false); 263 263 264 // required options 265 bool status = false; 266 psString workdir = psMetadataLookupStr(&status, config->args, "-workdir"); 267 if (!status) { 268 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -workdir"); 269 return false; 270 } 271 if (!workdir) { 272 psError(PS_ERR_UNKNOWN, true, "-workdir is required"); 273 return false; 274 } 275 276 psString label = psMetadataLookupStr(&status, config->args, "-label"); 277 if (!status) { 278 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -label"); 279 return false; 280 } 281 282 psString dvodb = psMetadataLookupStr(&status, config->args, "-dvodb"); 283 if (!status) { 284 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -dvodb"); 285 return false; 286 } 264 // required 265 PXOPT_LOOKUP_STR(workdir, config->args, "-workdir", true, false); 266 267 // optional 268 PXOPT_LOOKUP_STR(label, config->args, "-label", false, false); 269 PXOPT_LOOKUP_STR(dvodb, config->args, "-dvodb", false, false); 270 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 287 271 288 272 psTime *registered = NULL; 289 273 { 274 bool status; 290 275 psString registeredStr = psMetadataLookupStr(&status, config->args, "-registered"); 291 276 if (!status) { … … 325 310 run->magic_id = magic_id; 326 311 327 bool simple = false;328 {329 bool status = false;330 simple = psMetadataLookupBool(&status, config->args, "-simple");331 if (!status) {332 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -simple");333 psFree(run);334 return false;335 }336 }337 338 312 if (!magicRunPrintObject(stdout, run, !simple)) { 339 313 psError(PS_ERR_UNKNOWN, false, "failed to print object"); … … 352 326 PS_ASSERT_PTR_NON_NULL(config, false); 353 327 354 bool status = false; 355 psString magic_id = psMetadataLookupStr(&status, config->args, "-magic_id"); 356 if (!status) { 357 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -magic_id"); 358 return false; 359 } 360 if (!magic_id) { 361 psError(PS_ERR_UNKNOWN, true, "-magic_id is required"); 362 return false; 363 } 364 365 psString state = psMetadataLookupStr(&status, config->args, "-state"); 366 if (!status) { 367 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -state"); 368 return false; 369 } 370 if (!state) { 371 psError(PS_ERR_UNKNOWN, true, "-state is required"); 372 return false; 373 } 328 // required 329 PXOPT_LOOKUP_STR(magic_id, config->args, "-magic_id", true, false); 330 PXOPT_LOOKUP_STR(state, config->args, "-state", true, false); 374 331 375 332 if (state) { … … 386 343 PS_ASSERT_PTR_NON_NULL(config, false); 387 344 388 bool status = false; 389 psString magic_id = psMetadataLookupStr(&status, config->args, "-magic_id"); 390 if (!status) { 391 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -magic_id"); 392 return false; 393 } 394 if (!magic_id) { 395 psError(PS_ERR_UNKNOWN, true, "-magic_id is required"); 396 return false; 397 } 398 399 psString diff_id = psMetadataLookupStr(&status, config->args, "-diff_id"); 400 if (!status) { 401 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -diff_id"); 402 return false; 403 } 404 if (!diff_id) { 405 psError(PS_ERR_UNKNOWN, true, "-diff_id is required"); 406 return false; 407 } 408 409 psString node = psMetadataLookupStr(&status, config->args, "-node"); 410 if (!status) { 411 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -node"); 412 return false; 413 } 414 if (!node) { 415 psError(PS_ERR_UNKNOWN, true, "-node is required"); 416 return false; 417 } 345 // required 346 PXOPT_LOOKUP_STR(magic_id, config->args, "-magic_id", true, false); 347 PXOPT_LOOKUP_STR(diff_id, config->args, "-diff_id", true, false); 348 PXOPT_LOOKUP_STR(node, config->args, "-node", true, false); 418 349 419 350 magicInputSkyfileInsert( … … 432 363 PS_ASSERT_PTR_NON_NULL(config, false); 433 364 434 bool status = false; 435 psU64 limit = psMetadataLookupU64(&status, config->args, "-limit"); 436 if (!status) { 437 psError(PXTOOLS_ERR_PROG, false, "failed to lookup value for -limit"); 438 return false; 439 } 365 PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false); 366 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 440 367 441 368 // find all rawImfiles matching the default query … … 486 413 } 487 414 488 bool simple = false;489 {490 bool status = false;491 simple = psMetadataLookupBool(&status, config->args, "-simple");492 if (!status) {493 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -simple");494 return false;495 }496 }497 498 415 if (psArrayLength(output)) { 499 416 if (!convertIdToStr(output)) { … … 521 438 PS_ASSERT_PTR_NON_NULL(config, false); 522 439 523 bool status = false; 524 psString magic_id = psMetadataLookupStr(&status, config->args, "-magic_id"); 525 if (!status) { 526 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -magic_id"); 527 return false; 528 } 529 if (!magic_id) { 530 psError(PS_ERR_UNKNOWN, true, "-magic_id is required"); 531 return false; 532 } 533 534 psString dep_file = psMetadataLookupStr(&status, config->args, "-dep_file"); 535 if (!status) { 536 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -dep_file"); 537 return false; 538 } 539 if (!dep_file) { 540 psError(PS_ERR_UNKNOWN, true, "-dep_file is required"); 541 return false; 542 } 440 // required 441 PXOPT_LOOKUP_STR(magic_id, config->args, "-magic_id", true, false); 442 PXOPT_LOOKUP_STR(dep_file, config->args, "-dep_file", true, false); 543 443 544 444 if (!parseAndInsertNodeDeps(config, (psS64)atoll(magic_id), dep_file)) { 445 psError(PS_ERR_UNKNOWN, false, "failed to parse file"); 446 return false; 545 447 } 546 448 … … 619 521 PS_ASSERT_PTR_NON_NULL(config, false); 620 522 621 bool status = false; 622 psString magic_id = psMetadataLookupStr(&status, config->args, "-magic_id"); 623 if (!status) { 624 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -magic_id"); 625 return false; 626 } 523 PXOPT_LOOKUP_STR(magic_id, config->args, "-magic_id", false, false); 524 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 627 525 628 526 // look for "inputs" that need to processed … … 632 530 return false; 633 531 } 634 635 532 636 533 if (magic_id) { … … 718 615 // convert the array of metadata into a pxTree structure 719 616 for (long i = 0; i < psArrayLength(magicTree); i++) { 617 bool status; 720 618 psString node = psMetadataLookupStr(&status, magicTree->data[i], "node"); 721 619 if (!status) { … … 743 641 psFree(root); 744 642 745 bool simple = false;746 {747 bool status = false;748 simple = psMetadataLookupBool(&status, config->args, "-simple");749 if (!status) {750 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -simple");751 return false;752 }753 }754 755 643 if (psArrayLength(output)) { 756 644 if (!convertIdToStr(output)) { … … 778 666 PS_ASSERT_PTR_NON_NULL(config, false); 779 667 780 bool status = false; 781 psString magic_id = psMetadataLookupStr(&status, config->args, "-magic_id"); 782 if (!status) { 783 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -magic_id"); 784 return false; 785 } 786 if (!magic_id) { 787 psError(PS_ERR_UNKNOWN, true, "-magic_id is required"); 788 return false; 789 } 790 791 psString node = psMetadataLookupStr(&status, config->args, "-node"); 792 if (!status) { 793 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -node"); 794 return false; 795 } 796 if (!node) { 797 psError(PS_ERR_UNKNOWN, true, "-node is required"); 798 return false; 799 } 800 801 psString uri = psMetadataLookupStr(&status, config->args, "-uri"); 802 if (!status) { 803 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -uri"); 804 return false; 805 } 806 if (!uri) { 807 psError(PS_ERR_UNKNOWN, true, "-uri is required"); 808 return false; 809 } 668 // required 669 PXOPT_LOOKUP_STR(magic_id, config->args, "-magic_id", true, false); 670 PXOPT_LOOKUP_STR(node, config->args, "-node", true, false); 671 PXOPT_LOOKUP_STR(uri, config->args, "-uri", true, false); 810 672 811 673 if (!magicNodeResultInsert(config->dbh, … … 826 688 PS_ASSERT_PTR_NON_NULL(config, false); 827 689 828 bool status = false; 829 psU64 limit = psMetadataLookupU64(&status, config->args, "-limit"); 830 if (!status) { 831 psError(PXTOOLS_ERR_PROG, false, "failed to lookup value for -limit"); 832 return false; 833 } 690 PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false); 691 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 834 692 835 693 // look for "inputs" that need to processed … … 874 732 } 875 733 876 bool simple = false;877 {878 bool status = false;879 simple = psMetadataLookupBool(&status, config->args, "-simple");880 if (!status) {881 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -simple");882 return false;883 }884 }885 886 734 if (psArrayLength(output)) { 887 735 if (!convertIdToStr(output)) { … … 909 757 PS_ASSERT_PTR_NON_NULL(config, false); 910 758 911 bool status = false; 912 psString magic_id = psMetadataLookupStr(&status, config->args, "-magic_id"); 913 if (!status) { 914 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -magic_id"); 915 return false; 916 } 917 if (!magic_id) { 918 psError(PS_ERR_UNKNOWN, true, "-magic_id is required"); 919 return false; 920 } 921 922 psString uri = psMetadataLookupStr(&status, config->args, "-uri"); 923 if (!status) { 924 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -uri"); 925 return false; 926 } 927 if (!uri) { 928 psError(PS_ERR_UNKNOWN, true, "-uri is required"); 929 return false; 930 } 759 // required 760 PXOPT_LOOKUP_STR(magic_id, config->args, "-magic_id", true, false); 761 PXOPT_LOOKUP_STR(uri, config->args, "-uri", true, false); 931 762 932 763 if (!magicMaskInsert(config->dbh, … … 946 777 PS_ASSERT_PTR_NON_NULL(config, false); 947 778 948 bool status = false; 949 psU64 limit = psMetadataLookupU64(&status, config->args, "-limit"); 950 if (!status) { 951 psError(PXTOOLS_ERR_PROG, false, "failed to lookup value for -limit"); 952 return false; 953 } 779 PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false); 780 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 954 781 955 782 psString query = pxDataGet("magictool_toskyfilemask.sql"); … … 993 820 } 994 821 995 bool simple = false;996 {997 bool status = false;998 simple = psMetadataLookupBool(&status, config->args, "-simple");999 if (!status) {1000 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -simple");1001 return false;1002 }1003 }1004 1005 822 if (psArrayLength(output)) { 1006 823 if (!convertIdToStr(output)) { … … 1028 845 PS_ASSERT_PTR_NON_NULL(config, false); 1029 846 1030 bool status = false; 1031 psString magic_id = psMetadataLookupStr(&status, config->args, "-magic_id"); 1032 if (!status) { 1033 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -magic_id"); 1034 return false; 1035 } 1036 if (!magic_id) { 1037 psError(PS_ERR_UNKNOWN, true, "-magic_id is required"); 1038 return false; 1039 } 1040 1041 psString diff_id = psMetadataLookupStr(&status, config->args, "-diff_id"); 1042 if (!status) { 1043 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -diff_id"); 1044 return false; 1045 } 1046 if (!diff_id) { 1047 psError(PS_ERR_UNKNOWN, true, "-diff_id is required"); 1048 return false; 1049 } 1050 1051 psString uri = psMetadataLookupStr(&status, config->args, "-uri"); 1052 if (!status) { 1053 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -uri"); 1054 return false; 1055 } 1056 if (!uri) { 1057 psError(PS_ERR_UNKNOWN, true, "-uri is required"); 1058 return false; 1059 } 847 // required 848 PXOPT_LOOKUP_STR(magic_id, config->args, "-magic_id", true, false); 849 PXOPT_LOOKUP_STR(diff_id, config->args, "diff_id", true, false); 850 PXOPT_LOOKUP_STR(uri, config->args, "uri", true, false); 1060 851 1061 852 if (!magicSkyfileMaskInsert(config->dbh, … … 1070 861 return true; 1071 862 } 1072 1073 #if 01074 1075 static psS64 definerunMode(pxConfig *config)1076 {1077 PS_ASSERT_PTR_NON_NULL(config, false);1078 1079 // required options1080 bool status = false;1081 psString mode = psMetadataLookupStr(&status, config->args, "-mode");1082 if (!status) {1083 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -survey_mode");1084 return false;1085 }1086 if (!mode) {1087 psError(PS_ERR_UNKNOWN, true, "-mode is required");1088 return false;1089 }1090 // check mode1091 if (mode && !isValidMode(config, mode)) {1092 psError(PS_ERR_UNKNOWN, false, "invalud mode");1093 return false;1094 }1095 1096 psString workdir = psMetadataLookupStr(&status, config->args, "-workdir");1097 if (!status) {1098 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -workdir");1099 return false;1100 }1101 if (!workdir) {1102 psError(PS_ERR_UNKNOWN, true, "-workdir is required");1103 return false;1104 }1105 1106 psTime *registered = NULL;1107 {1108 psString registeredStr = psMetadataLookupStr(&status, config->args, "-registered");1109 if (!status) {1110 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -registered");1111 return false;1112 }1113 // pass through NULL as this is an optional field1114 if (registeredStr) {1115 registered = psTimeFromISO(registeredStr, PS_TIME_UTC);1116 } else {1117 registered = NULL;1118 }1119 }1120 1121 warpRunRow *warpRun = warpRunRowAlloc(1122 0, // ID1123 mode,1124 "reg", // state1125 workdir,1126 NULL, // dvodb1127 registered1128 );1129 psFree(registered);1130 if (!warpRun) {1131 psError(PS_ERR_UNKNOWN, false, "failed to alloc warpRun object");1132 return true;1133 }1134 if (!warpRunInsertObject(config->dbh, warpRun)) {1135 psError(PS_ERR_UNKNOWN, false, "database error");1136 psFree(warpRun);1137 return true;1138 }1139 1140 // get the assigned warp_id1141 psS64 warp_id = psDBLastInsertID(config->dbh);1142 warpRun->warp_id = warp_id;1143 1144 bool simple = false;1145 {1146 bool status = false;1147 simple = psMetadataLookupBool(&status, config->args, "-simple");1148 if (!status) {1149 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -simple");1150 psFree(warpRun);1151 return false;1152 }1153 }1154 1155 if (!warpRunPrintObject(stdout, warpRun, !simple)) {1156 psError(PS_ERR_UNKNOWN, false, "failed to print object");1157 psFree(warpRun);1158 return false;1159 }1160 1161 psFree(warpRun);1162 1163 return warp_id;1164 }1165 1166 static bool runoneMode(pxConfig *config)1167 {1168 PS_ASSERT_PTR_NON_NULL(config, false);1169 1170 if (!psDBTransaction(config->dbh)) {1171 psError(PS_ERR_UNKNOWN, false, "database error");1172 return false;1173 }1174 1175 psS64 warp_id = definerunMode(config);1176 if (!warp_id) {1177 // rollback1178 if (!psDBRollback(config->dbh)) {1179 psError(PS_ERR_UNKNOWN, false, "database error");1180 }1181 psError(PS_ERR_UNKNOWN, false, "failed to define warpRun");1182 return false;1183 }1184 1185 psString warp_id_str = psDBIntToString(warp_id);1186 if (!psMetadataAddStr(config->args, PS_LIST_TAIL, "-warp_id", 0, NULL, warp_id_str)) {1187 // rollback1188 if (!psDBRollback(config->dbh)) {1189 psError(PS_ERR_UNKNOWN, false, "database error");1190 }1191 psError(PS_ERR_UNKNOWN, false, "failed to add item warp_id");1192 psFree(warp_id_str);1193 return false;1194 }1195 psFree(warp_id_str);1196 1197 if (!addinputexpMode(config)) {1198 // rollback1199 if (!psDBRollback(config->dbh)) {1200 psError(PS_ERR_UNKNOWN, false, "database error");1201 }1202 psError(PS_ERR_UNKNOWN, false, "failed to add cam_id to warpRun");1203 return false;1204 }1205 if (!setwarpRunState(config, warp_id, "run")) {1206 // rollback1207 if (!psDBRollback(config->dbh)) {1208 psError(PS_ERR_UNKNOWN, false, "database error");1209 }1210 psError(PS_ERR_UNKNOWN, false, "failed to set warpRun.state to run");1211 return false;1212 }1213 1214 // point of no return1215 if (!psDBCommit(config->dbh)) {1216 psError(PS_ERR_UNKNOWN, false, "database error");1217 return false;1218 }1219 1220 return true;1221 }1222 1223 static bool updaterunMode(pxConfig *config)1224 {1225 PS_ASSERT_PTR_NON_NULL(config, false);1226 1227 bool status = false;1228 psString warp_id = psMetadataLookupStr(&status, config->args, "-warp_id");1229 if (!status) {1230 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -warpt_id");1231 return false;1232 }1233 if (!warp_id) {1234 psError(PS_ERR_UNKNOWN, true, "-warp_id is required");1235 return false;1236 }1237 1238 psString state = psMetadataLookupStr(&status, config->args, "-state");1239 if (!status) {1240 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -state");1241 return false;1242 }1243 if (!state) {1244 psError(PS_ERR_UNKNOWN, true, "-state is required");1245 return false;1246 }1247 1248 if (state) {1249 // set detRun.state to state1250 return setwarpRunState(config, (psS64)atoll(warp_id), state);1251 }1252 1253 return true;1254 }1255 1256 1257 static bool addinputexpMode(pxConfig *config)1258 {1259 PS_ASSERT_PTR_NON_NULL(config, false);1260 1261 bool status = false;1262 psString warp_id = psMetadataLookupStr(&status, config->args, "-warp_id");1263 if (!status) {1264 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -warp_id");1265 return false;1266 }1267 if (!warp_id) {1268 psError(PS_ERR_UNKNOWN, true, "-warp_id is required");1269 return false;1270 }1271 1272 psString cam_id = psMetadataLookupStr(&status, config->args, "-cam_id");1273 if (!status) {1274 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -cam_id");1275 return false;1276 }1277 if (!cam_id) {1278 psError(PS_ERR_UNKNOWN, true, "-cam_id is required");1279 return false;1280 }1281 1282 // defaults to false1283 bool magiced = psMetadataLookupBool(&status, config->args, "-magiced");1284 if (!status) {1285 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -magiced");1286 return false;1287 }1288 1289 // XXX need to validate the warp_id here1290 // XXX instead of validiting it here we should just use forgein key1291 // constrants1292 if (!warpInputExpInsert(config->dbh,1293 (psS64)atoll(warp_id),1294 (psS64)atoll(cam_id),1295 magiced1296 )) {1297 psError(PS_ERR_UNKNOWN, false, "database error");1298 return false;1299 }1300 1301 return true;1302 }1303 1304 1305 static bool expMode(pxConfig *config)1306 {1307 PS_ASSERT_PTR_NON_NULL(config, false);1308 1309 bool status = false;1310 psU64 limit = psMetadataLookupU64(&status, config->args, "-limit");1311 if (!status) {1312 psError(PXTOOLS_ERR_PROG, false, "failed to lookup value for -limit");1313 return false;1314 }1315 1316 // find all rawImfiles matching the default query1317 psString query = pxDataGet("warptool_exp.sql");1318 if (!query) {1319 psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement");1320 return false;1321 }1322 1323 if (config->where) {1324 psString whereClause = psDBGenerateWhereConditionSQL(config->where, "warpInputExp");1325 psStringAppend(&query, " AND %s", whereClause);1326 psFree(whereClause);1327 }1328 1329 // treat limit == 0 as "no limit"1330 if (limit) {1331 psString limitString = psDBGenerateLimitSQL(limit);1332 psStringAppend(&query, " %s", limitString);1333 psFree(limitString);1334 }1335 1336 if (!p_psDBRunQuery(config->dbh, query)) {1337 psError(PS_ERR_UNKNOWN, false, "database error");1338 psFree(query);1339 return false;1340 }1341 psFree(query);1342 1343 psArray *output = p_psDBFetchResult(config->dbh);1344 if (!output) {1345 psErrorCode err = psErrorCodeLast();1346 switch (err) {1347 case PS_ERR_DB_CLIENT:1348 psError(PXTOOLS_ERR_SYS, false, "database error");1349 case PS_ERR_DB_SERVER:1350 psError(PXTOOLS_ERR_PROG, false, "database error");1351 default:1352 psError(PXTOOLS_ERR_PROG, false, "unknown error");1353 }1354 1355 return false;1356 }1357 if (!psArrayLength(output)) {1358 psTrace("warptool", PS_LOG_INFO, "no rows found");1359 psFree(output);1360 return true;1361 }1362 1363 bool simple = false;1364 {1365 bool status = false;1366 simple = psMetadataLookupBool(&status, config->args, "-simple");1367 if (!status) {1368 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -simple");1369 return false;1370 }1371 }1372 1373 if (psArrayLength(output)) {1374 if (!convertIdToStr(output)) {1375 psError(PS_ERR_UNKNOWN, false, "failed to convert id fields into a strings");1376 psFree(output);1377 return false;1378 }1379 1380 // negative simple so the default is true1381 if (!ippdbPrintMetadatas(stdout, output, "warpInputExp", !simple)) {1382 psError(PS_ERR_UNKNOWN, false, "failed to print array");1383 psFree(output);1384 return false;1385 }1386 }1387 1388 psFree(output);1389 1390 return true;1391 }1392 1393 1394 static bool imfileMode(pxConfig *config)1395 {1396 PS_ASSERT_PTR_NON_NULL(config, false);1397 1398 bool status = false;1399 psU64 limit = psMetadataLookupU64(&status, config->args, "-limit");1400 if (!status) {1401 psError(PXTOOLS_ERR_PROG, false, "failed to lookup value for -limit");1402 return false;1403 }1404 1405 // find all rawImfiles matching the default query1406 psString query = pxDataGet("warptool_imfile.sql");1407 if (!query) {1408 psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement");1409 return false;1410 }1411 1412 if (config->where) {1413 psString whereClause = psDBGenerateWhereConditionSQL(config->where, "warpInputExp");1414 psStringAppend(&query, " AND %s", whereClause);1415 psFree(whereClause);1416 }1417 1418 // treat limit == 0 as "no limit"1419 if (limit) {1420 psString limitString = psDBGenerateLimitSQL(limit);1421 psStringAppend(&query, " %s", limitString);1422 psFree(limitString);1423 }1424 1425 if (!p_psDBRunQuery(config->dbh, query)) {1426 psError(PS_ERR_UNKNOWN, false, "database error");1427 psFree(query);1428 return false;1429 }1430 psFree(query);1431 1432 psArray *output = p_psDBFetchResult(config->dbh);1433 if (!output) {1434 psErrorCode err = psErrorCodeLast();1435 switch (err) {1436 case PS_ERR_DB_CLIENT:1437 psError(PXTOOLS_ERR_SYS, false, "database error");1438 case PS_ERR_DB_SERVER:1439 psError(PXTOOLS_ERR_PROG, false, "database error");1440 default:1441 psError(PXTOOLS_ERR_PROG, false, "unknown error");1442 }1443 1444 return false;1445 }1446 if (!psArrayLength(output)) {1447 psTrace("warptool", PS_LOG_INFO, "no rows found");1448 psFree(output);1449 return true;1450 }1451 1452 bool simple = false;1453 {1454 bool status = false;1455 simple = psMetadataLookupBool(&status, config->args, "-simple");1456 if (!status) {1457 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -simple");1458 return false;1459 }1460 }1461 1462 if (psArrayLength(output)) {1463 if (!convertIdToStr(output)) {1464 psError(PS_ERR_UNKNOWN, false, "failed to convert id fields into a strings");1465 psFree(output);1466 return false;1467 }1468 1469 // negative simple so the default is true1470 if (!ippdbPrintMetadatas(stdout, output, "warpInputImfile", !simple)) {1471 psError(PS_ERR_UNKNOWN, false, "failed to print array");1472 psFree(output);1473 return false;1474 }1475 }1476 1477 psFree(output);1478 1479 return true;1480 }1481 1482 1483 static bool tooverlapMode(pxConfig *config)1484 {1485 PS_ASSERT_PTR_NON_NULL(config, false);1486 1487 bool status = false;1488 psU64 limit = psMetadataLookupU64(&status, config->args, "-limit");1489 if (!status) {1490 psError(PXTOOLS_ERR_PROG, false, "failed to lookup value for -limit");1491 return false;1492 }1493 1494 // find all rawImfiles matching the default query1495 psString query = pxDataGet("warptool_tooverlap.sql");1496 if (!query) {1497 psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement");1498 return false;1499 }1500 1501 if (config->where) {1502 psString whereClause = psDBGenerateWhereConditionSQL(config->where, "warpInputExp");1503 psStringAppend(&query, " AND %s", whereClause);1504 psFree(whereClause);1505 }1506 1507 // treat limit == 0 as "no limit"1508 if (limit) {1509 psString limitString = psDBGenerateLimitSQL(limit);1510 psStringAppend(&query, " %s", limitString);1511 psFree(limitString);1512 }1513 1514 if (!p_psDBRunQuery(config->dbh, query)) {1515 psError(PS_ERR_UNKNOWN, false, "database error");1516 psFree(query);1517 return false;1518 }1519 psFree(query);1520 1521 psArray *output = p_psDBFetchResult(config->dbh);1522 if (!output) {1523 psErrorCode err = psErrorCodeLast();1524 switch (err) {1525 case PS_ERR_DB_CLIENT:1526 psError(PXTOOLS_ERR_SYS, false, "database error");1527 case PS_ERR_DB_SERVER:1528 psError(PXTOOLS_ERR_PROG, false, "database error");1529 default:1530 psError(PXTOOLS_ERR_PROG, false, "unknown error");1531 }1532 1533 return false;1534 }1535 if (!psArrayLength(output)) {1536 psTrace("warptool", PS_LOG_INFO, "no rows found");1537 psFree(output);1538 return true;1539 }1540 1541 bool simple = false;1542 {1543 bool status = false;1544 simple = psMetadataLookupBool(&status, config->args, "-simple");1545 if (!status) {1546 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -simple");1547 return false;1548 }1549 }1550 1551 if (psArrayLength(output)) {1552 if (!convertIdToStr(output)) {1553 psError(PS_ERR_UNKNOWN, false, "failed to convert id fields into a strings");1554 psFree(output);1555 return false;1556 }1557 1558 // negative simple so the default is true1559 if (!ippdbPrintMetadatas(stdout, output, "warpInputExp", !simple)) {1560 psError(PS_ERR_UNKNOWN, false, "failed to print array");1561 psFree(output);1562 return false;1563 }1564 }1565 1566 psFree(output);1567 1568 return true;1569 }1570 1571 1572 static bool addoverlapMode(pxConfig *config)1573 {1574 PS_ASSERT_PTR_NON_NULL(config, false);1575 1576 bool status = false;1577 psString mapfile = psMetadataLookupStr(&status, config->args, "-mapfile");1578 if (!status) {1579 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -mapfile");1580 return false;1581 }1582 if (!mapfile) {1583 psError(PS_ERR_UNKNOWN, true, "-mapfile is required");1584 return false;1585 }1586 1587 if (!psDBTransaction(config->dbh)) {1588 psError(PS_ERR_UNKNOWN, false, "database error");1589 return false;1590 }1591 1592 if (!parseAndInsertSkyCellMap(config, mapfile)) {1593 psError(PS_ERR_UNKNOWN, false, "failed to inject mapfile: %s into the database", mapfile);1594 // rollback1595 if (!psDBRollback(config->dbh)) {1596 psError(PS_ERR_UNKNOWN, false, "database error");1597 }1598 return false;1599 }1600 1601 // point of no return1602 if (!psDBCommit(config->dbh)) {1603 psError(PS_ERR_UNKNOWN, false, "database error");1604 return false;1605 }1606 1607 return true;1608 }1609 1610 1611 static bool parseAndInsertSkyCellMap(pxConfig *config, const char *mapfile)1612 {1613 unsigned int nFail = 0;1614 psMetadata *skycells = psMetadataConfigRead(NULL, &nFail, mapfile, false);1615 if (!skycells) {1616 psError(PS_ERR_UNKNOWN, false, "failed to parse mapfile: %s", mapfile);1617 return false;1618 }1619 if (nFail) {1620 psError(PS_ERR_UNKNOWN, false, "there were %d errors parsing mapfile: %s", nFail, mapfile);1621 psFree(skycells);1622 return false;1623 }1624 1625 psMetadataItem *item = NULL;1626 psMetadataIterator *iter = psMetadataIteratorAlloc(skycells, 0, NULL);1627 while ((item = psMetadataGetAndIncrement(iter))) {1628 if (item->type != PS_DATA_METADATA) {1629 psError(PS_ERR_UNKNOWN, false, "mapfile: %s is in the wrong format", mapfile);1630 psFree(iter);1631 psFree(skycells);1632 return false;1633 }1634 1635 psMetadata *sc = item->data.md;1636 // this conversion isn't strictly nessicary but it's an easy way of1637 // validating the format1638 warpSkyCellMapRow *row = warpSkyCellMapObjectFromMetadata(sc);1639 if (!row) {1640 psError(PS_ERR_UNKNOWN, false, "failed to convert mapfile: %s metdata entry into a warpSkyCellMap object", mapfile);1641 psFree(iter);1642 psFree(skycells);1643 return false;1644 }1645 1646 if (!warpSkyCellMapInsertObject(config->dbh, row)) {1647 psErrorCode err = psErrorCodeLast();1648 switch (err) {1649 case PS_ERR_DB_CLIENT:1650 psError(PXTOOLS_ERR_SYS, false, "database error");1651 case PS_ERR_DB_SERVER:1652 psError(PXTOOLS_ERR_PROG, false, "database error");1653 default:1654 psError(PXTOOLS_ERR_PROG, false, "unknown error");1655 }1656 psFree(row);1657 psFree(iter);1658 psFree(skycells);1659 return false;1660 }1661 1662 psFree(row);1663 }1664 psFree(iter);1665 psFree(skycells);1666 1667 return true;1668 }1669 1670 1671 static bool scmapMode(pxConfig *config)1672 {1673 PS_ASSERT_PTR_NON_NULL(config, false);1674 1675 bool status = false;1676 psU64 limit = psMetadataLookupU64(&status, config->args, "-limit");1677 if (!status) {1678 psError(PXTOOLS_ERR_PROG, false, "failed to lookup value for -limit");1679 return false;1680 }1681 1682 // find all rawImfiles matching the default query1683 psString query = pxDataGet("warptool_scmap.sql");1684 if (!query) {1685 psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement");1686 return false;1687 }1688 1689 if (config->where) {1690 psString whereClause = psDBGenerateWhereConditionSQL(config->where, "warpSkyCellMap");1691 psStringAppend(&query, " AND %s", whereClause);1692 psFree(whereClause);1693 }1694 1695 // treat limit == 0 as "no limit"1696 if (limit) {1697 psString limitString = psDBGenerateLimitSQL(limit);1698 psStringAppend(&query, " %s", limitString);1699 psFree(limitString);1700 }1701 1702 if (!p_psDBRunQuery(config->dbh, query)) {1703 psError(PS_ERR_UNKNOWN, false, "database error");1704 psFree(query);1705 return false;1706 }1707 psFree(query);1708 1709 psArray *output = p_psDBFetchResult(config->dbh);1710 if (!output) {1711 psErrorCode err = psErrorCodeLast();1712 switch (err) {1713 case PS_ERR_DB_CLIENT:1714 psError(PXTOOLS_ERR_SYS, false, "database error");1715 case PS_ERR_DB_SERVER:1716 psError(PXTOOLS_ERR_PROG, false, "database error");1717 default:1718 psError(PXTOOLS_ERR_PROG, false, "unknown error");1719 }1720 1721 return false;1722 }1723 if (!psArrayLength(output)) {1724 psTrace("warptool", PS_LOG_INFO, "no rows found");1725 psFree(output);1726 return true;1727 }1728 1729 bool simple = false;1730 {1731 bool status = false;1732 simple = psMetadataLookupBool(&status, config->args, "-simple");1733 if (!status) {1734 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -simple");1735 return false;1736 }1737 }1738 1739 if (psArrayLength(output)) {1740 if (!convertIdToStr(output)) {1741 psError(PS_ERR_UNKNOWN, false, "failed to convert id fields into a strings");1742 psFree(output);1743 return false;1744 }1745 1746 // negative simple so the default is true1747 if (!ippdbPrintMetadatas(stdout, output, "warpSkyCellMap", !simple)) {1748 psError(PS_ERR_UNKNOWN, false, "failed to print array");1749 psFree(output);1750 return false;1751 }1752 }1753 1754 psFree(output);1755 1756 return true;1757 }1758 1759 1760 static bool towarpedMode(pxConfig *config)1761 {1762 PS_ASSERT_PTR_NON_NULL(config, false);1763 1764 bool status = false;1765 psU64 limit = psMetadataLookupU64(&status, config->args, "-limit");1766 if (!status) {1767 psError(PXTOOLS_ERR_PROG, false, "failed to lookup value for -limit");1768 return false;1769 }1770 1771 // find all rawImfiles matching the default query1772 psString query = pxDataGet("warptool_towarped.sql");1773 if (!query) {1774 psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement");1775 return false;1776 }1777 1778 if (config->where) {1779 psString whereClause = psDBGenerateWhereConditionSQL(config->where, "warpSkyCellMap");1780 psStringAppend(&query, " AND %s", whereClause);1781 psFree(whereClause);1782 }1783 1784 // treat limit == 0 as "no limit"1785 if (limit) {1786 psString limitString = psDBGenerateLimitSQL(limit);1787 psStringAppend(&query, " %s", limitString);1788 psFree(limitString);1789 }1790 1791 if (!p_psDBRunQuery(config->dbh, query)) {1792 psError(PS_ERR_UNKNOWN, false, "database error");1793 psFree(query);1794 return false;1795 }1796 psFree(query);1797 1798 psArray *output = p_psDBFetchResult(config->dbh);1799 if (!output) {1800 psErrorCode err = psErrorCodeLast();1801 switch (err) {1802 case PS_ERR_DB_CLIENT:1803 psError(PXTOOLS_ERR_SYS, false, "database error");1804 case PS_ERR_DB_SERVER:1805 psError(PXTOOLS_ERR_PROG, false, "database error");1806 default:1807 psError(PXTOOLS_ERR_PROG, false, "unknown error");1808 }1809 1810 return false;1811 }1812 if (!psArrayLength(output)) {1813 psTrace("warptool", PS_LOG_INFO, "no rows found");1814 psFree(output);1815 return true;1816 }1817 1818 bool simple = false;1819 {1820 bool status = false;1821 simple = psMetadataLookupBool(&status, config->args, "-simple");1822 if (!status) {1823 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -simple");1824 return false;1825 }1826 }1827 1828 if (psArrayLength(output)) {1829 if (!convertIdToStr(output)) {1830 psError(PS_ERR_UNKNOWN, false, "failed to convert id fields into a strings");1831 psFree(output);1832 return false;1833 }1834 1835 // negative simple so the default is true1836 if (!ippdbPrintMetadatas(stdout, output, "warpPendingSkyCell", !simple)) {1837 psError(PS_ERR_UNKNOWN, false, "failed to print array");1838 psFree(output);1839 return false;1840 }1841 }1842 1843 psFree(output);1844 1845 return true;1846 }1847 1848 1849 static bool addwarpedMode(pxConfig *config)1850 {1851 PS_ASSERT_PTR_NON_NULL(config, false);1852 1853 bool status = false;1854 psString warp_id = psMetadataLookupStr(&status, config->args, "-warp_id");1855 if (!status) {1856 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -warp_id");1857 return false;1858 }1859 if (!warp_id) {1860 psError(PS_ERR_UNKNOWN, true, "-warp_id is required");1861 return false;1862 }1863 1864 psString skycell_id = psMetadataLookupStr(&status, config->args, "-skycell_id");1865 if (!status) {1866 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -skycell_id");1867 return false;1868 }1869 if (!skycell_id) {1870 psError(PS_ERR_UNKNOWN, true, "-skycell_id is required");1871 return false;1872 }1873 1874 psString tess_id = psMetadataLookupStr(&status, config->args, "-tess_id");1875 if (!status) {1876 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -tess_id");1877 return false;1878 }1879 if (!tess_id) {1880 psError(PS_ERR_UNKNOWN, true, "-tess_id is required");1881 return false;1882 }1883 1884 psString uri = psMetadataLookupStr(&status, config->args, "-uri");1885 if (!status) {1886 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -uri");1887 return false;1888 }1889 if (!uri) {1890 psError(PS_ERR_UNKNOWN, true, "-uri is required");1891 return false;1892 }1893 1894 psString path_base = psMetadataLookupStr(&status, config->args, "-path_base");1895 if (!status) {1896 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -path_base");1897 return false;1898 }1899 if (!path_base) {1900 psError(PS_ERR_UNKNOWN, true, "-path_base is required");1901 return false;1902 }1903 1904 // optional1905 psF64 bg = psMetadataLookupF64(&status, config->args, "-bg");1906 if (!status) {1907 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -bg");1908 return false;1909 }1910 1911 psF64 bg_stdev = psMetadataLookupF64(&status, config->args, "-bg_stdev");1912 if (!status) {1913 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -bg_stdev");1914 return false;1915 }1916 1917 psF64 pixel_fill = psMetadataLookupF64(&status, config->args, "-pixel_fill");1918 if (!status) {1919 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -pixel_fill");1920 return false;1921 }1922 1923 // default values1924 psS16 code = psMetadataLookupS16(&status, config->args, "-code");1925 if (!status) {1926 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -code");1927 return false;1928 }1929 1930 // we don't want to insert the last skyfile in a run but then not mark the1931 // run as 'stop'1932 if (!psDBTransaction(config->dbh)) {1933 psError(PS_ERR_UNKNOWN, false, "database error");1934 return false;1935 }1936 1937 // XXX need to validate that this coresponds to an warpInputImfile1938 if (!warpSkyfileInsert(config->dbh,1939 (psS64)atoll(warp_id),1940 skycell_id,1941 tess_id,1942 uri,1943 path_base,1944 bg,1945 bg_stdev,1946 pixel_fill,1947 code1948 )) {1949 if (!psDBRollback(config->dbh)) {1950 psError(PS_ERR_UNKNOWN, false, "database error");1951 }1952 psError(PS_ERR_UNKNOWN, false, "database error");1953 return false;1954 }1955 1956 if (!warpCompletedRuns(config)) {1957 if (!psDBRollback(config->dbh)) {1958 psError(PS_ERR_UNKNOWN, false, "database error");1959 }1960 psError(PS_ERR_UNKNOWN, false, "database error");1961 return false;1962 }1963 1964 // point of no return1965 if (!psDBCommit(config->dbh)) {1966 psError(PS_ERR_UNKNOWN, false, "database error");1967 return false;1968 }1969 1970 return true;1971 }1972 1973 bool warpCompletedRuns(pxConfig *config)1974 {1975 PS_ASSERT_PTR_NON_NULL(config, false);1976 1977 // XXX this SQL has not been broken out to into seperate files as the MYSQL1978 // < 5 & MYSQL 5 versions need to be kept in sync1979 #if MYSQL51980 // XXX at MySQL 4.1.21 (probably all of 4.1.x) chokes and dies on this1981 // statement as it thinks it is trying to select from the table being1982 // updated. The 4.1 manual says that nested sub-queries are explicited1983 // allowed to do this with update statements as a temporary table is1984 // created so that you are not actually selecting from the table you are1985 // modifying.1986 char *query =1987 "UPDATE warpRun\n"1988 " SET warpRun.state = 'stop'\n"1989 " WHERE\n"1990 " warpRun.warp_id =\n"1991 " (SELECT DISTINCT\n"1992 " warp_id\n"1993 " FROM\n"1994 " (SELECT DISTINCT\n"1995 " warpRun.warp_id,\n"1996 " warpSkyCellMap.warp_id as foo,\n"1997 " warpSkyfile.warp_id as bar\n"1998 " FROM warpRun\n"1999 " JOIN warpSkyCellMap\n"2000 " USING(warp_id)\n"2001 " LEFT JOIN warpSkyfile\n"2002 " USING(warp_id, skycell_id, tess_id)\n"2003 " WHERE\n"2004 " warpRun.state = 'run'\n"2005 " GROUP BY\n"2006 " warpRun.warp_id\n"2007 " HAVING\n"2008 " COUNT(warpSkyCellMap.warp_id) = COUNT(warpSkyfile.warp_id)\n"2009 " ) as Foo\n"2010 " )\n";2011 2012 if (!p_psDBRunQuery(config->dbh, query)) {2013 psError(PS_ERR_UNKNOWN, false, "database error");2014 return false;2015 }2016 #else // if MYSQL52017 {2018 char *query =2019 "CREATE TEMPORARY TABLE finished\n"2020 " (warp_id INT, PRIMARY KEY(warp_id)) ENGINE=MEMORY\n";2021 2022 if (!p_psDBRunQuery(config->dbh, query)) {2023 psError(PS_ERR_UNKNOWN, false, "database error");2024 return false;2025 }2026 }2027 2028 {2029 char *query =2030 "INSERT INTO finished\n"2031 " SELECT\n"2032 " warp_id\n"2033 " FROM\n"2034 " (SELECT DISTINCT\n"2035 " warpRun.warp_id,\n"2036 " warpSkyCellMap.warp_id as foo,\n"2037 " warpSkyfile.warp_id as bar\n"2038 " FROM warpRun\n"2039 " JOIN warpSkyCellMap\n"2040 " USING(warp_id)\n"2041 " LEFT JOIN warpSkyfile\n"2042 " USING(warp_id, skycell_id, tess_id)\n"2043 " WHERE\n"2044 " warpRun.state = 'run'\n"2045 " GROUP BY\n"2046 " warpRun.warp_id\n"2047 " HAVING\n"2048 " COUNT(warpSkyCellMap.warp_id) = COUNT(warpSkyfile.warp_id)\n"2049 " ) as Foo \n";2050 2051 if (!p_psDBRunQuery(config->dbh, query)) {2052 psError(PS_ERR_UNKNOWN, false, "database error");2053 return false;2054 }2055 }2056 2057 {2058 char *query =2059 "UPDATE warpRun\n"2060 " SET warpRun.state = 'stop'\n"2061 " WHERE\n"2062 " warpRun.warp_id =\n"2063 " (SELECT DISTINCT\n"2064 " warp_id\n"2065 " FROM finished\n"2066 " )\n";2067 2068 if (!p_psDBRunQuery(config->dbh, query)) {2069 psError(PS_ERR_UNKNOWN, false, "database error");2070 return false;2071 }2072 }2073 #endif // if MYSQL52074 2075 return true;2076 }2077 2078 static bool warpedMode(pxConfig *config)2079 {2080 PS_ASSERT_PTR_NON_NULL(config, false);2081 2082 bool status = false;2083 psU64 limit = psMetadataLookupU64(&status, config->args, "-limit");2084 if (!status) {2085 psError(PXTOOLS_ERR_PROG, false, "failed to lookup value for -limit");2086 return false;2087 }2088 2089 // find all rawImfiles matching the default query2090 psString query = pxDataGet("warptool_warped.sql");2091 if (!query) {2092 psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement");2093 return false;2094 }2095 2096 if (config->where) {2097 psString whereClause = psDBGenerateWhereConditionSQL(config->where, "warpSkyfile");2098 psStringAppend(&query, " AND %s", whereClause);2099 psFree(whereClause);2100 }2101 2102 // treat limit == 0 as "no limit"2103 if (limit) {2104 psString limitString = psDBGenerateLimitSQL(limit);2105 psStringAppend(&query, " %s", limitString);2106 psFree(limitString);2107 }2108 2109 if (!p_psDBRunQuery(config->dbh, query)) {2110 psError(PS_ERR_UNKNOWN, false, "database error");2111 psFree(query);2112 return false;2113 }2114 psFree(query);2115 2116 psArray *output = p_psDBFetchResult(config->dbh);2117 if (!output) {2118 psErrorCode err = psErrorCodeLast();2119 switch (err) {2120 case PS_ERR_DB_CLIENT:2121 psError(PXTOOLS_ERR_SYS, false, "database error");2122 case PS_ERR_DB_SERVER:2123 psError(PXTOOLS_ERR_PROG, false, "database error");2124 default:2125 psError(PXTOOLS_ERR_PROG, false, "unknown error");2126 }2127 2128 return false;2129 }2130 if (!psArrayLength(output)) {2131 psTrace("warptool", PS_LOG_INFO, "no rows found");2132 psFree(output);2133 return true;2134 }2135 2136 bool simple = false;2137 {2138 bool status = false;2139 simple = psMetadataLookupBool(&status, config->args, "-simple");2140 if (!status) {2141 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -simple");2142 return false;2143 }2144 }2145 2146 if (psArrayLength(output)) {2147 if (!convertIdToStr(output)) {2148 psError(PS_ERR_UNKNOWN, false, "failed to convert id fields into a strings");2149 psFree(output);2150 return false;2151 }2152 2153 // negative simple so the default is true2154 if (!ippdbPrintMetadatas(stdout, output, "warpSkyfile", !simple)) {2155 psError(PS_ERR_UNKNOWN, false, "failed to print array");2156 psFree(output);2157 return false;2158 }2159 }2160 2161 psFree(output);2162 2163 return true;2164 }2165 2166 2167 static bool revertwarpedMode(pxConfig *config)2168 {2169 PS_ASSERT_PTR_NON_NULL(config, false);2170 2171 psString query = pxDataGet("warptool_revertwarped.sql");2172 if (!query) {2173 psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement");2174 return false;2175 }2176 2177 if (config->where) {2178 psString whereClause = psDBGenerateWhereConditionSQL(config->where, "warpSkyfile");2179 psStringAppend(&query, " AND %s", whereClause);2180 psFree(whereClause);2181 }2182 2183 if (!p_psDBRunQuery(config->dbh, query)) {2184 psError(PS_ERR_UNKNOWN, false, "database error");2185 psFree(query);2186 return false;2187 }2188 psFree(query);2189 2190 if (psDBAffectedRows(config->dbh) < 1) {2191 psError(PS_ERR_UNKNOWN, false, "should have affected atleast 1 row");2192 return false;2193 }2194 2195 return true;2196 }2197 #endif2198 863 2199 864 … … 2224 889 } 2225 890 2226 2227 #if 02228 static bool isValidMode(pxConfig *config, const char *mode)2229 {2230 PS_ASSERT_PTR_NON_NULL(config, false);2231 PS_ASSERT_PTR_NON_NULL(mode, false);2232 2233 // check that state is a valid string value2234 if (!(2235 (strncmp(mode, "warp", 5) == 0)2236 || (strncmp(mode, "diff", 5) == 0)2237 || (strncmp(mode, "stack", 6) == 0)2238 || (strncmp(mode, "magic", 6) == 0)2239 )2240 ) {2241 psError(PS_ERR_UNKNOWN, false,2242 "invalid warpRun mode: %s", mode);2243 return false;2244 }2245 2246 return true;2247 }2248 #endif2249 2250 891 static bool parseAndInsertNodeDeps(pxConfig *config, psS64 magic_id, const char *filename) 2251 892 {
Note:
See TracChangeset
for help on using the changeset viewer.
