IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Sep 23, 2009, 1:41:56 PM (17 years ago)
Author:
Paul Price
Message:

Adding 'difftool -advance' mode, with accompanying pantasks task definition.

File:
1 edited

Legend:

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

    r25074 r25509  
    3737static bool todiffskyfileMode(pxConfig *config);
    3838static bool adddiffskyfileMode(pxConfig *config);
     39static bool advanceMode(pxConfig *config);
    3940static bool diffskyfileMode(pxConfig *config);
    4041static bool revertdiffskyfileMode(pxConfig *config);
     
    5051
    5152static bool setdiffRunState(pxConfig *config, psS64 diff_id, const char *state, psS64 magicked);
    52 static bool diffRunComplete(pxConfig *config);
    5353
    5454# define MODECASE(caseName, func) \
     
    7676        MODECASE(DIFFTOOL_MODE_TODIFFSKYFILE,         todiffskyfileMode);
    7777        MODECASE(DIFFTOOL_MODE_ADDDIFFSKYFILE,        adddiffskyfileMode);
     78        MODECASE(DIFFTOOL_MODE_ADVANCE,               advanceMode);
    7879        MODECASE(DIFFTOOL_MODE_DIFFSKYFILE,           diffskyfileMode);
    7980        MODECASE(DIFFTOOL_MODE_REVERTDIFFSKYFILE,     revertdiffskyfileMode);
    8081        MODECASE(DIFFTOOL_MODE_DEFINEPOPRUN,          definepoprunMode);
    81         MODECASE(DIFFTOOL_MODE_DEFINEWARPSTACK,         definewarpstackMode);
     82        MODECASE(DIFFTOOL_MODE_DEFINEWARPSTACK,       definewarpstackMode);
    8283        MODECASE(DIFFTOOL_MODE_DEFINEWARPWARP,        definewarpwarpMode);
    8384        MODECASE(DIFFTOOL_MODE_PENDINGCLEANUPRUN,     pendingcleanuprunMode);
     
    555556    }
    556557
    557     if (!diffRunComplete(config)) {
    558         if (!psDBRollback(config->dbh)) {
    559             psError(PS_ERR_UNKNOWN, false, "database error");
    560         }
    561         psError(PS_ERR_UNKNOWN, false, "database error");
    562         return false;
    563     }
    564 
    565558    // point of no return
    566559    if (!psDBCommit(config->dbh)) {
     
    569562    }
    570563
     564
     565    return true;
     566}
     567
     568static bool advanceMode(pxConfig *config)
     569{
     570    PS_ASSERT_PTR_NON_NULL(config, false);
     571
     572    psMetadata *where = psMetadataAlloc();
     573    PXOPT_COPY_S64(config->args, where,  "-diff_id", "diffRun.diff_id", "==");
     574    PXOPT_COPY_STR(config->args, where, "-label", "diffRun.label", "==");
     575
     576    PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false);
     577
     578    // look for completed diffRuns
     579    psString query = pxDataGet("difftool_completed_runs.sql");
     580    if (!query) {
     581        psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement");
     582        return false;
     583    }
     584
     585    if (psListLength(where->list)) {
     586        psString whereClause = psDBGenerateWhereConditionSQL(where, NULL);
     587        psStringAppend(&query, " WHERE %s", whereClause);
     588        psFree(whereClause);
     589    }
     590    psFree(where);
     591
     592    // treat limit == 0 as "no limit"
     593    if (limit) {
     594        psString limitString = psDBGenerateLimitSQL(limit);
     595        psStringAppend(&query, " %s", limitString);
     596        psFree(limitString);
     597    }
     598
     599    if (!psDBTransaction(config->dbh)) {
     600        psError(PS_ERR_UNKNOWN, false, "database error");
     601        return false;
     602    }
     603
     604    if (!p_psDBRunQuery(config->dbh, query)) {
     605        psError(PS_ERR_UNKNOWN, false, "database error");
     606        psFree(query);
     607        if (!psDBRollback(config->dbh)) {
     608            psError(PS_ERR_UNKNOWN, false, "database error");
     609        }
     610        return false;
     611    }
     612    psFree(query);
     613
     614    psArray *output = p_psDBFetchResult(config->dbh);
     615    if (!output) {
     616        psError(PS_ERR_UNKNOWN, false, "database error");
     617        if (!psDBRollback(config->dbh)) {
     618            psError(PS_ERR_UNKNOWN, false, "database error");
     619        }
     620        return false;
     621    }
     622    if (!psArrayLength(output)) {
     623        psTrace("difftool", PS_LOG_INFO, "no rows found");
     624        psFree(output);
     625        return true;
     626    }
     627
     628    for (long i = 0; i < psArrayLength(output); i++) {
     629        psMetadata *row = output->data[i];
     630
     631        psS64 diff_id = psMetadataLookupS64(NULL, row, "diff_id");
     632        psS64 magicked = psMetadataLookupS64(NULL, row, "magicked");
     633
     634        // set diffRun.state to 'full'
     635        if (!setdiffRunState(config, diff_id, "full", magicked)) {
     636            psError(PS_ERR_UNKNOWN, false, "failed to change diffRun.state for diff_id: %" PRId64,
     637                diff_id);
     638            psFree(output);
     639            if (!psDBRollback(config->dbh)) {
     640                psError(PS_ERR_UNKNOWN, false, "database error");
     641            }
     642            return false;
     643        }
     644    }
     645    psFree(output);
     646
     647    if (!psDBCommit(config->dbh)) {
     648        psError(PS_ERR_UNKNOWN, false, "database error");
     649        return false;
     650    }
    571651
    572652    return true;
     
    18101890}
    18111891
    1812 static bool diffRunComplete(pxConfig *config)
    1813 {
    1814     PS_ASSERT_PTR_NON_NULL(config, false);
    1815 
    1816     // look for completed diffRuns
    1817     psString query = pxDataGet("difftool_completed_runs.sql");
    1818     if (!query) {
    1819         psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement");
    1820         return false;
    1821     }
    1822 
    1823     if (!p_psDBRunQuery(config->dbh, query)) {
    1824         psError(PS_ERR_UNKNOWN, false, "database error");
    1825         psFree(query);
    1826         return false;
    1827     }
    1828     psFree(query);
    1829 
    1830     psArray *output = p_psDBFetchResult(config->dbh);
    1831     if (!output) {
    1832         psError(PS_ERR_UNKNOWN, false, "database error");
    1833         return false;
    1834     }
    1835     if (!psArrayLength(output)) {
    1836         psTrace("difftool", PS_LOG_INFO, "no rows found");
    1837         psFree(output);
    1838         return true;
    1839     }
    1840     for (long i = 0; i < psArrayLength(output); i++) {
    1841         psMetadata *row = output->data[i];
    1842 
    1843         psS64 diff_id = psMetadataLookupS64(NULL, row, "diff_id");
    1844         psS64 magicked = psMetadataLookupS64(NULL, row, "magicked");
    1845 
    1846         // set diffRun.state to 'stop'
    1847         if (!setdiffRunState(config, diff_id, "full", magicked)) {
    1848             psError(PS_ERR_UNKNOWN, false, "failed to change diffRun.state for diff_id: %" PRId64,
    1849                 diff_id);
    1850             psFree(output);
    1851             return false;
    1852         }
    1853     }
    1854 
    1855     return true;
    1856 }
    18571892
    18581893bool exportrunMode(pxConfig *config)
Note: See TracChangeset for help on using the changeset viewer.