IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jul 21, 2008, 12:12:59 PM (18 years ago)
Author:
eugene
Message:

adding cleanup mode functions (but not yet sql or cmd-line options); dropping guidetool

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branch_20080719/ippTools/src/dettool_processedimfile.c

    r18641 r18643  
    293293    return true;
    294294}
     295
     296bool pendingcleanup_processedimfileMode(pxConfig *config)
     297{
     298    PS_ASSERT_PTR_NON_NULL(config, NULL);
     299
     300    PXOPT_LOOKUP_S64(chip_id, config->args, "-chip_id", false, false);
     301    PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false);
     302    PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false);
     303
     304    psMetadata *where = psMetadataAlloc();
     305    if (chip_id) {
     306        PXOPT_COPY_S64(config->args, where, "-chip_id", "chip_id", "==");
     307    }
     308    PXOPT_COPY_STR(config->args, where, "-label", "label", "==");
     309
     310    psString query = pxDataGet("dettool_pendingcleanup_processedimfile.sql");
     311    if (!query) {
     312        psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement");
     313        return false;
     314    }
     315
     316    if (where && psListLength(where->list)) {
     317        psString whereClause = psDBGenerateWhereConditionSQL(where, NULL);
     318        psStringAppend(&query, " AND %s", whereClause);
     319        psFree(whereClause);
     320    }
     321    psFree(where);
     322
     323    // treat limit == 0 as "no limit"
     324    if (limit) {
     325        psString limitString = psDBGenerateLimitSQL(limit);
     326        psStringAppend(&query, " %s", limitString);
     327        psFree(limitString);
     328    }
     329
     330    if (!p_psDBRunQuery(config->dbh, query)) {
     331        psError(PS_ERR_UNKNOWN, false, "database error");
     332        psFree(query);
     333        return false;
     334    }
     335    psFree(query);
     336
     337    psArray *output = p_psDBFetchResult(config->dbh);
     338    if (!output) {
     339        psError(PS_ERR_UNKNOWN, false, "database error");
     340        return false;
     341    }
     342    if (!psArrayLength(output)) {
     343        psTrace("dettool", PS_LOG_INFO, "no rows found");
     344        psFree(output);
     345        return true;
     346    }
     347
     348    // negative simple so the default is true
     349    if (!ippdbPrintMetadatas(stdout, output, "detPendingCleanup_processedimfile", !simple)) {
     350        psError(PS_ERR_UNKNOWN, false, "failed to print array");
     351        psFree(output);
     352        return false;
     353    }
     354
     355    psFree(output);
     356
     357    return true;
     358}
     359
     360
     361bool donecleanup_processedimfileMode(pxConfig *config)
     362{
     363    PS_ASSERT_PTR_NON_NULL(config, NULL);
     364
     365    PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false);
     366    PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false);
     367
     368    psMetadata *where = psMetadataAlloc();
     369    PXOPT_COPY_STR(config->args, where, "-label", "label", "==");
     370
     371    psString query = pxDataGet("dettool_donecleanup_processedimfile.sql");
     372    if (!query) {
     373        psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement");
     374        return false;
     375    }
     376
     377    if (where && psListLength(where->list)) {
     378        psString whereClause = psDBGenerateWhereConditionSQL(where, NULL);
     379        psStringAppend(&query, " AND %s", whereClause);
     380        psFree(whereClause);
     381    }
     382    psFree(where);
     383
     384    // treat limit == 0 as "no limit"
     385    if (limit) {
     386        psString limitString = psDBGenerateLimitSQL(limit);
     387        psStringAppend(&query, " %s", limitString);
     388        psFree(limitString);
     389    }
     390
     391    if (!p_psDBRunQuery(config->dbh, query)) {
     392        psError(PS_ERR_UNKNOWN, false, "database error");
     393        psFree(query);
     394        return false;
     395    }
     396    psFree(query);
     397
     398    psArray *output = p_psDBFetchResult(config->dbh);
     399    if (!output) {
     400        psError(PS_ERR_UNKNOWN, false, "database error");
     401        return false;
     402    }
     403    if (!psArrayLength(output)) {
     404        psTrace("dettool", PS_LOG_INFO, "no rows found");
     405        psFree(output);
     406        return true;
     407    }
     408
     409    // negative simple so the default is true
     410    if (!ippdbPrintMetadatas(stdout, output, "detDoneCleanup_processedimfile", !simple)) {
     411        psError(PS_ERR_UNKNOWN, false, "failed to print array");
     412        psFree(output);
     413        return false;
     414    }
     415
     416    psFree(output);
     417
     418    return true;
     419}
     420
Note: See TracChangeset for help on using the changeset viewer.