Changeset 25800 for trunk/ippTools/src
- Timestamp:
- Oct 7, 2009, 4:25:35 PM (17 years ago)
- Location:
- trunk/ippTools/src
- Files:
-
- 11 edited
-
chiptool.c (modified) (1 diff)
-
chiptoolConfig.c (modified) (1 diff)
-
difftool.c (modified) (7 diffs)
-
difftool.h (modified) (1 diff)
-
difftoolConfig.c (modified) (3 diffs)
-
pxchip.c (modified) (2 diffs)
-
pxchip.h (modified) (1 diff)
-
stacktool.c (modified) (3 diffs)
-
stacktoolConfig.c (modified) (1 diff)
-
warptool.c (modified) (1 diff)
-
warptoolConfig.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippTools/src/chiptool.c
r25790 r25800 728 728 PXOPT_COPY_S64(config->args, where, "-chip_id", "chip_id", "=="); 729 729 PXOPT_COPY_STR(config->args, where, "-class_id", "class_id", "=="); 730 PXOPT_LOOKUP_S16(fault, config->args, "-fault", true, false); 731 732 if (!pxSetFaultCode(config->dbh, "chipProcessedImfile", where, fault)) { 730 PXOPT_LOOKUP_STR(state, config->args, "-set_state", false, NULL); 731 732 if (!state) { 733 PXOPT_LOOKUP_S16(fault, config->args, "-fault", true, false); 734 735 if (!pxSetFaultCode(config->dbh, "chipProcessedImfile", where, fault)) { 733 736 psError(PS_ERR_UNKNOWN, false, "failed to set set fault flag"); 734 737 return false; 735 } 736 psFree(where); 737 738 } 739 psFree(where); 740 } 741 else { 742 if (!pxchipProcessedImfileSetStateByQuery(config,where,state)) { 743 psError(PS_ERR_UNKNOWN, false, "failed to set chipProcessedImfile state"); 744 return(false); 745 } 746 } 747 748 738 749 return true; 739 750 } -
trunk/ippTools/src/chiptoolConfig.c
r25777 r25800 182 182 psMetadataAddStr(updateprocessedimfileArgs, PS_LIST_TAIL, "-class_id", 0, "search by class ID", NULL); 183 183 psMetadataAddS16(updateprocessedimfileArgs, PS_LIST_TAIL, "-fault", 0, "set fault code (required)", 0); 184 184 psMetadataAddStr(updateprocessedimfileArgs, PS_LIST_TAIL, "-set_state", 0, "set state", NULL); 185 185 // -block 186 186 psMetadata *blockArgs = psMetadataAlloc(); -
trunk/ippTools/src/difftool.c
r25790 r25800 51 51 52 52 static bool setdiffRunState(pxConfig *config, psS64 diff_id, const char *state, psS64 magicked); 53 static bool setdiffRunStateByLabel(pxConfig *config, const char* label, const char *state); 54 static bool change_skyfile_data_state(pxConfig *config, psString data_state, psString run_state); 55 static bool tocleanedskyfileMode(pxConfig *config); 56 static bool topurgedskyfileMode(pxConfig *config); 57 static bool toscrubbedskyfileMode(pxConfig *config); 58 59 53 60 54 61 # define MODECASE(caseName, func) \ … … 88 95 MODECASE(DIFFTOOL_MODE_EXPORTRUN, exportrunMode); 89 96 MODECASE(DIFFTOOL_MODE_IMPORTRUN, importrunMode); 97 MODECASE(DIFFTOOL_MODE_TOCLEANEDSKYFILE, tocleanedskyfileMode); 98 MODECASE(DIFFTOOL_MODE_TOPURGEDSKYFILE, topurgedskyfileMode); 99 MODECASE(DIFFTOOL_MODE_TOSCRUBBEDSKYFILE, toscrubbedskyfileMode); 100 90 101 default: 91 102 psAbort("invalid option (this should not happen)"); … … 169 180 170 181 // required options 171 PXOPT_LOOKUP_S64(diff_id, config->args, "-diff_id", true, false);182 PXOPT_LOOKUP_S64(diff_id, config->args, "-diff_id", false, false); 172 183 PXOPT_LOOKUP_STR(state, config->args, "-state", true, false); 173 174 if (state) { 184 PXOPT_LOOKUP_STR(label, config->args, "-label", false, false); 185 186 // Copy of my hacky work around from stacktool.c 187 if ((state)&&(diff_id)) { 175 188 // set detRun.state to state 176 189 return setdiffRunState(config, diff_id, state, false); 177 190 } 178 191 179 return true; 192 if ((state)&&(label)) { 193 return setdiffRunStateByLabel(config, label, state); 194 } 195 196 psError(PS_ERR_UNKNOWN, false, "Required options not found."); 197 198 return false; 180 199 } 181 200 … … 865 884 } 866 885 867 char *query = "UPDATE diffRun SET state = '%s', magicked = %" PRId64 " WHERE diff_id = %"PRId64; 868 869 if (!p_psDBRunQueryF(config->dbh, query, state, magicked, diff_id)) { 886 if (magicked) { 887 char *query = "UPDATE diffRun SET state = '%s', magicked = %" PRId64 " WHERE diff_id = %"PRId64; 888 889 if (!p_psDBRunQueryF(config->dbh, query, state, magicked, diff_id)) { 870 890 psError(PS_ERR_UNKNOWN, false, 871 891 "failed to change state for diff_id %"PRId64, diff_id); 872 892 return false; 873 } 874 893 } 894 } 895 else { 896 char *query = "UPDATE diffRun SET state = '%s' WHERE diff_id = %"PRId64; 897 898 if (!p_psDBRunQueryF(config->dbh, query, state, diff_id)) { 899 psError(PS_ERR_UNKNOWN, false, 900 "failed to change state for diff_id %"PRId64, diff_id); 901 return false; 902 } 903 } 904 875 905 return true; 906 } 907 908 909 static bool setdiffRunStateByLabel(pxConfig *config, const char *label, const char *state) { 910 PS_ASSERT_PTR_NON_NULL(state,false); 911 912 // check that state is a valid string value 913 if (!pxIsValidState(state)) { 914 psError(PS_ERR_UNKNOWN, false, "invalid diffRun state: %s", state); 915 return false; 916 } 917 918 char *query = "UPDATE diffRun SET state = '%s' WHERE label = '%s'"; 919 if (!p_psDBRunQueryF(config->dbh,query,state,label)) { 920 psError(PS_ERR_UNKNOWN, false, 921 "failed to change state for label %s", label); 922 return(false); 923 } 924 925 return true; 876 926 } 877 927 … … 1725 1775 1726 1776 psMetadata *where = psMetadataAlloc(); 1727 pxAddLabelSearchArgs (config, where, "-label", " diffRun.label", "==");1777 pxAddLabelSearchArgs (config, where, "-label", "label", "=="); 1728 1778 1729 1779 psString query = pxDataGet("difftool_pendingcleanuprun.sql"); … … 1747 1797 } 1748 1798 1799 // fprintf(stderr,"%s",query); 1749 1800 if (!p_psDBRunQuery(config->dbh, query)) { 1750 1801 psError(PS_ERR_UNKNOWN, false, "database error"); … … 1918 1969 1919 1970 return true; 1971 } 1972 1973 static bool change_skyfile_data_state(pxConfig *config, psString data_state, psString run_state) { 1974 PS_ASSERT_PTR_NON_NULL(config, false); 1975 1976 // diff_id, skycell_id are required 1977 PXOPT_LOOKUP_S64(diff_id, config->args, "-diff_id", true, false); 1978 PXOPT_LOOKUP_STR(skycell_id, config->args, "-skycell_id", true, false); 1979 1980 psString query = pxDataGet("difftool_change_skyfile_data_state.sql"); 1981 1982 if (!psDBTransaction(config->dbh)) { 1983 psError(PS_ERR_UNKNOWN, false, "database error"); 1984 return(false); 1985 } 1986 1987 // Uses the unconstrained (diffRun.state [NEED NOT EQUAL] run_state) version from warptool.c 1988 1989 if (!p_psDBRunQueryF(config->dbh, query, data_state, diff_id, skycell_id)) { 1990 psError(PS_ERR_UNKNOWN, false, "database error"); 1991 // rollback 1992 if (!psDBRollback(config->dbh)) { 1993 psError(PS_ERR_UNKNOWN, false, "database error"); 1994 } 1995 psError(PS_ERR_UNKNOWN, false, "database error"); 1996 return(false); 1997 } 1998 psFree(query); 1999 2000 query = pxDataGet("difftool_change_run_state.sql"); 2001 if (!p_psDBRunQueryF(config->dbh, query, data_state, diff_id, data_state)) { 2002 // rollback 2003 if (!psDBRollback(config->dbh)) { 2004 psError(PS_ERR_UNKNOWN, false, "database error"); 2005 } 2006 psError(PS_ERR_UNKNOWN, false, "database error"); 2007 return(false); 2008 } 2009 2010 if (!psDBCommit(config->dbh)) { 2011 psError(PS_ERR_UNKNOWN, false, "database error"); 2012 return(false); 2013 } 2014 2015 return(true); 2016 } 2017 2018 static bool tocleanedskyfileMode(pxConfig *config) { 2019 return change_skyfile_data_state(config, "cleaned","goto_cleaned"); 2020 } 2021 static bool topurgedskyfileMode(pxConfig *config) { 2022 return change_skyfile_data_state(config, "purged", "goto_purged"); 2023 } 2024 static bool toscrubbedskyfileMode(pxConfig *config) { 2025 return change_skyfile_data_state(config, "scrubbed", "goto_scrubbed"); 1920 2026 } 1921 2027 -
trunk/ippTools/src/difftool.h
r25509 r25800 42 42 DIFFTOOL_MODE_UPDATEDIFFSKYFILE, 43 43 DIFFTOOL_MODE_EXPORTRUN, 44 DIFFTOOL_MODE_IMPORTRUN 44 DIFFTOOL_MODE_IMPORTRUN, 45 DIFFTOOL_MODE_TOCLEANEDSKYFILE, 46 DIFFTOOL_MODE_TOPURGEDSKYFILE, 47 DIFFTOOL_MODE_TOSCRUBBEDSKYFILE 48 45 49 } difftoolMode; 46 50 -
trunk/ippTools/src/difftoolConfig.c
r25775 r25800 60 60 psMetadataAddS64(updaterunArgs, PS_LIST_TAIL, "-diff_id", 0, "define diff ID (required)", 0); 61 61 psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-state", 0, "set state (required)", NULL); 62 62 psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-label", 0, "define by label instead of diff ID", 0); 63 63 64 // -addinputskyfile 64 65 psMetadata *addinputskyfileArgs = psMetadataAlloc(); … … 258 259 psMetadataAddS16(updatediffskyfileArgs, PS_LIST_TAIL, "-fault", 0, "set fault code (required)", 0); 259 260 261 // -tocleanedskyfile 262 psMetadata *tocleanedskyfileArgs = psMetadataAlloc(); 263 psMetadataAddS64(tocleanedskyfileArgs, PS_LIST_TAIL, "-diff_id", 0, "difftool ID to update", 0); 264 psMetadataAddStr(tocleanedskyfileArgs, PS_LIST_TAIL, "-skycell_id", 0, "skycell ID to update", NULL); 265 266 // -topurgedskyfile 267 psMetadata *topurgedskyfileArgs = psMetadataAlloc(); 268 psMetadataAddS64(topurgedskyfileArgs, PS_LIST_TAIL, "-diff_id", 0, "difftool ID to update", 0); 269 psMetadataAddStr(topurgedskyfileArgs, PS_LIST_TAIL, "-skycell_id", 0, "skycell ID to update", NULL); 270 271 // -toscrubbedskyfile 272 psMetadata *toscrubbedskyfileArgs = psMetadataAlloc(); 273 psMetadataAddS64(toscrubbedskyfileArgs, PS_LIST_TAIL, "-diff_id", 0, "difftool ID to update", 0); 274 psMetadataAddStr(toscrubbedskyfileArgs, PS_LIST_TAIL, "-skycell_id", 0, "skycell ID to update", NULL); 275 260 276 // -exportrun 261 277 psMetadata *exportrunArgs = psMetadataAlloc(); … … 295 311 PXOPT_ADD_MODE("-importrun", "import run from metadata file", DIFFTOOL_MODE_IMPORTRUN, importrunArgs); 296 312 313 PXOPT_ADD_MODE("-tocleanedskyfile", "set skyfile as cleaned", DIFFTOOL_MODE_TOCLEANEDSKYFILE, tocleanedskyfileArgs); 314 PXOPT_ADD_MODE("-topurgedskyfile", "set skyfile as purged", DIFFTOOL_MODE_TOPURGEDSKYFILE, topurgedskyfileArgs); 315 PXOPT_ADD_MODE("-toscrubbedskyfile", "set skyfile as scrubbed", DIFFTOOL_MODE_TOSCRUBBEDSKYFILE, toscrubbedskyfileArgs); 316 297 317 if (!pxGetOptions(stderr, argc, argv, config, modes, argSets)) { 298 318 psError(PS_ERR_UNKNOWN, true, "option parsing failed"); -
trunk/ippTools/src/pxchip.c
r24866 r25800 192 192 } 193 193 194 195 194 bool pxchipRunSetLabel(pxConfig *config, psS64 chip_id, const char *label) 196 195 { … … 233 232 } 234 233 234 bool pxchipProcessedImfileSetStateByQuery(pxConfig *config, psMetadata *where, const char *state) 235 { 236 PS_ASSERT_PTR_NON_NULL(config, false); 237 PS_ASSERT_PTR_NON_NULL(state, false); 238 239 // check that state is a valid string value 240 if (!pxIsValidState(state)) { 241 psError(PS_ERR_UNKNOWN, false, "invalid chipProcessedImfile state: %s", state); 242 return false; 243 } 244 245 /* if (!strcmp(state, "full")) { */ 246 /* // There are states that need to be met for a run to be set to full that we don't */ 247 /* // check here. */ 248 /* // for example all of the run's Imfiles must have chipProcessedImfile.data_state == "full" */ 249 /* // chipRun.magicked = (SUM(!chipProcessedImfile.magicked) = 0) */ 250 /* // so don't do allow setting the state to full */ 251 /* psError(PS_ERR_UNKNOWN, true, "cannot use -updaterun so set chipRun state to full"); */ 252 /* return false; */ 253 /* } */ 254 255 psString query = psStringCopy("UPDATE chipProcessedImfile JOIN chipRun USING(chip_id) JOIN rawExp ON chipRun.exp_id = rawExp.exp_id SET state = '%s'"); 256 257 if (where && psListLength(where->list) > 0) { 258 psString whereClause = psDBGenerateWhereSQL(where, NULL); 259 psStringAppend(&query, " %s", whereClause); 260 psFree(whereClause); 261 } 262 263 if (!p_psDBRunQueryF(config->dbh, query, state)) { 264 psFree(query); 265 psError(PS_ERR_UNKNOWN, false, "database error"); 266 return false; 267 } 268 269 psFree(query); 270 271 return true; 272 } 235 273 236 274 psS64 pxchipQueueByExpTag(pxConfig *config, -
trunk/ippTools/src/pxchip.h
r23381 r25800 25 25 #include "pxtools.h" 26 26 27 28 27 29 bool pxchipRunSetState(pxConfig *config, psS64 chip_id, const char *state, const bool magicked); 28 30 bool pxchipRunSetStateByQuery(pxConfig *config, psMetadata *where, const char *state); 29 31 bool pxchipRunSetLabel(pxConfig *config, psS64 chip_id, const char *label); 30 32 bool pxchipRunSetLabelByQuery(pxConfig *config, psMetadata *where, const char *label); 33 34 bool pxchipProcessedImfileSetStateByQuery(pxConfig *config, psMetadata *where, const char *state); 31 35 32 36 psS64 pxchipQueueByExpTag(pxConfig *config, -
trunk/ippTools/src/stacktool.c
r25691 r25800 48 48 49 49 static bool setstackRunState(pxConfig *config, psS64 stack_id, const char *state); 50 static bool setstackRunStateByLabel(pxConfig *config, const char *label, const char *state); 50 51 51 52 # define MODECASE(caseName, func) \ … … 569 570 PS_ASSERT_PTR_NON_NULL(config, false); 570 571 571 PXOPT_LOOKUP_S64(stack_id, config->args, "-stack_id", true, false);572 PXOPT_LOOKUP_S64(stack_id, config->args, "-stack_id", false, false); 572 573 PXOPT_LOOKUP_STR(state, config->args, "-state", true, false); 573 574 if (state) { 574 PXOPT_LOOKUP_STR(label, config->args, "-label", false, false); 575 576 // Hack-y work around to make stacktool more like the other tools, without breaking other stuff (hopefully). 577 578 if ((state)&&(stack_id)) { 575 579 // set detRun.state to state 576 580 return setstackRunState(config, stack_id, state); 577 581 } 578 582 579 return true; 583 if ((state)&&(label)) { 584 return setstackRunStateByLabel(config, label, state); 585 } 586 587 psError(PS_ERR_UNKNOWN, false, "Required options not found."); 588 return false; 580 589 } 581 590 … … 1006 1015 } 1007 1016 1017 static bool setstackRunStateByLabel(pxConfig *config, const char *label, const char *state) 1018 { 1019 PS_ASSERT_PTR_NON_NULL(state, false); 1020 1021 // check that state is a valid string value 1022 if (!pxIsValidState(state)) { 1023 psError(PS_ERR_UNKNOWN, false, "invalid stackRun state: %s", state); 1024 return false; 1025 } 1026 1027 char *query = "UPDATE stackRun SET state = '%s' WHERE label = '%s'"; 1028 if (!p_psDBRunQueryF(config->dbh, query, state, label)) { 1029 psError(PS_ERR_UNKNOWN, false, 1030 "failed to change state for label %s", label); 1031 return false; 1032 } 1033 1034 return true; 1035 } 1036 1008 1037 static bool pendingcleanuprunMode(pxConfig *config) 1009 1038 { -
trunk/ippTools/src/stacktoolConfig.c
r25691 r25800 108 108 psMetadataAddS64(updaterunArgs, PS_LIST_TAIL, "-stack_id", 0, "define stack ID (required)", 0); 109 109 psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-state", 0, "set state (required)", NULL); 110 110 psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-label", 0, "define by label instead of stack ID", 0); 111 111 112 // -addinputskyfile 112 113 psMetadata *addinputskyfileArgs = psMetadataAlloc(); -
trunk/ippTools/src/warptool.c
r25778 r25800 1709 1709 PXOPT_LOOKUP_STR(skycell_id, config->args, "-skycell_id", true, false); 1710 1710 PXOPT_LOOKUP_S16(fault, config->args, "-fault", false, false); 1711 1712 psString query = pxDataGet("warptool_updateskyfile.sql"); 1713 1714 if (!p_psDBRunQueryF(config->dbh, query, fault, warp_id, skycell_id)) { 1715 psError(PS_ERR_UNKNOWN, false, "database error"); 1716 return false; 1717 } 1718 psFree(query); 1711 PXOPT_LOOKUP_STR(state, config->args, "-set_state", false, false); 1712 1713 if (!state) { 1714 psString query = pxDataGet("warptool_updateskyfile.sql"); 1715 1716 if (!p_psDBRunQueryF(config->dbh, query, fault, warp_id, skycell_id)) { 1717 psError(PS_ERR_UNKNOWN, false, "database error"); 1718 return false; 1719 } 1720 psFree(query); 1721 } 1722 else { 1723 if (strcmp(state,"error_cleaned") == 0) { 1724 change_skyfile_data_state(config,"error_cleaned","goto_cleaned"); 1725 } 1726 else if (strcmp(state, "error_scrubbed") == 0) { 1727 change_skyfile_data_state(config,"error_scrubbed","goto_scrubbed"); 1728 } 1729 else if (strcmp(state, "error_purged") == 0) { 1730 change_skyfile_data_state(config,"error_purged","goto_purged"); 1731 } 1732 else { 1733 psError(PS_ERR_UNKNOWN, false, "unhandled state given"); 1734 return(false); 1735 } 1736 } 1719 1737 1720 1738 return true; -
trunk/ippTools/src/warptoolConfig.c
r25775 r25800 305 305 psMetadataAddStr(updateskyfileArgs, PS_LIST_TAIL, "-skycell_id", 0, "skycell ID to update", NULL); 306 306 psMetadataAddS16(updateskyfileArgs, PS_LIST_TAIL, "-fault", 0, "new fault code", 0); 307 307 psMetadataAddStr(updateskyfileArgs, PS_LIST_TAIL, "-set_state", 0, "set state", 0); 308 308 309 // -exportrun 309 310 psMetadata *exportrunArgs = psMetadataAlloc();
Note:
See TracChangeset
for help on using the changeset viewer.
