IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Aug 17, 2010, 11:12:06 AM (16 years ago)
Author:
bills
Message:

add two new modes to bgtool -listchip and -listwarp which give the path_base of the corresponding component.
This will be used by distribute the associated variance files

File:
1 edited

Legend:

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

    r28746 r28941  
    3939static bool advancechipMode(pxConfig *config);
    4040static bool revertchipMode(pxConfig *config);
     41static bool listchipMode(pxConfig *config);
    4142static bool definewarpMode(pxConfig *config);
    4243static bool updatewarpMode(pxConfig *config);
     
    4748static bool advancewarpMode(pxConfig *config);
    4849static bool revertwarpMode(pxConfig *config);
     50static bool listwarpMode(pxConfig *config);
    4951static bool tocleanchipMode(pxConfig *config);
    5052static bool cleanedchipMode(pxConfig *config);
     
    100102        MODECASE(BGTOOL_MODE_ADVANCECHIP, advancechipMode);
    101103        MODECASE(BGTOOL_MODE_REVERTCHIP,  revertchipMode);
     104        MODECASE(BGTOOL_MODE_LISTCHIP,    listchipMode);
    102105        MODECASE(BGTOOL_MODE_DEFINEWARP,  definewarpMode);
    103106        MODECASE(BGTOOL_MODE_UPDATEWARP,  updatewarpMode);
     
    108111        MODECASE(BGTOOL_MODE_ADVANCEWARP, advancewarpMode);
    109112        MODECASE(BGTOOL_MODE_REVERTWARP,  revertwarpMode);
     113        MODECASE(BGTOOL_MODE_LISTWARP,    listwarpMode);
    110114        MODECASE(BGTOOL_MODE_TOCLEANCHIP, tocleanchipMode);
    111115        MODECASE(BGTOOL_MODE_CLEANEDCHIP, cleanedchipMode);
     
    907911    int numDeleted = psDBAffectedRows(config->dbh);
    908912    psLogMsg("bgtool", PS_LOG_INFO, "Deleted %d chipBackgroundImfiles", numDeleted);
     913
     914    return true;
     915}
     916static bool listchipMode(pxConfig *config)
     917{
     918    PS_ASSERT_PTR_NON_NULL(config, false);
     919
     920    psMetadata *where = psMetadataAlloc();
     921    PXOPT_COPY_S64(config->args, where, "-chip_bg_id", "chipBackgroundRun.chip_bg_id", "==");
     922    PXOPT_COPY_STR(config->args, where, "-class_id", "chipProcessedImfile.class_id", "==");
     923
     924    // chip_bg_id is required
     925    PXOPT_LOOKUP_S64(chip_bg_id, config->args, "-chip_bg_id", true, false);
     926
     927    PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false);
     928    PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false);
     929
     930    psString query = pxDataGet("bgtool_listchip.sql");
     931    if (!query) {
     932        psError(psErrorCodeLast(), false, "failed to retreive SQL statement");
     933        return false;
     934    }
     935
     936    psString whereStr = psStringCopy("");
     937    psString whereClause = psDBGenerateWhereConditionSQL(where, NULL);
     938    psStringAppend(&query, "\nWHERE %s", whereClause);
     939    psFree(whereClause);
     940    psFree(where);
     941
     942    if (limit) {
     943        psString limitString = psDBGenerateLimitSQL(limit);
     944        psStringAppend(&query, " %s", limitString);
     945        psFree(limitString);
     946    }
     947
     948    if (!p_psDBRunQuery(config->dbh, query)) {
     949        psError(psErrorCodeLast(), false, "database error");
     950        psFree(query);
     951        return false;
     952    }
     953    psFree(whereStr);
     954    psFree(query);
     955
     956    psArray *output = p_psDBFetchResult(config->dbh);
     957    if (!output) {
     958        psError(psErrorCodeLast(), false, "Unable to fetch result of query %s", query);
     959        return false;
     960    }
     961    if (!psArrayLength(output)) {
     962        psTrace("bgtool", PS_LOG_INFO, "no rows found");
     963        psFree(output);
     964        return true;
     965    }
     966
     967    if (psArrayLength(output)) {
     968        if (!ippdbPrintMetadatas(stdout, output, "chipProcessedImfile", !simple)) {
     969            psError(psErrorCodeLast(), false, "failed to print array");
     970            psFree(output);
     971            return false;
     972        }
     973    }
     974
     975    psFree(output);
    909976
    910977    return true;
     
    16861753    return true;
    16871754}
     1755static bool listwarpMode(pxConfig *config)
     1756{
     1757    PS_ASSERT_PTR_NON_NULL(config, false);
     1758
     1759    psMetadata *where = psMetadataAlloc();
     1760    PXOPT_COPY_S64(config->args, where, "-warp_bg_id", "warpBackgroundRun.warp_bg_id", "==");
     1761    PXOPT_COPY_STR(config->args, where, "-skycell_id", "warpSkyfile.skycell_id", "==");
     1762
     1763    PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false);
     1764    PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false);
     1765
     1766    psString query = pxDataGet("bgtool_listwarp.sql");
     1767    if (!query) {
     1768        psError(psErrorCodeLast(), false, "failed to retreive SQL statement");
     1769        return false;
     1770    }
     1771
     1772    psString whereStr = psStringCopy("");
     1773    psString whereClause = psDBGenerateWhereConditionSQL(where, NULL);
     1774    psStringAppend(&query, "\nWHERE %s", whereClause);
     1775    psFree(whereClause);
     1776    psFree(where);
     1777
     1778    if (limit) {
     1779        psString limitString = psDBGenerateLimitSQL(limit);
     1780        psStringAppend(&query, " %s", limitString);
     1781        psFree(limitString);
     1782    }
     1783
     1784    if (!p_psDBRunQuery(config->dbh, query)) {
     1785        psError(psErrorCodeLast(), false, "database error");
     1786        psFree(query);
     1787        return false;
     1788    }
     1789    psFree(whereStr);
     1790    psFree(query);
     1791
     1792    psArray *output = p_psDBFetchResult(config->dbh);
     1793    if (!output) {
     1794        psError(psErrorCodeLast(), false, "Unable to fetch result of query %s", query);
     1795        return false;
     1796    }
     1797    if (!psArrayLength(output)) {
     1798        psTrace("bgtool", PS_LOG_INFO, "no rows found");
     1799        psFree(output);
     1800        return true;
     1801    }
     1802
     1803    if (psArrayLength(output)) {
     1804        if (!ippdbPrintMetadatas(stdout, output, "warpSkyfile", !simple)) {
     1805            psError(psErrorCodeLast(), false, "failed to print array");
     1806            psFree(output);
     1807            return false;
     1808        }
     1809    }
     1810
     1811    psFree(output);
     1812
     1813    return true;
     1814}
    16881815
    16891816static bool tocleanwarpMode(pxConfig *config)
Note: See TracChangeset for help on using the changeset viewer.