IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Aug 16, 2008, 1:27:58 PM (18 years ago)
Author:
eugene
Message:

extensive changes from eam_branch_20080719:

  • added the 'cleanup' options to camtool, faketool, warptool, difftool, stacktool
  • added corresponding sql code
  • changed the states for camera, fake, warp, diff, and stack to the new set of states: new, full, goto_cleaned, cleaned, update, goto_purged, and purged
  • added 'data_state' entries to the detrend tables and the detRunSummary
  • added 'cleanup' options to dettool using the detRunSummary data_state as the control
  • moved dettool supporting code to dettool_STAGE, where stage is processedimfile, processedexp, etc.
  • converted dettool to use S64 for det_id and exp_id entries
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ippTools/src/faketool.c

    r18686 r19092  
    4545static bool unmaskedMode(pxConfig *config);
    4646static bool unblockMode(pxConfig *config);
     47static bool pendingcleanuprunMode(pxConfig *config);
     48static bool pendingcleanupimfileMode(pxConfig *config);
     49static bool donecleanupMode(pxConfig *config);
    4750
    4851static bool fakeProcessedCompleteExp(pxConfig *config);
     
    6568
    6669    switch (config->mode) {
    67         MODECASE(FAKETOOL_MODE_DEFINEBYQUERY,                   definebyqueryMode);
     70        MODECASE(FAKETOOL_MODE_DEFINEBYQUERY,           definebyqueryMode);
    6871        MODECASE(FAKETOOL_MODE_UPDATERUN,               updaterunMode);
    6972        MODECASE(FAKETOOL_MODE_PENDINGEXP,              pendingexpMode);
     
    7275        MODECASE(FAKETOOL_MODE_PROCESSEDIMFILE,         processedimfileMode);
    7376        MODECASE(FAKETOOL_MODE_REVERTPROCESSEDIMFILE,   revertprocessedimfileMode);
    74         MODECASE(FAKETOOL_MODE_UPDATEPROCESSEDIMFILE,updateprocessedimfileMode);
     77        MODECASE(FAKETOOL_MODE_UPDATEPROCESSEDIMFILE,   updateprocessedimfileMode);
    7578        MODECASE(FAKETOOL_MODE_BLOCK,                   blockMode);
    7679        MODECASE(FAKETOOL_MODE_MASKED,                  maskedMode);
    7780        MODECASE(FAKETOOL_MODE_UNMASKED,                unmaskedMode);
    7881        MODECASE(FAKETOOL_MODE_UNBLOCK,                 unblockMode);
     82        MODECASE(FAKETOOL_MODE_PENDINGCLEANUPRUN,       pendingcleanuprunMode);
     83        MODECASE(FAKETOOL_MODE_PENDINGCLEANUPIMFILE,    pendingcleanupimfileMode);
     84        MODECASE(FAKETOOL_MODE_DONECLEANUP,             donecleanupMode);
    7985        default:
    8086            psAbort("invalid option (this should not happen)");
     
    854860}
    855861
     862static bool pendingcleanuprunMode(pxConfig *config)
     863{
     864    PS_ASSERT_PTR_NON_NULL(config, NULL);
     865
     866    PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false);
     867    PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false);
     868
     869    psMetadata *where = psMetadataAlloc();
     870    PXOPT_COPY_STR(config->args, where, "-label", "label", "==");
     871
     872    psString query = pxDataGet("faketool_pendingcleanuprun.sql");
     873    if (!query) {
     874        psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement");
     875        return false;
     876    }
     877
     878    if (where && psListLength(where->list)) {
     879        psString whereClause = psDBGenerateWhereConditionSQL(where, NULL);
     880        psStringAppend(&query, " AND %s", whereClause);
     881        psFree(whereClause);
     882    }
     883    psFree(where);
     884
     885    // treat limit == 0 as "no limit"
     886    if (limit) {
     887        psString limitString = psDBGenerateLimitSQL(limit);
     888        psStringAppend(&query, " %s", limitString);
     889        psFree(limitString);
     890    }
     891
     892    if (!p_psDBRunQuery(config->dbh, query)) {
     893        psError(PS_ERR_UNKNOWN, false, "database error");
     894        psFree(query);
     895        return false;
     896    }
     897    psFree(query);
     898
     899    psArray *output = p_psDBFetchResult(config->dbh);
     900    if (!output) {
     901        psError(PS_ERR_UNKNOWN, false, "database error");
     902        return false;
     903    }
     904    if (!psArrayLength(output)) {
     905        psTrace("faketool", PS_LOG_INFO, "no rows found");
     906        psFree(output);
     907        return true;
     908    }
     909
     910    // negative simple so the default is true
     911    if (!ippdbPrintMetadatas(stdout, output, "fakePendingCleanupRun", !simple)) {
     912        psError(PS_ERR_UNKNOWN, false, "failed to print array");
     913        psFree(output);
     914        return false;
     915    }
     916
     917    psFree(output);
     918
     919    return true;
     920}
     921
     922
     923static bool pendingcleanupimfileMode(pxConfig *config)
     924{
     925    PS_ASSERT_PTR_NON_NULL(config, NULL);
     926
     927    PXOPT_LOOKUP_S64(fake_id, config->args, "-fake_id", false, false);
     928    PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false);
     929    PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false);
     930
     931    psMetadata *where = psMetadataAlloc();
     932    if (fake_id) {
     933        PXOPT_COPY_S64(config->args, where, "-fake_id", "fake_id", "==");
     934    }
     935    PXOPT_COPY_STR(config->args, where, "-label", "label", "==");
     936
     937    psString query = pxDataGet("faketool_pendingcleanupimfile.sql");
     938    if (!query) {
     939        psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement");
     940        return false;
     941    }
     942
     943    if (where && psListLength(where->list)) {
     944        psString whereClause = psDBGenerateWhereConditionSQL(where, NULL);
     945        psStringAppend(&query, " AND %s", whereClause);
     946        psFree(whereClause);
     947    }
     948    psFree(where);
     949
     950    // treat limit == 0 as "no limit"
     951    if (limit) {
     952        psString limitString = psDBGenerateLimitSQL(limit);
     953        psStringAppend(&query, " %s", limitString);
     954        psFree(limitString);
     955    }
     956
     957    if (!p_psDBRunQuery(config->dbh, query)) {
     958        psError(PS_ERR_UNKNOWN, false, "database error");
     959        psFree(query);
     960        return false;
     961    }
     962    psFree(query);
     963
     964    psArray *output = p_psDBFetchResult(config->dbh);
     965    if (!output) {
     966        psError(PS_ERR_UNKNOWN, false, "database error");
     967        return false;
     968    }
     969    if (!psArrayLength(output)) {
     970        psTrace("faketool", PS_LOG_INFO, "no rows found");
     971        psFree(output);
     972        return true;
     973    }
     974
     975    // negative simple so the default is true
     976    if (!ippdbPrintMetadatas(stdout, output, "fakePendingCleanupImfile", !simple)) {
     977        psError(PS_ERR_UNKNOWN, false, "failed to print array");
     978        psFree(output);
     979        return false;
     980    }
     981
     982    psFree(output);
     983
     984    return true;
     985}
     986
     987
     988static bool donecleanupMode(pxConfig *config)
     989{
     990    PS_ASSERT_PTR_NON_NULL(config, NULL);
     991
     992    PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false);
     993    PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false);
     994
     995    psMetadata *where = psMetadataAlloc();
     996    PXOPT_COPY_STR(config->args, where, "-label", "label", "==");
     997
     998    psString query = pxDataGet("faketool_donecleanup.sql");
     999    if (!query) {
     1000        psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement");
     1001        return false;
     1002    }
     1003
     1004    if (where && psListLength(where->list)) {
     1005        psString whereClause = psDBGenerateWhereConditionSQL(where, NULL);
     1006        psStringAppend(&query, " AND %s", whereClause);
     1007        psFree(whereClause);
     1008    }
     1009    psFree(where);
     1010
     1011    // treat limit == 0 as "no limit"
     1012    if (limit) {
     1013        psString limitString = psDBGenerateLimitSQL(limit);
     1014        psStringAppend(&query, " %s", limitString);
     1015        psFree(limitString);
     1016    }
     1017
     1018    if (!p_psDBRunQuery(config->dbh, query)) {
     1019        psError(PS_ERR_UNKNOWN, false, "database error");
     1020        psFree(query);
     1021        return false;
     1022    }
     1023    psFree(query);
     1024
     1025    psArray *output = p_psDBFetchResult(config->dbh);
     1026    if (!output) {
     1027        psError(PS_ERR_UNKNOWN, false, "database error");
     1028        return false;
     1029    }
     1030    if (!psArrayLength(output)) {
     1031        psTrace("faketool", PS_LOG_INFO, "no rows found");
     1032        psFree(output);
     1033        return true;
     1034    }
     1035
     1036    // negative simple so the default is true
     1037    if (!ippdbPrintMetadatas(stdout, output, "fakeDoneCleanup", !simple)) {
     1038        psError(PS_ERR_UNKNOWN, false, "failed to print array");
     1039        psFree(output);
     1040        return false;
     1041    }
     1042
     1043    psFree(output);
     1044
     1045    return true;
     1046}
    8561047
    8571048static bool fakeProcessedCompleteExp(pxConfig *config)
     
    8891080
    8901081        fakeRunRow *fakeRun = fakeRunObjectFromMetadata(row);
    891         // set fakeRun.state to 'stop'
    892         if (!pxfakeRunSetState(config, fakeRun->fake_id, "stop")) {
     1082        // set fakeRun.state to 'full'
     1083        if (!pxfakeRunSetState(config, fakeRun->fake_id, "full")) {
    8931084            psError(PS_ERR_UNKNOWN, false, "failed to change fakeRun.state for fake_id: %" PRId64, fakeRun->fake_id);
    8941085            psFree(fakeRun);
Note: See TracChangeset for help on using the changeset viewer.