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_residexp.c

    r18641 r18643  
    343343    return true;
    344344}
     345
     346bool pendingcleanup_residexpMode(pxConfig *config)
     347{
     348    PS_ASSERT_PTR_NON_NULL(config, NULL);
     349
     350    PXOPT_LOOKUP_S64(chip_id, config->args, "-chip_id", false, false);
     351    PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false);
     352    PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false);
     353
     354    psMetadata *where = psMetadataAlloc();
     355    if (chip_id) {
     356        PXOPT_COPY_S64(config->args, where, "-chip_id", "chip_id", "==");
     357    }
     358    PXOPT_COPY_STR(config->args, where, "-label", "label", "==");
     359
     360    psString query = pxDataGet("dettool_pendingcleanup_residexp.sql");
     361    if (!query) {
     362        psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement");
     363        return false;
     364    }
     365
     366    if (where && psListLength(where->list)) {
     367        psString whereClause = psDBGenerateWhereConditionSQL(where, NULL);
     368        psStringAppend(&query, " AND %s", whereClause);
     369        psFree(whereClause);
     370    }
     371    psFree(where);
     372
     373    // treat limit == 0 as "no limit"
     374    if (limit) {
     375        psString limitString = psDBGenerateLimitSQL(limit);
     376        psStringAppend(&query, " %s", limitString);
     377        psFree(limitString);
     378    }
     379
     380    if (!p_psDBRunQuery(config->dbh, query)) {
     381        psError(PS_ERR_UNKNOWN, false, "database error");
     382        psFree(query);
     383        return false;
     384    }
     385    psFree(query);
     386
     387    psArray *output = p_psDBFetchResult(config->dbh);
     388    if (!output) {
     389        psError(PS_ERR_UNKNOWN, false, "database error");
     390        return false;
     391    }
     392    if (!psArrayLength(output)) {
     393        psTrace("dettool", PS_LOG_INFO, "no rows found");
     394        psFree(output);
     395        return true;
     396    }
     397
     398    // negative simple so the default is true
     399    if (!ippdbPrintMetadatas(stdout, output, "detPendingCleanup_residexp", !simple)) {
     400        psError(PS_ERR_UNKNOWN, false, "failed to print array");
     401        psFree(output);
     402        return false;
     403    }
     404
     405    psFree(output);
     406
     407    return true;
     408}
     409
     410
     411bool donecleanup_residexpMode(pxConfig *config)
     412{
     413    PS_ASSERT_PTR_NON_NULL(config, NULL);
     414
     415    PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false);
     416    PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false);
     417
     418    psMetadata *where = psMetadataAlloc();
     419    PXOPT_COPY_STR(config->args, where, "-label", "label", "==");
     420
     421    psString query = pxDataGet("dettool_donecleanup_residexp.sql");
     422    if (!query) {
     423        psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement");
     424        return false;
     425    }
     426
     427    if (where && psListLength(where->list)) {
     428        psString whereClause = psDBGenerateWhereConditionSQL(where, NULL);
     429        psStringAppend(&query, " AND %s", whereClause);
     430        psFree(whereClause);
     431    }
     432    psFree(where);
     433
     434    // treat limit == 0 as "no limit"
     435    if (limit) {
     436        psString limitString = psDBGenerateLimitSQL(limit);
     437        psStringAppend(&query, " %s", limitString);
     438        psFree(limitString);
     439    }
     440
     441    if (!p_psDBRunQuery(config->dbh, query)) {
     442        psError(PS_ERR_UNKNOWN, false, "database error");
     443        psFree(query);
     444        return false;
     445    }
     446    psFree(query);
     447
     448    psArray *output = p_psDBFetchResult(config->dbh);
     449    if (!output) {
     450        psError(PS_ERR_UNKNOWN, false, "database error");
     451        return false;
     452    }
     453    if (!psArrayLength(output)) {
     454        psTrace("dettool", PS_LOG_INFO, "no rows found");
     455        psFree(output);
     456        return true;
     457    }
     458
     459    // negative simple so the default is true
     460    if (!ippdbPrintMetadatas(stdout, output, "detDoneCleanup_residexp", !simple)) {
     461        psError(PS_ERR_UNKNOWN, false, "failed to print array");
     462        psFree(output);
     463        return false;
     464    }
     465
     466    psFree(output);
     467
     468    return true;
     469}
     470
Note: See TracChangeset for help on using the changeset viewer.