IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
May 17, 2010, 3:53:40 PM (16 years ago)
Author:
Paul Price
Message:

Adding magictool -exposure to get camProcessedExp.path_base from magic_id.

File:
1 edited

Legend:

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

    r27274 r27982  
    4848static bool maskMode(pxConfig *config);
    4949static bool censorrunMode(pxConfig *config);
     50static bool exposureMode(pxConfig *config);
    5051
    5152static bool setmagicRunState(pxConfig *config, psS64 magic_id, const char *state);
     
    8788        MODECASE(MAGICTOOL_MODE_MASK,                maskMode);
    8889        MODECASE(MAGICTOOL_MODE_CENSORRUN,           censorrunMode);
     90        MODECASE(MAGICTOOL_MODE_EXPOSURE,            exposureMode);
    8991        default:
    9092            psAbort("invalid option (this should not happen)");
     
    15141516    return true;
    15151517}
     1518
     1519
     1520static bool exposureMode(pxConfig *config)
     1521{
     1522    PS_ASSERT_PTR_NON_NULL(config, false);
     1523
     1524    psMetadata *where = psMetadataAlloc();
     1525    PXOPT_COPY_S64(config->args, where, "-magic_id", "magicRun.magic_id", "==");
     1526    PXOPT_COPY_BOOL(config->args, where, "-inverse", "magicRun.inverse", "==");
     1527
     1528    PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false);
     1529
     1530    psString query = pxDataGet("magictool_exposure.sql");
     1531    if (!query) {
     1532        psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement");
     1533        return false;
     1534    }
     1535
     1536    psString whereClause = psStringCopy(""); // WHERE restrictions
     1537    if (psListLength(where->list)) {
     1538        psString clause = psDBGenerateWhereConditionSQL(where, NULL);
     1539        psStringAppend(&whereClause, " AND %s", clause);
     1540        psFree(clause);
     1541    }
     1542    psFree(where);
     1543
     1544    if (!p_psDBRunQueryF(config->dbh, query, whereClause, whereClause)) {
     1545        psError(PS_ERR_UNKNOWN, false, "database error");
     1546        psFree(query);
     1547        return false;
     1548    }
     1549    psFree(query);
     1550
     1551    psArray *output = p_psDBFetchResult(config->dbh);
     1552    if (!output) {
     1553        psErrorCode err = psErrorCodeLast();
     1554        switch (err) {
     1555            case PS_ERR_DB_CLIENT:
     1556                psError(PXTOOLS_ERR_SYS, false, "database error");
     1557                break;
     1558            case PS_ERR_DB_SERVER:
     1559                psError(PXTOOLS_ERR_PROG, false, "database error");
     1560                break;
     1561            default:
     1562                psError(PXTOOLS_ERR_PROG, false, "unknown error");
     1563                break;
     1564        }
     1565        return false;
     1566    }
     1567    if (!psArrayLength(output)) {
     1568        psTrace("magictool", PS_LOG_INFO, "no rows found");
     1569        psFree(output);
     1570        return true;
     1571    }
     1572
     1573    if (!ippdbPrintMetadatas(stdout, output, "magicMask", !simple)) {
     1574        psError(PS_ERR_UNKNOWN, false, "failed to print array");
     1575        psFree(output);
     1576        return false;
     1577    }
     1578    psFree(output);
     1579
     1580    return true;
     1581}
Note: See TracChangeset for help on using the changeset viewer.