IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Feb 17, 2010, 4:40:03 PM (16 years ago)
Author:
Paul Price
Message:

Reworked all ippTools to put fault=2 (SYS_ERROR) when can't find SQL file (presumably due to NFS problems). Removed DATA_ERROR because ippTools don't work on data (astronomical images or catalogues). This should allow us to turn on revert for fault=2 only.

File:
1 edited

Legend:

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

    r23998 r26981  
    135135    psString query = pxDataGet("detselect_search.sql");
    136136    if (!query) {
    137         psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement");
    138         return false;
    139     }
    140 
    141     // use psDBGenerateWhereConditionalSQL with AND ... because the SQL ends in a WHERE
    142     if (where && psListLength(where->list)) {
    143         psString whereClause = psDBGenerateWhereConditionSQL(where, NULL);
    144         psStringAppend(&query, " AND %s", whereClause);
    145         psFree(whereClause);
    146     }
    147     psFree(where);
    148 
    149     // we choose the single detrend image which matches all criteria and has
    150     // the latest insertion date
    151 
    152     // unless explicitly specified by the user, list all possible matches
    153     if (!unlimit) {
    154         psStringAppend(&query, " ORDER BY registered DESC LIMIT 1");
    155     }
    156 
    157     if (!p_psDBRunQuery(config->dbh, query)) {
    158         psError(PS_ERR_UNKNOWN, false, "database error");
    159         psFree(query);
    160         return false;
    161     }
    162     psFree(query);
    163 
    164     psArray *output = p_psDBFetchResult(config->dbh);
    165     if (!output) {
    166         psError(PS_ERR_UNKNOWN, false, "database error");
    167         return false;
    168     }
    169     if (!psArrayLength(output)) {
    170         // XXX check psError here
    171         psError(PS_ERR_UNKNOWN, false, "no detrend exposures found");
    172         psFree(output);
    173         return true;
    174     }
    175 
    176     // negate simple so the default is true
    177     if (!ippdbPrintMetadatas(stdout, output, "detExp", !simple)) {
    178         psError(PS_ERR_UNKNOWN, false, "failed to print array");
    179         psFree(output);
    180         return false;
    181     }
    182 
    183     psFree(output);
    184 
    185     return true;
    186 }
    187 
    188 static bool selectMode(pxConfig *config)
    189 {
    190     PS_ASSERT_PTR_NON_NULL(config, false);
    191 
    192     PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false);
    193 
    194     psMetadata *where = psMetadataAlloc();
    195     PXOPT_COPY_STR(config->args, where, "-det_id",    "det_id", "==");
    196     PXOPT_COPY_S32(config->args, where, "-iteration", "iteration", "==");
    197     PXOPT_COPY_STR(config->args, where, "-class_id",  "class_id", "==");
    198 
    199     psString query = pxDataGet("detselect_select.sql");
    200     if (!query) {
    201         psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement");
     137        psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement");
    202138        return false;
    203139    }
     
    211147    psFree(where);
    212148
     149    // we choose the single detrend image which matches all criteria and has
     150    // the latest insertion date
     151
     152    // unless explicitly specified by the user, list all possible matches
     153    if (!unlimit) {
     154        psStringAppend(&query, " ORDER BY registered DESC LIMIT 1");
     155    }
     156
     157    if (!p_psDBRunQuery(config->dbh, query)) {
     158        psError(PS_ERR_UNKNOWN, false, "database error");
     159        psFree(query);
     160        return false;
     161    }
     162    psFree(query);
     163
     164    psArray *output = p_psDBFetchResult(config->dbh);
     165    if (!output) {
     166        psError(PS_ERR_UNKNOWN, false, "database error");
     167        return false;
     168    }
     169    if (!psArrayLength(output)) {
     170        // XXX check psError here
     171        psError(PS_ERR_UNKNOWN, false, "no detrend exposures found");
     172        psFree(output);
     173        return true;
     174    }
     175
     176    // negate simple so the default is true
     177    if (!ippdbPrintMetadatas(stdout, output, "detExp", !simple)) {
     178        psError(PS_ERR_UNKNOWN, false, "failed to print array");
     179        psFree(output);
     180        return false;
     181    }
     182
     183    psFree(output);
     184
     185    return true;
     186}
     187
     188static bool selectMode(pxConfig *config)
     189{
     190    PS_ASSERT_PTR_NON_NULL(config, false);
     191
     192    PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false);
     193
     194    psMetadata *where = psMetadataAlloc();
     195    PXOPT_COPY_STR(config->args, where, "-det_id",    "det_id", "==");
     196    PXOPT_COPY_S32(config->args, where, "-iteration", "iteration", "==");
     197    PXOPT_COPY_STR(config->args, where, "-class_id",  "class_id", "==");
     198
     199    psString query = pxDataGet("detselect_select.sql");
     200    if (!query) {
     201        psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement");
     202        return false;
     203    }
     204
     205    // use psDBGenerateWhereConditionalSQL with AND ... because the SQL ends in a WHERE
     206    if (where && psListLength(where->list)) {
     207        psString whereClause = psDBGenerateWhereConditionSQL(where, NULL);
     208        psStringAppend(&query, " AND %s", whereClause);
     209        psFree(whereClause);
     210    }
     211    psFree(where);
     212
    213213    if (!p_psDBRunQuery(config->dbh, query)) {
    214214        psError(PS_ERR_UNKNOWN, false, "database error");
Note: See TracChangeset for help on using the changeset viewer.