IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 15340


Ignore:
Timestamp:
Oct 19, 2007, 3:23:46 PM (19 years ago)
Author:
jhoblitt
Message:

implement -tomask

Location:
trunk/ippTools
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/ippTools/scripts/magictest.sh

    r15337 r15340  
    1010magictool -addinputskyfile -magic_id 1 -diff_id 2 -node b || exit 1
    1111magictool -inputtree -magic_id 1 -dep_file magic_dep.md
     12magictool -addresult -magic_id 1 -node a -uri file:///foo/a
     13magictool -addresult -magic_id 1 -node b -uri file:///foo/b
     14magictool -addresult -magic_id 1 -node root -uri file:///foo/root
    1215
    1316magictool -updaterun -state run -magic_id 1 || exit 1
  • trunk/ippTools/share/magictool_tomask.sql

    r15338 r15340  
    11SELECT
    22    magic_id
    3 FROM magicTree
     3FROM magicRun
     4JOIN magicTree
     5    USING(magic_id)
    46LEFT JOIN magicNodeResult
    57    USING(magic_id, node)
     8WHERE
     9    magicRun.state = 'run'
    610GROUP BY
    711    magic_id
  • trunk/ippTools/src/magictool.c

    r15339 r15340  
    572572{
    573573    PS_ASSERT_PTR_NON_NULL(config, false);
     574
     575    bool status = false;
     576    psU64 limit = psMetadataLookupU64(&status, config->args, "-limit");
     577    if (!status) {
     578        psError(PXTOOLS_ERR_PROG, false, "failed to lookup value for -limit");
     579        return false;
     580    }
     581
     582    // look for "inputs" that need to processed
     583    psString query = pxDataGet("magictool_tomask.sql");
     584    if (!query) {
     585        psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement");
     586        return false;
     587    }
     588
     589    // treat limit == 0 as "no limit"
     590    if (limit) {
     591        psString limitString = psDBGenerateLimitSQL(limit);
     592        psStringAppend(&query, " %s", limitString);
     593        psFree(limitString);
     594    }
     595
     596    if (!p_psDBRunQuery(config->dbh, query)) {
     597        psError(PS_ERR_UNKNOWN, false, "database error");
     598        psFree(query);
     599        return false;
     600    }
     601    psFree(query);
     602
     603    psArray *output = p_psDBFetchResult(config->dbh);
     604    if (!output) {
     605        psErrorCode err = psErrorCodeLast();
     606        switch (err) {
     607            case PS_ERR_DB_CLIENT:
     608                psError(PXTOOLS_ERR_SYS, false, "database error");
     609            case PS_ERR_DB_SERVER:
     610                psError(PXTOOLS_ERR_PROG, false, "database error");
     611            default:
     612                psError(PXTOOLS_ERR_PROG, false, "unknown error");
     613        }
     614
     615        return false;
     616    }
     617    if (!psArrayLength(output)) {
     618        psTrace("magictool", PS_LOG_INFO, "no rows found");
     619        psFree(output);
     620        return true;
     621    }
     622
     623    bool simple = false;
     624    {
     625        bool status = false;
     626        simple = psMetadataLookupBool(&status, config->args, "-simple");
     627        if (!status) {
     628            psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -simple");
     629            return false;
     630        }
     631    }
     632
     633    if (psArrayLength(output)) {
     634        if (!convertIdToStr(output)) {
     635            psError(PS_ERR_UNKNOWN, false, "failed to convert id fields into a strings");
     636            psFree(output);
     637            return false;
     638        }
     639
     640        // negative simple so the default is true
     641        if (!ippdbPrintMetadatas(stdout, output, "toprocess", !simple)) {
     642            psError(PS_ERR_UNKNOWN, false, "failed to print array");
     643            psFree(output);
     644            return false;
     645        }
     646    }
     647
     648    psFree(output);
     649
    574650    return true;
    575651}
  • trunk/ippTools/src/magictoolConfig.c

    r14537 r15340  
    111111    // -tomask
    112112    psMetadata *tomaskArgs = psMetadataAlloc();
    113     psMetadataAddStr(tomaskArgs, PS_LIST_TAIL, "-magic_id", 0,
    114             "search by magic ID", NULL);
    115113    psMetadataAddU64(tomaskArgs, PS_LIST_TAIL, "-limit",  0,
    116114            "limit result set to N items", 0);
Note: See TracChangeset for help on using the changeset viewer.