IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jul 14, 2008, 5:31:55 PM (18 years ago)
Author:
Paul Price
Message:

Removing uri out of magictool -toprocess. Adding magictool -node to get the URIs. I'm worried that pantasks won't be able to handle the MULTI uri. This way, pantasks uses -toprocess, passes the name of the node to process on to a script, and the script can get the list of inputs with -node.

File:
1 edited

Legend:

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

    r18523 r18524  
    4040static bool toprocessMode(pxConfig *config);
    4141static bool addresultMode(pxConfig *config);
     42static bool nodeMode(pxConfig *config);
    4243static bool tomaskMode(pxConfig *config);
    4344static bool addmaskMode(pxConfig *config);
     
    7374        MODECASE(MAGICTOOL_MODE_TOPROCESS,      toprocessMode);
    7475        MODECASE(MAGICTOOL_MODE_ADDRESULT,      addresultMode);
     76        MODECASE(MAGICTOOL_MODE_NODE,           nodeMode);
    7577        MODECASE(MAGICTOOL_MODE_TOMASK,         tomaskMode);
    7678        MODECASE(MAGICTOOL_MODE_ADDMASK,        addmaskMode);
     
    393395    }
    394396    if (!psArrayLength(output)) {
    395         psTrace("warptool", PS_LOG_INFO, "no rows found");
     397        psTrace("magictool", PS_LOG_INFO, "no rows found");
    396398        psFree(output);
    397399        return true;
     
    520522        psMetadataRemoveKey(work, "dep");
    521523        psMetadataRemoveKey(work, "done");
     524#if 0
    522525        psMetadataRemoveKey(work, "uri");
     526#endif
    523527        pxNode *child = NULL;
    524528        while ((child = psListGetAndIncrement(iter))) {
     
    538542                return true;
    539543            }
    540 
     544#if 0
    541545            char *uri = psMetadataLookupStr(&status, data, "uri");
    542546            if (!status) {
     
    545549
    546550            psMetadataAddStr(work, PS_LIST_TAIL, "uri", PS_META_DUPLICATE_OK, NULL, uri);
    547 
     551#endif
    548552        }
    549553        psFree(iter);
     
    634638
    635639    psArray *magicTree = p_psDBFetchResult(config->dbh);
    636     if (!output) {
     640    if (!magicTree) {
    637641        psErrorCode err = psErrorCodeLast();
    638642        switch (err) {
     
    725729}
    726730
    727 
    728 static bool tomaskMode(pxConfig *config)
     731static bool nodeMode(pxConfig *config)
    729732{
    730733    PS_ASSERT_PTR_NON_NULL(config, false);
     
    733736    PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false);
    734737
    735     // look for "inputs" that need to processed
    736     psString query = pxDataGet("magictool_tomask.sql");
     738    psString query = pxDataGet("magictool_node.sql");
    737739    if (!query) {
    738740        psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement");
    739741        return false;
     742    }
     743
     744    if (config->where) {
     745        psString whereClause = psDBGenerateWhereConditionSQL(config->where, NULL);
     746        psStringAppend(&query, " AND %s", whereClause);
     747        psFree(whereClause);
    740748    }
    741749
     
    776784    if (psArrayLength(output)) {
    777785        // negative simple so the default is true
     786        if (!ippdbPrintMetadatas(stdout, output, "magicNode", !simple)) {
     787            psError(PS_ERR_UNKNOWN, false, "failed to print array");
     788            psFree(output);
     789            return false;
     790        }
     791    }
     792
     793    psFree(output);
     794
     795    return true;
     796}
     797
     798
     799static bool tomaskMode(pxConfig *config)
     800{
     801    PS_ASSERT_PTR_NON_NULL(config, false);
     802
     803    PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false);
     804    PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false);
     805
     806    // look for "inputs" that need to processed
     807    psString query = pxDataGet("magictool_tomask.sql");
     808    if (!query) {
     809        psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement");
     810        return false;
     811    }
     812
     813    // treat limit == 0 as "no limit"
     814    if (limit) {
     815        psString limitString = psDBGenerateLimitSQL(limit);
     816        psStringAppend(&query, " %s", limitString);
     817        psFree(limitString);
     818    }
     819
     820    if (!p_psDBRunQuery(config->dbh, query)) {
     821        psError(PS_ERR_UNKNOWN, false, "database error");
     822        psFree(query);
     823        return false;
     824    }
     825    psFree(query);
     826
     827    psArray *output = p_psDBFetchResult(config->dbh);
     828    if (!output) {
     829        psErrorCode err = psErrorCodeLast();
     830        switch (err) {
     831            case PS_ERR_DB_CLIENT:
     832                psError(PXTOOLS_ERR_SYS, false, "database error");
     833            case PS_ERR_DB_SERVER:
     834                psError(PXTOOLS_ERR_PROG, false, "database error");
     835            default:
     836                psError(PXTOOLS_ERR_PROG, false, "unknown error");
     837        }
     838
     839        return false;
     840    }
     841    if (!psArrayLength(output)) {
     842        psTrace("magictool", PS_LOG_INFO, "no rows found");
     843        psFree(output);
     844        return true;
     845    }
     846
     847    if (psArrayLength(output)) {
     848        // negative simple so the default is true
    778849        if (!ippdbPrintMetadatas(stdout, output, "toprocess", !simple)) {
    779850            psError(PS_ERR_UNKNOWN, false, "failed to print array");
Note: See TracChangeset for help on using the changeset viewer.