IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
May 3, 2010, 8:41:49 AM (16 years ago)
Author:
eugene
Message:

updates from trunk

Location:
branches/tap_branches
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/tap_branches

  • branches/tap_branches/ippTools/src

    • Property svn:ignore
      •  

        old new  
        1616difftool
        1717disttool
         18dqstatstool
        1819faketool
        1920flatcorr
  • branches/tap_branches/ippTools/src/addtool.c

    r25840 r27838  
    9898    pxcamGetSearchArgs (config, where);
    9999    PXOPT_COPY_S64(config->args, where,  "-cam_id",    "camRun.cam_id", "==");
    100     pxAddLabelSearchArgs (config, where, "-label",     "camRun.label", "==");
     100    pxAddLabelSearchArgs (config, where, "-label",     "camRun.label", "=="); // define using camRun label
     101    pxAddLabelSearchArgs (config, where, "-data_group","camRun.data_group", "=="); // define using camRun label
    101102    PXOPT_COPY_STR(config->args, where,  "-reduction", "camRun.reduction", "==");
    102103
    103     if (!psListLength(where->list) &&
    104         !psMetadataLookupBool(NULL, config->args, "-all")) {
     104    if (!psListLength(where->list)) {
    105105        psFree(where);
    106         psError(PXTOOLS_ERR_DATA, false, "search parameters are required");
     106        psError(PXTOOLS_ERR_CONFIG, false, "search parameters are required");
    107107        return false;
    108108    }
     
    115115    PXOPT_LOOKUP_STR(note,        config->args, "-set_note", false, false);
    116116    PXOPT_LOOKUP_BOOL(image_only, config->args, "-image_only", false);
     117    PXOPT_LOOKUP_BOOL(destreaked, config->args, "-destreaked", false);
    117118    PXOPT_LOOKUP_BOOL(pretend,    config->args, "-pretend", false);
    118119    PXOPT_LOOKUP_BOOL(simple,     config->args, "-simple", false);
    119120
    120121    // find the cam_id of all the exposures that we want to queue up.
    121     psString query = pxDataGet("addtool_find_cam_id.sql");
    122     if (!query) {
    123         psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement");
     122    psString bare_query = pxDataGet("addtool_find_cam_id.sql");
     123    if (!bare_query) {
     124        psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement");
    124125        psFree(where);
    125126        return false;
    126127    }
     128
     129    // prevent queueing an addRun if a given exposure has already been added to
     130    // the given dvo database
     131    psString dvodb_string = NULL;
     132    if (dvodb) {
     133        // user supplied dvodb
     134        psStringAppend(&dvodb_string, "(previous_dvodb = '%s')", dvodb);
     135    } else {
     136        // inherit dvodb from camRun, avoid matching NULL
     137        psStringAppend(&dvodb_string, "(camRun.dvodb IS NOT NULL AND previous_dvodb = camRun.dvodb)");
     138    }
     139    // Take the bare query and add the dvodb selector
     140    psString query = NULL;
     141    psStringAppend(&query, bare_query, dvodb_string);
     142    psFree(dvodb_string);
     143    psFree(bare_query);
    127144
    128145    // use psDBGenerateWhereConditionSQL because the SQL ends in a WHERE
     
    131148        psStringAppend(&query, " AND %s", whereClause);
    132149        psFree(whereClause);
     150    } else {
     151        psError(PS_ERR_UNKNOWN, true, "search parameters are required");
     152        return false;
    133153    }
    134154    psFree(where);
     155
     156    if (destreaked) {
     157        psStringAppend(&query, " AND (camRun.magicked > 0)");
     158    }
    135159
    136160    if (!p_psDBRunQuery(config->dbh, query)) {
     
    214238        // queue the exp
    215239        if (!pxaddQueueByCamID(config,
    216                                row->cam_id,
    217                                workdir     ? workdir   : row->workdir,
    218                                reduction   ? reduction : row->reduction,
    219                                label       ? label     : row->label,
    220                                data_group  ? data_group : (label ? label : row->label),
    221                                dvodb       ? dvodb     : row->dvodb,
     240                               row->cam_id,
     241                               workdir     ? workdir   : row->workdir,
     242                               reduction   ? reduction : row->reduction,
     243                               label       ? label     : row->label,
     244                               data_group  ? data_group : (row->data_group ? row->data_group :  (label ? label : row->label)),
     245                               dvodb       ? dvodb     : row->dvodb,
    222246                               note        ? note      : NULL,
    223                                image_only
     247                               image_only
    224248        )) {
    225249            if (!psDBRollback(config->dbh)) {
     
    256280    PXOPT_COPY_STR(config->args, where, "-state",     "addRun.state", "==");
    257281    PXOPT_COPY_STR(config->args, where, "-reduction", "addRun.reduction", "==");
     282    PXOPT_COPY_STR(config->args, where, "-dvodb", "addRun.dvodb", "==");
    258283
    259284    if (!psListLength(where->list)) {
    260285        psFree(where);
    261         psError(PXTOOLS_ERR_DATA, false, "search parameters are required");
     286        psError(PXTOOLS_ERR_CONFIG, false, "search parameters are required");
    262287        return false;
    263288    }
     
    266291
    267292    // pxUpdateRun gets parameters from config->args and runs the update query
    268     bool result = pxUpdateRun(config, where, &query, "addRun", false);
     293    bool result = pxUpdateRun(config, where, &query, "addRun", "add_id",
     294        "addProcessedExp", false);
    269295
    270296    psFree(query);
     
    272298
    273299    return result;
    274 
    275 
    276 #ifdef notdef
    277     PXOPT_LOOKUP_STR(state, config->args, "-set_state", false, false);
    278     PXOPT_LOOKUP_STR(label, config->args, "-set_label", false, false);
    279 
    280     if ((!state) && (!label)) {
    281         psError(PXTOOLS_ERR_DATA, false, "parameters are required");
    282         psFree(where);
    283         return false;
    284     }
    285 
    286     if (state) {
    287         // set addRun.state to state
    288         if (!pxaddRunSetStateByQuery(config, where, state)) {
    289             psFree(where);
    290             return false;
    291         }
    292     }
    293 
    294     if (label) {
    295         // set addRun.label to label
    296         if (!pxaddRunSetLabelByQuery(config, where, label)) {
    297             psFree(where);
    298             return false;
    299         }
    300     }
    301 
    302     psFree(where);
    303 
    304     return true;
    305 #endif
    306300}
    307301
     
    322316    psString query = pxDataGet("addtool_find_pendingexp.sql");
    323317    if (!query) {
    324         psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement");
     318        psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement");
    325319        return false;
    326320    }
     
    388382    psString query = pxDataGet("addtool_find_pendingexp.sql");
    389383    if (!query) {
    390         psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement");
     384        psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement");
    391385        return false;
    392386    }
     
    430424        dtime_addstar,
    431425        path_base,
    432         fault
     426        fault
    433427        );
    434428
     
    482476        !psMetadataLookupBool(NULL, config->args, "-all")) {
    483477        psFree(where);
    484         psError(PXTOOLS_ERR_DATA, false, "search parameters (or -all) are required");
     478        psError(PXTOOLS_ERR_CONFIG, false, "search parameters (or -all) are required");
    485479        return false;
    486480    }
     
    488482    psString query = pxDataGet("addtool_find_processedexp.sql");
    489483    if (!query) {
    490         psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement");
     484        psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement");
    491485        return false;
    492486    }
     
    496490        psStringAppend(&query, " WHERE %s", whereClause);
    497491        psFree(whereClause);
    498     } 
     492    }
    499493
    500494    // we either add AND (condition) or WHERE (condition):
     
    502496        // list only faulted rows
    503497        psStringAppend(&query, " %s", " AND addProcessedExp.fault != 0");
    504     } 
     498    }
    505499    if (where->list && !faulted) {
    506500        // don't list faulted rows
     
    510504        // list only faulted rows
    511505        psStringAppend(&query, " %s", " WHERE addProcessedExp.fault != 0");
    512     } 
     506    }
    513507    if (!where->list && !faulted) {
    514508        // don't list faulted rows
     
    571565    if (!psListLength(where->list) && !psMetadataLookupBool(NULL, config->args, "-all")) {
    572566        psFree(where);
    573         psError(PXTOOLS_ERR_DATA, false, "search parameters are required");
     567        psError(PXTOOLS_ERR_CONFIG, false, "search parameters are required");
    574568        return false;
    575569    }
     
    584578        psString query = pxDataGet("addtool_reset_faulted_runs.sql");
    585579        if (!query) {
    586             psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement");
     580            psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement");
    587581            psFree(where);
    588582            return false;
     
    616610                psError(PS_ERR_UNKNOWN, false, "database error");
    617611            }
    618             psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement");
     612            psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement");
    619613            psFree(where);
    620614            return false;
Note: See TracChangeset for help on using the changeset viewer.