Changeset 11851
- Timestamp:
- Feb 16, 2007, 12:10:39 PM (19 years ago)
- Location:
- trunk/ippTools/src
- Files:
-
- 3 edited
-
stacktool.c (modified) (17 diffs)
-
stacktool.h (modified) (1 diff)
-
stacktoolConfig.c (modified) (12 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippTools/src/stacktool.c
r11814 r11851 33 33 static bool definerunMode(pxConfig *config); 34 34 static bool updaterunMode(pxConfig *config); 35 static bool addinputexpMode(pxConfig *config); 36 static bool expMode(pxConfig *config); 37 static bool imfileMode(pxConfig *config); 38 static bool tooverlapMode(pxConfig *config); 39 static bool addoverlapMode(pxConfig *config); 40 static bool scmapMode(pxConfig *config); 41 static bool towarpedMode(pxConfig *config); 42 static bool addwarpedMode(pxConfig *config); 43 static bool warpedMode(pxConfig *config); 44 45 #if 0 46 static bool tostackedimfileMode(pxConfig *config); 47 //static bool addstackedimfileMode(pxConfig *config); 48 static bool stackedimfileMode(pxConfig *config); 49 static bool todiffimfileMode(pxConfig *config); 50 //static bool adddiffimfileMode(pxConfig *config); 51 static bool diffimfileMode(pxConfig *config); 52 #endif 53 54 static bool parseAndInsertSkyCellMap(pxConfig *config, const char *mapfile); 55 static bool setp4RunState(pxConfig *config, const char *p4_id, const char *state); 56 static bool isValidMode(pxConfig *config, const char *mode); 35 static bool addinputscfileMode(pxConfig *config); 36 static bool inputscfileMode(pxConfig *config); 37 static bool tosumMode(pxConfig *config); 38 static bool addsumscfileMode(pxConfig *config); 39 static bool sumscfileMode(pxConfig *config); 40 41 static bool setp6RunState(pxConfig *config, const char *p4_id, const char *state); 57 42 58 43 # define MODECASE(caseName, func) \ … … 68 53 69 54 pxConfig *config = p6toolConfig(NULL, argc, argv); 55 if (!config) { 56 psError(PXTOOLS_ERR_CONFIG, false, "failed to configure"); 57 goto FAIL; 58 } 70 59 71 60 switch (config->mode) { 72 61 MODECASE(P6TOOL_MODE_DEFINERUN, definerunMode); 73 62 MODECASE(P6TOOL_MODE_UPDATERUN, updaterunMode); 74 MODECASE(P6TOOL_MODE_ADDINPUTEXP, addinputexpMode); 75 MODECASE(P6TOOL_MODE_EXP, expMode); 76 MODECASE(P6TOOL_MODE_IMFILE, imfileMode); 77 MODECASE(P6TOOL_MODE_TOOVERLAP, tooverlapMode); 78 MODECASE(P6TOOL_MODE_ADDOVERLAP, addoverlapMode); 79 MODECASE(P6TOOL_MODE_SCMAP, scmapMode); 80 MODECASE(P6TOOL_MODE_TOWARPED, towarpedMode); 81 MODECASE(P6TOOL_MODE_ADDWARPED, addwarpedMode); 82 MODECASE(P6TOOL_MODE_WARPED, warpedMode); 83 84 #if 0 85 MODECASE(P6TOOL_MODE_ADDSCFILE, addscfileMode); 86 MODECASE(P6TOOL_MODE_SCFILE, scfileMode); 87 MODECASE(P6TOOL_MODE_TOSTACKEDIMFILE, tostackedimfileMode); 88 // MODECASE(P6TOOL_MODE_ADDSTACKEDIMFILE, addstackedimfileMode); 89 MODECASE(P6TOOL_MODE_STACKEDIMFILE, stackedimfileMode); 90 MODECASE(P6TOOL_MODE_TODIFFIMFILE, todiffimfileMode); 91 // MODECASE(P6TOOL_MODE_ADDDIFFIMFILE, adddiffimfileMode); 92 MODECASE(P6TOOL_MODE_DIFFIMFILE, diffimfileMode); 93 #endif 63 MODECASE(P6TOOL_MODE_ADDINPUTSCFILE, addinputscfileMode); 64 MODECASE(P6TOOL_MODE_INPUTSCFILE, inputscfileMode); 65 MODECASE(P6TOOL_MODE_TOSUM, tosumMode); 66 MODECASE(P6TOOL_MODE_ADDSUMSCFILE, addsumscfileMode); 67 MODECASE(P6TOOL_MODE_SUMSCFILE, sumscfileMode); 94 68 default: 95 69 psAbort("invalid option (this should not happen)"); … … 104 78 FAIL: 105 79 psErrorStackPrint(stderr, "\n"); 80 int exit_status = pxerrorGetExitStatus(); 106 81 107 82 psFree(config); … … 109 84 psLibFinalize(); 110 85 111 exit( EXIT_FAILURE);86 exit(exit_status); 112 87 } 113 88 … … 126 101 if (!mode) { 127 102 psError(PS_ERR_UNKNOWN, true, "-mode is required"); 128 return false;129 }130 // check mode131 if (mode && !isValidMode(config, mode)) {132 psError(PS_ERR_UNKNOWN, false, "invalud mode");133 103 return false; 134 104 } … … 230 200 if (state) { 231 201 // set detRun.state to state 232 return setp 4RunState(config, p4_id, state);233 } 234 235 return true; 236 } 237 238 239 static bool addinput expMode(pxConfig *config)202 return setp6RunState(config, p4_id, state); 203 } 204 205 return true; 206 } 207 208 209 static bool addinputscfileMode(pxConfig *config) 240 210 { 241 211 PS_ASSERT_PTR_NON_NULL(config, false); … … 293 263 294 264 295 static bool expMode(pxConfig *config) 296 { 297 PS_ASSERT_PTR_NON_NULL(config, false); 298 299 bool status = false; 300 psU64 limit = psMetadataLookupU64(&status, config->args, "-limit"); 301 if (!status) { 302 psError(PXTOOLS_ERR_PROG, false, "failed to lookup value for -limit"); 303 return false; 304 } 305 306 // find all rawImfiles matching the default query 307 psString query = psStringCopy( 308 "SELECT\n" 309 " p3ProcessedExp.*\n" 310 " FROM p4Run\n" 311 " JOIN p4InputExp\n" 312 " USING(p4_id)\n" 313 " JOIN p3ProcessedExp\n" 314 " ON p4InputExp.exp_tag = p3ProcessedExp.exp_tag\n" 315 " AND p4InputExp.p3_version = p3ProcessedExp.p3_version\n" 316 " WHERE\n" 317 " p4Run.state = 'run'\n" 318 " AND p3ProcessedExp.fault = 0\n" 319 ); 320 321 if (config->where) { 322 psString whereClause = psDBGenerateWhereConditionSQL(config->where, "p4InputExp"); 323 psStringAppend(&query, " AND %s", whereClause); 324 psFree(whereClause); 325 } 326 327 // treat limit == 0 as "no limit" 328 if (limit) { 329 psString limitString = psDBGenerateLimitSQL(limit); 330 psStringAppend(&query, " %s", limitString); 331 psFree(limitString); 332 } 333 334 if (!p_psDBRunQuery(config->dbh, query)) { 335 psError(PS_ERR_UNKNOWN, false, "database error"); 336 psFree(query); 337 return false; 338 } 339 psFree(query); 340 341 psArray *output = p_psDBFetchResult(config->dbh); 342 if (!output) { 343 psErrorCode err = psErrorCodeLast(); 344 switch (err) { 345 case PS_ERR_DB_CLIENT: 346 psError(PXTOOLS_ERR_SYS, false, "database error"); 347 case PS_ERR_DB_SERVER: 348 psError(PXTOOLS_ERR_PROG, false, "database error"); 349 default: 350 psError(PXTOOLS_ERR_PROG, false, "unknown error"); 351 } 352 353 return false; 354 } 355 if (!psArrayLength(output)) { 356 psError(PS_ERR_UNKNOWN, false, "no pending rawImfile rows found"); 357 psFree(output); 358 return true; 359 } 360 361 bool simple = false; 362 { 363 bool status = false; 364 simple = psMetadataLookupBool(&status, config->args, "-simple"); 365 if (!status) { 366 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -simple"); 367 return false; 368 } 369 } 370 371 if (psArrayLength(output)) { 372 // negative simple so the default is true 373 if (!ippdbPrintMetadatas(stdout, output, "p4InputExp", !simple)) { 374 psError(PS_ERR_UNKNOWN, false, "failed to print array"); 375 psFree(output); 376 return false; 377 } 378 } 379 380 psFree(output); 381 382 return true; 383 } 384 385 386 static bool imfileMode(pxConfig *config) 265 static bool inputscfileMode(pxConfig *config) 387 266 { 388 267 PS_ASSERT_PTR_NON_NULL(config, false); … … 472 351 473 352 474 static bool to overlapMode(pxConfig *config)353 static bool tosumMode(pxConfig *config) 475 354 { 476 355 PS_ASSERT_PTR_NON_NULL(config, false); … … 570 449 571 450 572 static bool add overlapMode(pxConfig *config)451 static bool addsumscfileMode(pxConfig *config) 573 452 { 574 453 PS_ASSERT_PTR_NON_NULL(config, false); … … 590 469 } 591 470 592 if (!parseAndInsertSkyCellMap(config, mapfile)) {593 psError(PS_ERR_UNKNOWN, false, "failed to inject mapfile: %s into the database", mapfile);594 // rollback595 if (!psDBRollback(config->dbh)) {596 psError(PS_ERR_UNKNOWN, false, "database error");597 }598 return false;599 }600 601 471 // point of no return 602 472 if (!psDBCommit(config->dbh)) { … … 609 479 610 480 611 static bool parseAndInsertSkyCellMap(pxConfig *config, const char *mapfile) 612 { 613 unsigned int nFail = 0; 614 psMetadata *skycells = psMetadataConfigRead(NULL, &nFail, mapfile, false); 615 if (!skycells) { 616 psError(PS_ERR_UNKNOWN, false, "failed to parse mapfile: %s", mapfile); 617 return false; 618 } 619 if (nFail) { 620 psError(PS_ERR_UNKNOWN, false, "there were %d errors parsing mapfile: %s", nFail, mapfile); 621 psFree(skycells); 622 return false; 623 } 624 625 psMetadataItem *item = NULL; 626 psMetadataIterator *iter = psMetadataIteratorAlloc(skycells, 0, NULL); 627 if ((item = psMetadataGetAndIncrement(iter))) { 628 if (item->type != PS_DATA_METADATA) { 629 psError(PS_ERR_UNKNOWN, false, "mapfile: %s is in the wrong format", mapfile); 630 psFree(iter); 631 psFree(skycells); 632 return false; 633 } 634 635 psMetadata *sc = item->data.md; 636 // this conversion isn't strictly nessicary but it's an easy way of 637 // validating the format 638 p4SkyCellMapRow *row = p4SkyCellMapObjectFromMetadata(sc); 639 if (!row) { 640 psError(PS_ERR_UNKNOWN, false, "failed to convert mapfile: %s metdata entry into a p4SkyCellMap object", mapfile); 641 psFree(iter); 642 psFree(skycells); 643 return false; 644 } 645 646 if (!p4SkyCellMapInsertObject(config->dbh, row)) { 647 psErrorCode err = psErrorCodeLast(); 648 switch (err) { 649 case PS_ERR_DB_CLIENT: 650 psError(PXTOOLS_ERR_SYS, false, "database error"); 651 case PS_ERR_DB_SERVER: 652 psError(PXTOOLS_ERR_PROG, false, "database error"); 653 default: 654 psError(PXTOOLS_ERR_PROG, false, "unknown error"); 655 } 656 psFree(row); 657 psFree(iter); 658 psFree(skycells); 659 return false; 660 } 661 662 psFree(row); 663 } 664 psFree(iter); 665 psFree(skycells); 666 667 return true; 668 } 669 670 671 static bool scmapMode(pxConfig *config) 481 static bool sumscfileMode(pxConfig *config) 672 482 { 673 483 PS_ASSERT_PTR_NON_NULL(config, false); … … 683 493 psString query = psStringCopy( 684 494 "SELECT\n" 685 " p4S kyCellMap.*\n"495 " p4Scfile.*\n" 686 496 " FROM p4Run\n" 687 " JOIN p4S kyCellMap\n"497 " JOIN p4Scfile\n" 688 498 " USING(p4_id)\n" 689 499 " WHERE\n" … … 692 502 693 503 if (config->where) { 694 psString whereClause = psDBGenerateWhereConditionSQL(config->where, "p4S kyCellMap");504 psString whereClause = psDBGenerateWhereConditionSQL(config->where, "p4Scfile"); 695 505 psStringAppend(&query, " AND %s", whereClause); 696 506 psFree(whereClause); … … 726 536 } 727 537 if (!psArrayLength(output)) { 728 psError(PS_ERR_UNKNOWN, false, "no p4S kyCellMaprows found");538 psError(PS_ERR_UNKNOWN, false, "no p4Scfile rows found"); 729 539 psFree(output); 730 540 return true; … … 743 553 if (psArrayLength(output)) { 744 554 // negative simple so the default is true 745 if (!ippdbPrintMetadatas(stdout, output, "p4SkyCellMap", !simple)) {746 psError(PS_ERR_UNKNOWN, false, "failed to print array");747 psFree(output);748 return false;749 }750 }751 752 psFree(output);753 754 return true;755 }756 757 758 static bool towarpedMode(pxConfig *config)759 {760 PS_ASSERT_PTR_NON_NULL(config, false);761 762 bool status = false;763 psU64 limit = psMetadataLookupU64(&status, config->args, "-limit");764 if (!status) {765 psError(PXTOOLS_ERR_PROG, false, "failed to lookup value for -limit");766 return false;767 }768 769 // find all rawImfiles matching the default query770 psString query = psStringCopy(771 "SELECT\n"772 " p4SkyCellMap.*\n"773 " FROM p4Run\n"774 " JOIN p4SkyCellMap\n"775 " USING(p4_id)\n"776 " LEFT JOIN p4Scfile\n"777 " USING(p4_id, skycell_id, tess_id, exp_tag, p3_version)\n"778 " WHERE\n"779 " p4Run.state = 'run'\n"780 " AND p4Scfile.p4_id IS NULL\n"781 " AND p4Scfile.skycell_id IS NULL\n"782 " AND p4Scfile.tess_id IS NULL\n"783 " AND p4Scfile.exp_tag IS NULL\n"784 " AND p4Scfile.p3_version IS NULL\n"785 );786 787 if (config->where) {788 psString whereClause = psDBGenerateWhereConditionSQL(config->where, "p4SkyCellMap");789 psStringAppend(&query, " AND %s", whereClause);790 psFree(whereClause);791 }792 793 // treat limit == 0 as "no limit"794 if (limit) {795 psString limitString = psDBGenerateLimitSQL(limit);796 psStringAppend(&query, " %s", limitString);797 psFree(limitString);798 }799 800 if (!p_psDBRunQuery(config->dbh, query)) {801 psError(PS_ERR_UNKNOWN, false, "database error");802 psFree(query);803 return false;804 }805 psFree(query);806 807 psArray *output = p_psDBFetchResult(config->dbh);808 if (!output) {809 psErrorCode err = psErrorCodeLast();810 switch (err) {811 case PS_ERR_DB_CLIENT:812 psError(PXTOOLS_ERR_SYS, false, "database error");813 case PS_ERR_DB_SERVER:814 psError(PXTOOLS_ERR_PROG, false, "database error");815 default:816 psError(PXTOOLS_ERR_PROG, false, "unknown error");817 }818 819 return false;820 }821 if (!psArrayLength(output)) {822 psError(PS_ERR_UNKNOWN, false, "no p4PendingSkyCell rows found");823 psFree(output);824 return true;825 }826 827 bool simple = false;828 {829 bool status = false;830 simple = psMetadataLookupBool(&status, config->args, "-simple");831 if (!status) {832 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -simple");833 return false;834 }835 }836 837 if (psArrayLength(output)) {838 // negative simple so the default is true839 if (!ippdbPrintMetadatas(stdout, output, "p4PendingSkyCell", !simple)) {840 psError(PS_ERR_UNKNOWN, false, "failed to print array");841 psFree(output);842 return false;843 }844 }845 846 psFree(output);847 848 return true;849 }850 851 852 static bool addwarpedMode(pxConfig *config)853 {854 PS_ASSERT_PTR_NON_NULL(config, false);855 856 bool status = false;857 psString p4_id = psMetadataLookupStr(&status, config->args, "-p4_id");858 if (!status) {859 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -p4_id");860 return false;861 }862 if (!p4_id) {863 psError(PS_ERR_UNKNOWN, true, "-p4_id is required");864 return false;865 }866 867 psString skycell_id = psMetadataLookupStr(&status, config->args, "-skycell_id");868 if (!status) {869 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -skycell_id");870 return false;871 }872 if (!skycell_id) {873 psError(PS_ERR_UNKNOWN, true, "-skycell_id is required");874 return false;875 }876 877 psString tess_id = psMetadataLookupStr(&status, config->args, "-tess_id");878 if (!status) {879 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -tess_id");880 return false;881 }882 if (!tess_id) {883 psError(PS_ERR_UNKNOWN, true, "-tess_id is required");884 return false;885 }886 887 psString exp_tag = psMetadataLookupStr(&status, config->args, "-exp_tag");888 if (!status) {889 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -exp_tag");890 return false;891 }892 if (!exp_tag) {893 psError(PS_ERR_UNKNOWN, true, "-exp_tag is required");894 return false;895 }896 897 psString uri = psMetadataLookupStr(&status, config->args, "-uri");898 if (!status) {899 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -uri");900 return false;901 }902 if (!uri) {903 psError(PS_ERR_UNKNOWN, true, "-uri is required");904 return false;905 }906 907 // defaults to 0908 psS32 p3_version = psMetadataLookupS32(&status, config->args, "-p3_version");909 if (!status) {910 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -p3_version");911 return false;912 }913 914 // optional915 psF64 bg = psMetadataLookupF64(&status, config->args, "-bg");916 if (!status) {917 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -bg");918 return false;919 }920 921 psF64 bg_mean_stdev = psMetadataLookupF64(&status, config->args, "-bg_mean_stdev");922 if (!status) {923 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -bg_mean_stdev");924 return false;925 }926 927 928 // XXX need to validate that this coresponds to an p4InputImfile929 if (!p4ScfileInsert(config->dbh,930 (psS32)atoi(p4_id),931 skycell_id,932 tess_id,933 exp_tag,934 p3_version,935 uri,936 bg,937 bg_mean_stdev938 )) {939 psError(PS_ERR_UNKNOWN, false, "database error");940 return false;941 }942 943 return true;944 }945 946 static bool warpedMode(pxConfig *config)947 {948 PS_ASSERT_PTR_NON_NULL(config, false);949 950 bool status = false;951 psU64 limit = psMetadataLookupU64(&status, config->args, "-limit");952 if (!status) {953 psError(PXTOOLS_ERR_PROG, false, "failed to lookup value for -limit");954 return false;955 }956 957 // find all rawImfiles matching the default query958 psString query = psStringCopy(959 "SELECT\n"960 " p4Scfile.*\n"961 " FROM p4Run\n"962 " JOIN p4Scfile\n"963 " USING(p4_id)\n"964 " WHERE\n"965 " p4Run.state = 'run'\n"966 );967 968 if (config->where) {969 psString whereClause = psDBGenerateWhereConditionSQL(config->where, "p4Scfile");970 psStringAppend(&query, " AND %s", whereClause);971 psFree(whereClause);972 }973 974 // treat limit == 0 as "no limit"975 if (limit) {976 psString limitString = psDBGenerateLimitSQL(limit);977 psStringAppend(&query, " %s", limitString);978 psFree(limitString);979 }980 981 if (!p_psDBRunQuery(config->dbh, query)) {982 psError(PS_ERR_UNKNOWN, false, "database error");983 psFree(query);984 return false;985 }986 psFree(query);987 988 psArray *output = p_psDBFetchResult(config->dbh);989 if (!output) {990 psErrorCode err = psErrorCodeLast();991 switch (err) {992 case PS_ERR_DB_CLIENT:993 psError(PXTOOLS_ERR_SYS, false, "database error");994 case PS_ERR_DB_SERVER:995 psError(PXTOOLS_ERR_PROG, false, "database error");996 default:997 psError(PXTOOLS_ERR_PROG, false, "unknown error");998 }999 1000 return false;1001 }1002 if (!psArrayLength(output)) {1003 psError(PS_ERR_UNKNOWN, false, "no p4Scfile rows found");1004 psFree(output);1005 return true;1006 }1007 1008 bool simple = false;1009 {1010 bool status = false;1011 simple = psMetadataLookupBool(&status, config->args, "-simple");1012 if (!status) {1013 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -simple");1014 return false;1015 }1016 }1017 1018 if (psArrayLength(output)) {1019 // negative simple so the default is true1020 555 if (!ippdbPrintMetadatas(stdout, output, "p4Scfile", !simple)) { 1021 556 psError(PS_ERR_UNKNOWN, false, "failed to print array"); … … 1030 565 } 1031 566 1032 #if 0 1033 static bool tostackedimfileMode(pxConfig *config) 1034 { 1035 PS_ASSERT_PTR_NON_NULL(config, NULL); 1036 1037 psString query = psStringCopy( 1038 " SELECT DISTINCT" 1039 " p4WarpedImfile.*," 1040 " p4Run.workdir" 1041 " FROM p4Run" 1042 " JOIN p4WarpedImfile" 1043 " USING(p4_id)" 1044 " LEFT JOIN p4StackedImfile" 1045 " USING(p4_id, class_id)" 1046 " WHERE" 1047 " p4Run.state = 'run'" 1048 " AND p4StackedImfile.p4_id IS NULL" 1049 " AND p4Stackedmfile.class_id IS NULL" 1050 ); 1051 1052 if (config->where) { 1053 psString whereClause = psDBGenerateWhereConditionSQL(config->where, "p4WarpedImfile"); 1054 psStringAppend(&query, " AND %s", whereClause); 1055 psFree(whereClause); 1056 } 1057 1058 if (!p_psDBRunQuery(config->dbh, query)) { 1059 psError(PS_ERR_UNKNOWN, false, "database error"); 1060 psFree(query); 1061 return false; 1062 } 1063 psFree(query); 1064 1065 psArray *output = p_psDBFetchResult(config->dbh); 1066 if (!output) { 1067 psError(PS_ERR_UNKNOWN, false, "database error"); 1068 return false; 1069 } 1070 if (!psArrayLength(output)) { 1071 psError(PS_ERR_UNKNOWN, false, "no p4WarpedImfile rows found"); 1072 psFree(output); 1073 return true; 1074 } 1075 1076 bool simple = false; 1077 { 1078 bool status = false; 1079 simple = psMetadataLookupBool(&status, config->args, "-simple"); 1080 if (!status) { 1081 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -simple"); 1082 return false; 1083 } 1084 } 1085 1086 // negative simple so the default is true 1087 if (!ippdbPrintMetadatas(stdout, output, "p4WarpedImfile", !simple)) { 1088 psError(PS_ERR_UNKNOWN, false, "failed to print array"); 1089 psFree(output); 1090 return false; 1091 } 1092 1093 psFree(output); 1094 1095 return true; 1096 } 1097 1098 static bool addstackedimfileMode(pxConfig *config) 1099 { 1100 PS_ASSERT_PTR_NON_NULL(config, NULL); 1101 1102 bool status = false; 1103 psString p4_id = psMetadataLookupStr(&status, config->args, "-p4_id"); 1104 if (!status) { 1105 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -p4_id"); 1106 return false; 1107 } 1108 if (!p4_id) { 1109 psError(PS_ERR_UNKNOWN, true, "-p4_id is required"); 1110 return false; 1111 } 1112 1113 psString class_id = psMetadataLookupStr(&status, config->args, "-class_id"); 1114 if (!status) { 1115 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -class_id"); 1116 return false; 1117 } 1118 if (!class_id) { 1119 psError(PS_ERR_UNKNOWN, true, "-class_id is required"); 1120 return false; 1121 } 1122 1123 psString uri = psMetadataLookupStr(&status, config->args, "-uri"); 1124 if (!status) { 1125 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -uri"); 1126 return false; 1127 } 1128 if (!uri) { 1129 psError(PS_ERR_UNKNOWN, true, "-uri is required"); 1130 return false; 1131 } 1132 1133 // optional 1134 psString b1_uri = psMetadataLookupStr(&status, config->args, "-b1_uri"); 1135 if (!status) { 1136 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -b1_uri"); 1137 return false; 1138 } 1139 1140 psString b2_uri = psMetadataLookupStr(&status, config->args, "-b2_uri"); 1141 if (!status) { 1142 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -b2_uri"); 1143 return false; 1144 } 1145 1146 // XXX need to validate that this coresponds to an p4WarpedImfile 1147 if (!p4StackedImfileInsert(config->dbh, 1148 (psS32)atoi(p4_id), 1149 class_id, 1150 uri, 1151 b1_uri, 1152 b2_uri 1153 )) { 1154 psError(PS_ERR_UNKNOWN, false, "database error"); 1155 return false; 1156 } 1157 1158 return true; 1159 } 1160 1161 static bool stackedimfileMode(pxConfig *config) 1162 { 1163 PS_ASSERT_PTR_NON_NULL(config, NULL); 1164 1165 psString query = psStringCopy( 1166 " SELECT DISTINCT" 1167 " p4StackedImfile.*" 1168 " FROM p4Run" 1169 " JOIN p4StackedImfile" 1170 " USING(p4_id)" 1171 " WHERE" 1172 " p4Run.state = 'run'" 1173 ); 1174 1175 if (config->where) { 1176 psString whereClause = psDBGenerateWhereConditionSQL(config->where, "p4StackedImfile"); 1177 psStringAppend(&query, " AND %s", whereClause); 1178 psFree(whereClause); 1179 } 1180 1181 if (!p_psDBRunQuery(config->dbh, query)) { 1182 psError(PS_ERR_UNKNOWN, false, "database error"); 1183 psFree(query); 1184 return false; 1185 } 1186 psFree(query); 1187 1188 psArray *output = p_psDBFetchResult(config->dbh); 1189 if (!output) { 1190 psError(PS_ERR_UNKNOWN, false, "database error"); 1191 return false; 1192 } 1193 if (!psArrayLength(output)) { 1194 psError(PS_ERR_UNKNOWN, false, "no p4StackedImfile rows found"); 1195 psFree(output); 1196 return true; 1197 } 1198 1199 bool simple = false; 1200 { 1201 bool status = false; 1202 simple = psMetadataLookupBool(&status, config->args, "-simple"); 1203 if (!status) { 1204 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -simple"); 1205 return false; 1206 } 1207 } 1208 1209 // negative simple so the default is true 1210 if (!ippdbPrintMetadatas(stdout, output, "p4StackedImfile", !simple)) { 1211 psError(PS_ERR_UNKNOWN, false, "failed to print array"); 1212 psFree(output); 1213 return false; 1214 } 1215 1216 psFree(output); 1217 1218 return true; 1219 } 1220 1221 static bool todiffimfileMode(pxConfig *config) 1222 { 1223 PS_ASSERT_PTR_NON_NULL(config, NULL); 1224 1225 psString query = psStringCopy( 1226 " SELECT DISTINCT" 1227 " p4StackedImfile.*," 1228 " p4WarpedImfile.uri as warped_uri," 1229 " p4Run.workdir" 1230 " FROM p4Run" 1231 " JOIN p4StackedImfile" 1232 " USING(p4_id)" 1233 " JOIN p4WarpedImfile" 1234 " USING(p4_id, class_id)" 1235 " LEFT JOIN p4DiffImfile" 1236 " ON p4WarpedImfile.p4_id = p4DiffImfile.p4_id" 1237 " AND p4WarpedImfile.exp_tag = p4DiffImfile.exp_tag" 1238 " AND p4WarpedImfile.p3_version = p4DiffImfile.p3_version" 1239 " AND p4WarpedImfile.class_id = p4DiffImfile.class_id" 1240 " WHERE" 1241 " p4Run.state = 'run'" 1242 " AND p4DiffImfile.p4_id IS NULL" 1243 " AND p4DiffImfile.exp_tag IS NULL" 1244 " AND p4DiffImfile.p3_version IS NULL" 1245 " AND p4DiffImfile.class_id IS NULL" 1246 ); 1247 1248 if (config->where) { 1249 psString whereClause = psDBGenerateWhereConditionSQL(config->where, "p4StackedImfile"); 1250 psStringAppend(&query, " AND %s", whereClause); 1251 psFree(whereClause); 1252 } 1253 1254 if (!p_psDBRunQuery(config->dbh, query)) { 1255 psError(PS_ERR_UNKNOWN, false, "database error"); 1256 psFree(query); 1257 return false; 1258 } 1259 psFree(query); 1260 1261 psArray *output = p_psDBFetchResult(config->dbh); 1262 if (!output) { 1263 psError(PS_ERR_UNKNOWN, false, "database error"); 1264 return false; 1265 } 1266 if (!psArrayLength(output)) { 1267 psError(PS_ERR_UNKNOWN, false, "no p4StackedImfile rows found"); 1268 psFree(output); 1269 return true; 1270 } 1271 1272 bool simple = false; 1273 { 1274 bool status = false; 1275 simple = psMetadataLookupBool(&status, config->args, "-simple"); 1276 if (!status) { 1277 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -simple"); 1278 return false; 1279 } 1280 } 1281 1282 // negative simple so the default is true 1283 if (!ippdbPrintMetadatas(stdout, output, "p4StackedImfile", !simple)) { 1284 psError(PS_ERR_UNKNOWN, false, "failed to print array"); 1285 psFree(output); 1286 return false; 1287 } 1288 1289 psFree(output); 1290 1291 return true; 1292 } 1293 1294 static bool adddiffimfileMode(pxConfig *config) 1295 { 1296 PS_ASSERT_PTR_NON_NULL(config, NULL); 1297 1298 bool status = false; 1299 psString p4_id = psMetadataLookupStr(&status, config->args, "-p4_id"); 1300 if (!status) { 1301 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -p4_id"); 1302 return false; 1303 } 1304 if (!p4_id) { 1305 psError(PS_ERR_UNKNOWN, true, "-p4_id is required"); 1306 return false; 1307 } 1308 1309 psString exp_tag = psMetadataLookupStr(&status, config->args, "-exp_tag"); 1310 if (!status) { 1311 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -exp_tag"); 1312 return false; 1313 } 1314 if (!exp_tag) { 1315 psError(PS_ERR_UNKNOWN, true, "-exp_tag is required"); 1316 return false; 1317 } 1318 1319 psString class_id = psMetadataLookupStr(&status, config->args, "-class_id"); 1320 if (!status) { 1321 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -class_id"); 1322 return false; 1323 } 1324 if (!class_id) { 1325 psError(PS_ERR_UNKNOWN, true, "-class_id is required"); 1326 return false; 1327 } 1328 1329 psString uri = psMetadataLookupStr(&status, config->args, "-uri"); 1330 if (!status) { 1331 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -uri"); 1332 return false; 1333 } 1334 if (!uri) { 1335 psError(PS_ERR_UNKNOWN, true, "-uri is required"); 1336 return false; 1337 } 1338 1339 // defaults to 0 1340 psS32 p3_version = psMetadataLookupS32(&status, config->args, "-p3_version"); 1341 if (!status) { 1342 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -p3_version"); 1343 return false; 1344 } 1345 1346 // optional 1347 psString b1_uri = psMetadataLookupStr(&status, config->args, "-b1_uri"); 1348 if (!status) { 1349 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -b1_uri"); 1350 return false; 1351 } 1352 1353 psString b2_uri = psMetadataLookupStr(&status, config->args, "-b2_uri"); 1354 if (!status) { 1355 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -b2_uri"); 1356 return false; 1357 } 1358 1359 // XXX need to validate that this coresponds to an p4InputImfile 1360 if (!p4DiffImfileInsert(config->dbh, 1361 (psS32)atoi(p4_id), 1362 exp_tag, 1363 p3_version, 1364 class_id, 1365 uri, 1366 b1_uri, 1367 b2_uri 1368 )) { 1369 psError(PS_ERR_UNKNOWN, false, "database error"); 1370 return false; 1371 } 1372 1373 return true; 1374 } 1375 1376 static bool diffimfileMode(pxConfig *config) 1377 { 1378 PS_ASSERT_PTR_NON_NULL(config, NULL); 1379 1380 psString query = psStringCopy( 1381 " SELECT DISTINCT" 1382 " p4DiffImfile.*" 1383 " FROM p4Run" 1384 " JOIN p4DiffImfile" 1385 " USING(p4_id)" 1386 " WHERE" 1387 " p4Run.state = 'run'" 1388 ); 1389 1390 if (config->where) { 1391 psString whereClause = psDBGenerateWhereConditionSQL(config->where, "p4DiffImfile"); 1392 psStringAppend(&query, " AND %s", whereClause); 1393 psFree(whereClause); 1394 } 1395 1396 if (!p_psDBRunQuery(config->dbh, query)) { 1397 psError(PS_ERR_UNKNOWN, false, "database error"); 1398 psFree(query); 1399 return false; 1400 } 1401 psFree(query); 1402 1403 psArray *output = p_psDBFetchResult(config->dbh); 1404 if (!output) { 1405 psError(PS_ERR_UNKNOWN, false, "database error"); 1406 return false; 1407 } 1408 if (!psArrayLength(output)) { 1409 psError(PS_ERR_UNKNOWN, false, "no p4DiffImfile rows found"); 1410 psFree(output); 1411 return true; 1412 } 1413 1414 bool simple = false; 1415 { 1416 bool status = false; 1417 simple = psMetadataLookupBool(&status, config->args, "-simple"); 1418 if (!status) { 1419 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -simple"); 1420 return false; 1421 } 1422 } 1423 1424 // negative simple so the default is true 1425 if (!ippdbPrintMetadatas(stdout, output, "p4DiffImfile", !simple)) { 1426 psError(PS_ERR_UNKNOWN, false, "failed to print array"); 1427 psFree(output); 1428 return false; 1429 } 1430 1431 psFree(output); 1432 1433 return true; 1434 } 1435 #endif 1436 1437 static bool setp4RunState(pxConfig *config, const char *p4_id, const char *state) 1438 { 1439 PS_ASSERT_PTR_NON_NULL(p4_id, false); 567 568 static bool setp6RunState(pxConfig *config, const char *p6_id, const char *state) 569 { 570 PS_ASSERT_PTR_NON_NULL(p6_id, false); 1440 571 PS_ASSERT_PTR_NON_NULL(state, false); 1441 572 … … 1453 584 1454 585 char *query = "UPDATE p4Run SET state = '%s' WHERE p4_id = '%s'"; 1455 if (!p_psDBRunQuery(config->dbh, query, state, p 4_id)) {586 if (!p_psDBRunQuery(config->dbh, query, state, p6_id)) { 1456 587 psError(PS_ERR_UNKNOWN, false, 1457 "failed to change state for p4_id %s", p4_id); 1458 return false; 1459 } 1460 1461 return true; 1462 } 1463 1464 static bool isValidMode(pxConfig *config, const char *mode) 1465 { 1466 PS_ASSERT_PTR_NON_NULL(config, false); 1467 PS_ASSERT_PTR_NON_NULL(mode, false); 1468 1469 // check that state is a valid string value 1470 if (!( 1471 (strncmp(mode, "warp", 5) == 0) 1472 || (strncmp(mode, "diff", 5) == 0) 1473 || (strncmp(mode, "stack", 6) == 0) 1474 || (strncmp(mode, "magic", 6) == 0) 1475 ) 1476 ) { 1477 psError(PS_ERR_UNKNOWN, false, 1478 "invalid detRun mode: %s", mode); 1479 return false; 1480 } 1481 1482 return true; 1483 } 588 "failed to change state for p6_id %s", p6_id); 589 return false; 590 } 591 592 return true; 593 } -
trunk/ippTools/src/stacktool.h
r11814 r11851 27 27 P6TOOL_MODE_DEFINERUN, 28 28 P6TOOL_MODE_UPDATERUN, 29 P6TOOL_MODE_ADDINPUTEXP, 30 P6TOOL_MODE_EXP, 31 P6TOOL_MODE_IMFILE, 32 P6TOOL_MODE_TOOVERLAP, 33 P6TOOL_MODE_ADDOVERLAP, 34 P6TOOL_MODE_SCMAP, 35 P6TOOL_MODE_TOWARPED, 36 P6TOOL_MODE_ADDWARPED, 37 P6TOOL_MODE_WARPED, 29 P6TOOL_MODE_ADDINPUTSCFILE, 30 P6TOOL_MODE_INPUTSCFILE, 31 P6TOOL_MODE_TOSUM, 32 P6TOOL_MODE_ADDSUMSCFILE, 33 P6TOOL_MODE_SUMSCFILE, 38 34 } p6toolMode; 39 35 -
trunk/ippTools/src/stacktoolConfig.c
r11814 r11851 27 27 #include "p6tool.h" 28 28 29 // this function can not fail -- exits on error30 29 pxConfig *p6toolConfig(pxConfig *config, int argc, char **argv) { 31 30 if (!config) { … … 39 38 if (!config->modules) { 40 39 psError(PS_ERR_UNKNOWN, false, "Can't find site configuration"); 41 goto FAIL; 40 psFree(config); 41 return NULL; 42 42 } 43 43 … … 59 59 // -updaterun 60 60 psMetadata *updaterunArgs = psMetadataAlloc(); 61 psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-p 4_id", 0,62 "define p 4ID (required)", NULL);61 psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-p6_id", 0, 62 "define p6 ID (required)", NULL); 63 63 psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-state", 0, 64 64 "set state (required)", NULL); … … 70 70 #endif 71 71 72 // -addinputexp 73 psMetadata *addinputexpArgs = psMetadataAlloc(); 74 psMetadataAddStr(addinputexpArgs, PS_LIST_TAIL, "-p4_id", 0, 72 // -addinputscfile 73 psMetadata *addinputscfileArgs = psMetadataAlloc(); 74 psMetadataAddStr(addinputscfileArgs, PS_LIST_TAIL, "-p6_id", 0, 75 "define p6 ID (required)", NULL); 76 psMetadataAddStr(addinputscfileArgs, PS_LIST_TAIL, "-p4_id", 0, 75 77 "define p4 ID (required)", NULL); 76 psMetadataAddStr(addinputexpArgs, PS_LIST_TAIL, "-exp_tag", 0, 77 "define exposure tag (required)", NULL); 78 psMetadataAddS32(addinputexpArgs, PS_LIST_TAIL, "-p3_version", 0, 79 "define phase 3 version of exposure tag (required)", 0); 80 psMetadataAddBool(addinputexpArgs, PS_LIST_TAIL, "-magiced", 0, 81 "has this exposure been magiced", false); 82 83 // -exp 84 psMetadata *expArgs = psMetadataAlloc(); 85 psMetadataAddStr(expArgs, PS_LIST_TAIL, "-p4_id", 0, 78 psMetadataAddStr(addinputscfileArgs, PS_LIST_TAIL, "-skycell_id", 0, 79 "define skycell ID (required)", NULL); 80 psMetadataAddStr(addinputscfileArgs, PS_LIST_TAIL, "-tess_id", 0, 81 "define tessellation ID (required)", NULL); 82 83 // -inputscfile 84 psMetadata *inputscfileArgs = psMetadataAlloc(); 85 psMetadataAddStr(inputscfileArgs, PS_LIST_TAIL, "-p6_id", 0, 86 "search by p6 ID (required)", NULL); 87 psMetadataAddStr(inputscfileArgs, PS_LIST_TAIL, "-p4_id", 0, 88 "search by p4 ID (required)", NULL); 89 psMetadataAddStr(inputscfileArgs, PS_LIST_TAIL, "-skycell_id", 0, 90 "search by skycell ID (required)", NULL); 91 psMetadataAddStr(inputscfileArgs, PS_LIST_TAIL, "-tess_id", 0, 92 "search by tessellation ID (required)", NULL); 93 psMetadataAddU64(inputscfileArgs, PS_LIST_TAIL, "-limit", 0, 94 "limit result set to N items", 0); 95 psMetadataAddBool(inputscfileArgs, PS_LIST_TAIL, "-simple", 0, 96 "use the simple output format", false); 97 98 // -tosum 99 psMetadata *tosumArgs = psMetadataAlloc(); 100 psMetadataAddStr(tosumArgs, PS_LIST_TAIL, "-p6_id", 0, 101 "search by p6 ID (required)", NULL); 102 psMetadataAddStr(tosumArgs, PS_LIST_TAIL, "-p4_id", 0, 103 "search by p4 ID (required)", NULL); 104 psMetadataAddStr(tosumArgs, PS_LIST_TAIL, "-skycell_id", 0, 105 "search by skycell ID (required)", NULL); 106 psMetadataAddStr(tosumArgs, PS_LIST_TAIL, "-tess_id", 0, 107 "search by tessellation ID (required)", NULL); 108 psMetadataAddU64(tosumArgs, PS_LIST_TAIL, "-limit", 0, 109 "limit result set to N items", 0); 110 psMetadataAddBool(tosumArgs, PS_LIST_TAIL, "-simple", 0, 111 "use the simple output format", false); 112 113 // -addsumscfile 114 psMetadata *addsumscfileArgs = psMetadataAlloc(); 115 psMetadataAddStr(addsumscfileArgs, PS_LIST_TAIL, "-p4_id", 0, 86 116 "define p4 ID (required)", NULL); 87 psMetadataAddStr(expArgs, PS_LIST_TAIL, "-exp_tag", 0, 88 "define exposure tag (required)", NULL); 89 psMetadataAddS32(expArgs, PS_LIST_TAIL, "-p3_version", 0, 90 "define phase 3 version of exposure tag (required)", 0); 91 psMetadataAddU64(expArgs, PS_LIST_TAIL, "-limit", 0, 117 psMetadataAddStr(addsumscfileArgs, PS_LIST_TAIL, "-skycell_id", 0, 118 "define skycell ID (required)", NULL); 119 psMetadataAddStr(addsumscfileArgs, PS_LIST_TAIL, "-tess_id", 0, 120 "define tessellation ID (required)", NULL); 121 psMetadataAddStr(addsumscfileArgs, PS_LIST_TAIL, "-uri", 0, 122 "define URI of file (required)", 0); 123 psMetadataAddF64(addsumscfileArgs, PS_LIST_TAIL, "-bg", 0, 124 "define exposue background", NAN); 125 psMetadataAddF64(addsumscfileArgs, PS_LIST_TAIL, "-bg_mean_stdev", 0, 126 "define exposue background mean stdev", NAN); 127 128 // -sumscfile 129 psMetadata *sumscfileArgs= psMetadataAlloc(); 130 psMetadataAddStr(sumscfileArgs, PS_LIST_TAIL, "-p6_id", 0, 131 "search by p6 ID (required)", NULL); 132 psMetadataAddStr(sumscfileArgs, PS_LIST_TAIL, "-p4_id", 0, 133 "search by p4 ID (required)", NULL); 134 psMetadataAddStr(sumscfileArgs, PS_LIST_TAIL, "-skycell_id", 0, 135 "search by skycell ID (required)", NULL); 136 psMetadataAddStr(sumscfileArgs, PS_LIST_TAIL, "-tess_id", 0, 137 "search by tessellation ID (required)", NULL); 138 psMetadataAddU64(sumscfileArgs, PS_LIST_TAIL, "-limit", 0, 92 139 "limit result set to N items", 0); 93 psMetadataAddBool(expArgs, PS_LIST_TAIL, "-simple", 0, 94 "use the simple output format", false); 95 96 // -imfile 97 psMetadata *imfileArgs = psMetadataAlloc(); 98 psMetadataAddStr(imfileArgs, PS_LIST_TAIL, "-p4_id", 0, 99 "define p4 ID (required)", NULL); 100 psMetadataAddStr(imfileArgs, PS_LIST_TAIL, "-exp_tag", 0, 101 "define exposure tag (required)", NULL); 102 psMetadataAddS32(imfileArgs, PS_LIST_TAIL, "-p3_version", 0, 103 "define phase 3 version of exposure tag (required)", 0); 104 psMetadataAddU64(imfileArgs, PS_LIST_TAIL, "-limit", 0, 105 "limit result set to N items", 0); 106 psMetadataAddBool(imfileArgs, PS_LIST_TAIL, "-simple", 0, 107 "use the simple output format", false); 108 109 // -tooverlap 110 psMetadata *tooverlapArgs = psMetadataAlloc(); 111 psMetadataAddStr(tooverlapArgs, PS_LIST_TAIL, "-p4_id", 0, 112 "search by p4 ID", NULL); 113 psMetadataAddU64(tooverlapArgs, PS_LIST_TAIL, "-limit", 0, 114 "limit result set to N items", 0); 115 psMetadataAddBool(tooverlapArgs, PS_LIST_TAIL, "-simple", 0, 116 "use the simple output format", false); 117 118 // -addoverlap 119 psMetadata *addoverlapArgs = psMetadataAlloc(); 120 psMetadataAddStr(addoverlapArgs, PS_LIST_TAIL, "-mapfile", 0, 121 "skycell <-> imfile mapping description", NULL); 122 123 // -scmap 124 psMetadata *scmapArgs = psMetadataAlloc(); 125 psMetadataAddStr(scmapArgs, PS_LIST_TAIL, "-p4_id", 0, 126 "search by p4 ID", NULL); 127 psMetadataAddStr(scmapArgs, PS_LIST_TAIL, "-skycell_id", 0, 128 "searcy by skycell ID", NULL); 129 psMetadataAddStr(scmapArgs, PS_LIST_TAIL, "-tess_id", 0, 130 "searcy by tess ID", NULL); 131 psMetadataAddU64(scmapArgs, PS_LIST_TAIL, "-limit", 0, 132 "limit result set to N items", 0); 133 psMetadataAddBool(scmapArgs, PS_LIST_TAIL, "-simple", 0, 134 "use the simple output format", false); 135 136 // -towarped 137 psMetadata *towarpedArgs = psMetadataAlloc(); 138 psMetadataAddStr(towarpedArgs, PS_LIST_TAIL, "-p4_id", 0, 139 "search by p4 ID", NULL); 140 psMetadataAddU64(towarpedArgs, PS_LIST_TAIL, "-limit", 0, 141 "limit result set to N items", 0); 142 psMetadataAddBool(towarpedArgs, PS_LIST_TAIL, "-simple", 0, 143 "use the simple output format", false); 144 145 // -addwarped 146 psMetadata *addwarpedArgs = psMetadataAlloc(); 147 psMetadataAddStr(addwarpedArgs, PS_LIST_TAIL, "-p4_id", 0, 148 "define p4 ID (required)", NULL); 149 psMetadataAddStr(addwarpedArgs, PS_LIST_TAIL, "-skycell_id", 0, 150 "define skycell ID (required)", NULL); 151 psMetadataAddStr(addwarpedArgs, PS_LIST_TAIL, "-tess_id", 0, 152 "define tessellation ID (required)", NULL); 153 psMetadataAddStr(addwarpedArgs, PS_LIST_TAIL, "-exp_tag", 0, 154 "define exposure tag (required)", NULL); 155 psMetadataAddS32(addwarpedArgs, PS_LIST_TAIL, "-p3_version", 0, 156 "define phase 3 version of exposure tag (required)", 0); 157 psMetadataAddStr(addwarpedArgs, PS_LIST_TAIL, "-uri", 0, 158 "define URI of file (required)", 0); 159 psMetadataAddF64(addwarpedArgs, PS_LIST_TAIL, "-bg", 0, 160 "define exposue background", NAN); 161 psMetadataAddF64(addwarpedArgs, PS_LIST_TAIL, "-bg_mean_stdev", 0, 162 "define exposue background mean stdev", NAN); 163 164 // -warped 165 psMetadata *warpedArgs = psMetadataAlloc(); 166 psMetadataAddStr(warpedArgs, PS_LIST_TAIL, "-p4_id", 0, 167 "search by p4 ID", NULL); 168 psMetadataAddStr(warpedArgs, PS_LIST_TAIL, "-skycell_id", 0, 169 "define skycell ID (required)", NULL); 170 psMetadataAddStr(warpedArgs, PS_LIST_TAIL, "-tess_id", 0, 171 "define tessellation ID (required)", NULL); 172 psMetadataAddStr(warpedArgs, PS_LIST_TAIL, "-exp_tag", 0, 173 "define exposure tag (required)", NULL); 174 psMetadataAddS32(warpedArgs, PS_LIST_TAIL, "-p3_version", 0, 175 "define phase 3 version of exposure tag (required)", 0); 176 psMetadataAddU64(warpedArgs, PS_LIST_TAIL, "-limit", 0, 177 "limit result set to N items", 0); 178 psMetadataAddBool(warpedArgs, PS_LIST_TAIL, "-simple", 0, 179 "use the simple output format", false); 180 181 #if 0 182 // -tostackedimfile 183 psMetadata *tostackedimfileArgs = psMetadataAlloc(); 184 psMetadataAddStr(tostackedimfileArgs, PS_LIST_TAIL, "-p4_id", 0, 185 "search by p4 ID", NULL); 186 psMetadataAddBool(tostackedimfileArgs, PS_LIST_TAIL, "-simple", 0, 187 "use the simple output format", false); 188 189 // -addstackedimfile 190 psMetadata *addstackedimfileArgs = psMetadataAlloc(); 191 psMetadataAddStr(addstackedimfileArgs, PS_LIST_TAIL, "-p4_id", 0, 192 "define p4 ID (required)", NULL); 193 psMetadataAddStr(addstackedimfileArgs, PS_LIST_TAIL, "-exp_tag", 0, 194 "define exposure tag (required)", NULL); 195 psMetadataAddS32(addstackedimfileArgs, PS_LIST_TAIL, "-p3_version", 0, 196 "define phase 3 version of exposure tag (required)", 0); 197 psMetadataAddStr(addstackedimfileArgs, PS_LIST_TAIL, "-class_id", 0, 198 "define class ID (required)", 0); 199 psMetadataAddStr(addstackedimfileArgs, PS_LIST_TAIL, "-uri", 0, 200 "define URI of file (required)", 0); 201 psMetadataAddStr(addstackedimfileArgs, PS_LIST_TAIL, "-b1_uri", 0, 202 "define banana 1", NULL); 203 psMetadataAddStr(addstackedimfileArgs, PS_LIST_TAIL, "-b2_uri", 0, 204 "define banana 2", NULL); 205 206 // -stackedimfile 207 psMetadata *stackedimfileArgs = psMetadataAlloc(); 208 psMetadataAddStr(stackedimfileArgs, PS_LIST_TAIL, "-p4_id", 0, 209 "search by p4 ID", NULL); 210 psMetadataAddBool(stackedimfileArgs, PS_LIST_TAIL, "-simple", 0, 211 "use the simple output format", false); 212 213 // -todiffimfile 214 psMetadata *todiffimfileArgs = psMetadataAlloc(); 215 psMetadataAddStr(todiffimfileArgs, PS_LIST_TAIL, "-p4_id", 0, 216 "search by p4 ID", NULL); 217 psMetadataAddBool(todiffimfileArgs, PS_LIST_TAIL, "-simple", 0, 218 "use the simple output format", false); 219 220 // -adddiffimfile 221 psMetadata *adddiffimfileArgs = psMetadataAlloc(); 222 psMetadataAddStr(adddiffimfileArgs, PS_LIST_TAIL, "-p4_id", 0, 223 "define p4 ID (required)", NULL); 224 psMetadataAddStr(adddiffimfileArgs, PS_LIST_TAIL, "-exp_tag", 0, 225 "define exposure tag (required)", NULL); 226 psMetadataAddS32(adddiffimfileArgs, PS_LIST_TAIL, "-p3_version", 0, 227 "define phase 3 version of exposure tag (required)", 0); 228 psMetadataAddStr(adddiffimfileArgs, PS_LIST_TAIL, "-class_id", 0, 229 "define class ID (required)", 0); 230 psMetadataAddStr(adddiffimfileArgs, PS_LIST_TAIL, "-uri", 0, 231 "define URI of file (required)", 0); 232 psMetadataAddStr(adddiffimfileArgs, PS_LIST_TAIL, "-b1_uri", 0, 233 "define banana 1", NULL); 234 psMetadataAddStr(adddiffimfileArgs, PS_LIST_TAIL, "-b2_uri", 0, 235 "define banana 2", NULL); 236 237 // -diffimfile 238 psMetadata *diffimfileArgs = psMetadataAlloc(); 239 psMetadataAddStr(diffimfileArgs, PS_LIST_TAIL, "-p4_id", 0, 240 "search by p4 ID", NULL); 241 psMetadataAddBool(diffimfileArgs, PS_LIST_TAIL, "-simple", 0, 242 "use the simple output format", false); 243 #endif 140 psMetadataAddBool(sumscfileArgs, PS_LIST_TAIL, "-simple", 0, 141 "use the simple output format", false); 244 142 245 143 psFree(now); … … 252 150 if (config->mode) { \ 253 151 psError(PS_ERR_UNKNOWN, true, "only one mode selection is allowed"); \ 254 goto FAIL; \ 152 psFree(config); \ 153 return NULL; \ 255 154 } \ 256 155 config->mode = modeval; \ … … 267 166 PXTOOL_MODE("-definerun", P6TOOL_MODE_DEFINERUN, definerunArgs); 268 167 PXTOOL_MODE("-updaterun", P6TOOL_MODE_UPDATERUN, updaterunArgs); 269 PXTOOL_MODE("-addinputexp", P6TOOL_MODE_ADDINPUTEXP, addinputexpArgs); 270 PXTOOL_MODE("-exp", P6TOOL_MODE_EXP, expArgs); 271 PXTOOL_MODE("-imfile", P6TOOL_MODE_IMFILE, imfileArgs); 272 PXTOOL_MODE("-tooverlap", P6TOOL_MODE_TOOVERLAP, tooverlapArgs); 273 PXTOOL_MODE("-addoverlap", P6TOOL_MODE_ADDOVERLAP, addoverlapArgs); 274 PXTOOL_MODE("-scmap", P6TOOL_MODE_SCMAP, scmapArgs); 275 PXTOOL_MODE("-towarped", P6TOOL_MODE_TOWARPED, towarpedArgs); 276 PXTOOL_MODE("-addwarped", P6TOOL_MODE_ADDWARPED, addwarpedArgs); 277 PXTOOL_MODE("-warped", P6TOOL_MODE_WARPED, warpedArgs); 278 #if 0 279 PXTOOL_MODE("-tostackedimfile", P6TOOL_MODE_TOSTACKEDIMFILE, tostackedimfileArgs); 280 PXTOOL_MODE("-addstackedimfile", P6TOOL_MODE_ADDSTACKEDIMFILE, addstackedimfileArgs); 281 PXTOOL_MODE("-stackedimfile", P6TOOL_MODE_STACKEDIMFILE, stackedimfileArgs); 282 PXTOOL_MODE("-todiffimfile", P6TOOL_MODE_TODIFFIMFILE, todiffimfileArgs); 283 PXTOOL_MODE("-adddiffimfile", P6TOOL_MODE_ADDDIFFIMFILE, adddiffimfileArgs); 284 PXTOOL_MODE("-diffimfile", P6TOOL_MODE_DIFFIMFILE, diffimfileArgs); 285 #endif 168 PXTOOL_MODE("-addinputscfile", P6TOOL_MODE_ADDINPUTSCFILE, addinputscfileArgs); 169 PXTOOL_MODE("-inputscfile", P6TOOL_MODE_INPUTSCFILE, inputscfileArgs); 170 PXTOOL_MODE("-tosum", P6TOOL_MODE_TOSUM, tosumArgs); 171 PXTOOL_MODE("-addsumscfile", P6TOOL_MODE_ADDSUMSCFILE, addsumscfileArgs); 172 PXTOOL_MODE("-sumscfile", P6TOOL_MODE_SUMSCFILE, sumscfileArgs); 286 173 287 174 bool argErr = false; … … 312 199 313 200 psFree(argSets); 314 goto FAIL; 201 psFree(config); 202 return NULL; 315 203 } 316 204 … … 325 213 if (!psMetadataAddStr(config->where, PS_LIST_TAIL, #name, 0, "==", str)) {\ 326 214 psError(PS_ERR_UNKNOWN, false, "failed to add item " #name); \ 327 goto FAIL; \ 215 psFree(config); \ 216 return NULL; \ 328 217 } \ 329 218 } \ … … 337 226 if (!psMetadataAddS32(config->where, PS_LIST_TAIL, #name, 0, "==", s32)) { \ 338 227 psError(PS_ERR_UNKNOWN, false, "failed to add item " #name); \ 339 goto FAIL; \ 228 psFree(config); \ 229 return NULL; \ 340 230 } \ 341 231 } \ … … 352 242 if (!psMetadataAddS32(config->where, PS_LIST_TAIL, "p4_id", 0, "==", (psS32)atoi(str))) { 353 243 psError(PS_ERR_UNKNOWN, false, "failed to add item p4_id"); 354 goto FAIL; 244 psFree(config); 245 return NULL; 355 246 } 356 247 } … … 371 262 if (!config->dbh) { 372 263 psError(PS_ERR_UNKNOWN, false, "Can't configure database"); 373 goto FAIL; 264 psFree(config); 265 return NULL; 374 266 } 375 267 … … 379 271 380 272 return config; 381 382 FAIL: 383 psFree(config); 384 pmConfigDone(); 385 psLibFinalize(); 386 exit(EXIT_FAILURE); 387 } 273 }
Note:
See TracChangeset
for help on using the changeset viewer.
