IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 23873 for trunk/ippTools/src


Ignore:
Timestamp:
Apr 15, 2009, 9:33:58 AM (17 years ago)
Author:
bills
Message:

add -clean argument to the exportrun modes. If set switch
state and data state from 'full' to 'cleaned'.
If no rows are found in -exportrun return error status for
the command

Location:
trunk/ippTools/src
Files:
14 edited

Legend:

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

    r23830 r23873  
    109109    psMetadata *where = psMetadataAlloc();
    110110    pxcamGetSearchArgs (config, where);
    111     PXOPT_COPY_STR(config->args, where, "-label",     "chipRun.label",     "==");
    112     PXOPT_COPY_STR(config->args, where, "-reduction", "chipRun.reduction", "==");
     111    PXOPT_COPY_STR(config->args, where, "-label",     "camRun.label",     "==");
     112    PXOPT_COPY_STR(config->args, where, "-reduction", "camRun.reduction", "==");
    113113
    114114    if (!psListLength(where->list) &&
     
    196196    }
    197197
    198     // loop over our list of chipRun rows
     198    // loop over our list of camRun rows
    199199    for (long i = 0; i < psArrayLength(output); i++) {
    200200        psMetadata *md = output->data[i];
    201201
    202         chipRunRow *row = chipRunObjectFromMetadata(md);
     202        camRunRow *row = camRunObjectFromMetadata(md);
    203203        if (!row) {
    204             psError(PS_ERR_UNKNOWN, false, "failed to convert metadata into chipRun");
     204            psError(PS_ERR_UNKNOWN, false, "failed to convert metadata into camRun");
    205205            psFree(output);
    206206            return false;
     
    268268
    269269    if (state) {
    270         // set chipRun.state to state
     270        // set camRun.state to state
    271271        if (!pxcamRunSetStateByQuery(config, where, state)) {
    272272            psFree(where);
     
    276276
    277277    if (label) {
    278         // set chipRun.label to label
     278        // set camRun.label to label
    279279        if (!pxcamRunSetLabelByQuery(config, where, label)) {
    280280            psFree(where);
     
    362362    PXOPT_COPY_STR(config->args, where, "-label",     "camRun.label",                 "==");
    363363    PXOPT_COPY_STR(config->args, where, "-reduction", "camRun.reduction",             "==");
    364     PXOPT_COPY_S64(config->args, where, "-chip_id",   "chipRun.chip_id",              "==");
    365     PXOPT_COPY_STR(config->args, where, "-class_id",  "chipProcessedImfile.class_id", "==");
     364    PXOPT_COPY_S64(config->args, where, "-chip_id",   "camRun.chip_id",              "==");
     365    PXOPT_COPY_STR(config->args, where, "-class_id",  "camProcessedExp.class_id", "==");
    366366
    367367    PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false);
     
    400400
    401401    // negate simple so the default is true
    402     if (!ippdbPrintMetadatas(stdout, output, "chipProcessedImfile", !simple)) {
     402    if (!ippdbPrintMetadatas(stdout, output, "camProcessedExp", !simple)) {
    403403        psError(PS_ERR_UNKNOWN, false, "failed to print array");
    404404        psFree(output);
     
    11451145  PXOPT_LOOKUP_STR(outfile, config->args, "-outfile", true,  false);
    11461146  PXOPT_LOOKUP_U64(limit,   config->args, "-limit",   false, false);
     1147  PXOPT_LOOKUP_BOOL(clean, config->args, "-clean", false);
    11471148
    11481149  FILE *f = fopen (outfile, "w");
     
    11931194    }
    11941195    if (!psArrayLength(output)) {
    1195       psTrace("regtool", PS_LOG_INFO, "no rows found");
     1196      psError(PS_ERR_UNKNOWN, true, "no rows found");
    11961197      psFree(output);
    1197       return true;
     1198      return false;
     1199    }
     1200
     1201    if (clean) {
     1202        if (!strcmp(tables[i].tableName, "camRun")) {
     1203            if (!pxSetStateCleaned("camRun", "state", output)) {
     1204                psFree(output);
     1205                psError(PS_ERR_UNKNOWN, false, "pxSetStateClean failed for table %s",  tables[i].tableName);
     1206                return false;
     1207            }
     1208        }
    11981209    }
    11991210
  • trunk/ippTools/src/camtoolConfig.c

    r23688 r23873  
    242242    psMetadataAddStr(exportrunArgs, PS_LIST_TAIL, "-outfile", 0,          "export to this file (required)", NULL);
    243243    psMetadataAddU64(exportrunArgs, PS_LIST_TAIL, "-limit",   0,          "limit result set to N items", 0);
     244    psMetadataAddBool(exportrunArgs, PS_LIST_TAIL, "-clean",  0,          "export tables as cleaned", false);
    244245
    245246    // -importrun
  • trunk/ippTools/src/chiptool.c

    r23870 r23873  
    13081308  PS_ASSERT_PTR_NON_NULL(config, NULL);
    13091309
    1310   PXOPT_LOOKUP_S64(det_id, config->args, "-chip_id", true,  false);
     1310  PXOPT_LOOKUP_S64(dummy, config->args, "-chip_id", true,  false);
    13111311  PXOPT_LOOKUP_STR(outfile, config->args, "-outfile", true,  false);
    13121312  PXOPT_LOOKUP_U64(limit,   config->args, "-limit",   false, false);
     1313  PXOPT_LOOKUP_BOOL(clean, config->args, "-clean", false);
     1314
    13131315
    13141316  FILE *f = fopen (outfile, "w");
     
    13611363    }
    13621364    if (!psArrayLength(output)) {
    1363       psTrace("regtool", PS_LOG_INFO, "no rows found");
     1365      psTrace("chiptool", PS_LOG_INFO, "no rows found");
    13641366      psFree(output);
    1365       return true;
     1367      return false;
     1368    }
     1369
     1370    if (clean) {
     1371        bool success = true;
     1372        if (!strcmp(tables[i].tableName, "chipRun")) {
     1373            success = pxSetStateCleaned("chipRun", "state", output);
     1374        } else if (!strcmp(tables[i].tableName, "chipProcessedImfile")) {
     1375            success = pxSetStateCleaned("chipProcessedImfile", "data_state", output);
     1376        }
     1377        if (!success) {
     1378            psFree(output);
     1379            psError(PS_ERR_UNKNOWN, false, "pxSetStateClean failed for table %s",  tables[i].tableName);
     1380            return false;
     1381        }
    13661382    }
    13671383
     
    14291445    return true;
    14301446}
    1431 
    1432 
  • trunk/ippTools/src/chiptoolConfig.c

    r23688 r23873  
    253253    psMetadataAddS64(exportrunArgs, PS_LIST_TAIL, "-chip_id", 0,          "export this chip ID (required)", 0);
    254254    psMetadataAddStr(exportrunArgs, PS_LIST_TAIL, "-outfile", 0,          "export to this file (required)", NULL);
     255    psMetadataAddBool(exportrunArgs, PS_LIST_TAIL, "-clean",  0,          "mark tables as cleaned", false);
    255256    psMetadataAddU64(exportrunArgs, PS_LIST_TAIL, "-limit",   0,          "limit result set to N items", 0);
    256257
  • trunk/ippTools/src/difftool.c

    r23740 r23873  
    17481748  PXOPT_LOOKUP_STR(outfile, config->args, "-outfile", true,  false);
    17491749  PXOPT_LOOKUP_U64(limit,   config->args, "-limit",   false, false);
     1750  PXOPT_LOOKUP_BOOL(clean, config->args, "-clean", false);
    17501751
    17511752  FILE *f = fopen (outfile, "w");
     
    17931794    psArray *output = p_psDBFetchResult(config->dbh);
    17941795    if (!output) {
    1795       psError(PS_ERR_UNKNOWN, false, "database error");
    17961796      return false;
    17971797    }
    17981798    if (!psArrayLength(output)) {
    1799       psTrace("regtool", PS_LOG_INFO, "no rows found");
     1799      psError(PS_ERR_UNKNOWN, true, "no rows found");
    18001800      psFree(output);
    1801       return true;
     1801      return false;
     1802    }
     1803
     1804    if (clean) {
     1805        bool success = true;
     1806        if (!strcmp(tables[i].tableName, "diffRun")) {
     1807            success = pxSetStateCleaned("diffRun", "state", output);
     1808#ifdef notyet
     1809        // diffSkyfile doesn't have dataState yet
     1810        } else if (!strcmp(tables[i].tableName, "diffSkyfile")) {
     1811            success = pxSetStateCleaned("diffSkyfile", "data_state", output);
     1812#endif
     1813        }
     1814        if (!success) {
     1815            psFree(output);
     1816            psError(PS_ERR_UNKNOWN, false, "pxSetStateClean failed for table %s",  tables[i].tableName);
     1817            return false;
     1818        }
    18021819    }
    18031820
  • trunk/ippTools/src/difftoolConfig.c

    r23740 r23873  
    215215    psMetadataAddStr(exportrunArgs, PS_LIST_TAIL, "-outfile", 0,          "export to this file (required)", NULL);
    216216    psMetadataAddU64(exportrunArgs, PS_LIST_TAIL, "-limit",   0,          "limit result set to N items", 0);
     217    psMetadataAddBool(exportrunArgs, PS_LIST_TAIL, "-clean",  0,          "mark tables as cleaned", false);
    217218
    218219    // -importrun
  • trunk/ippTools/src/faketool.c

    r23809 r23873  
    12651265  PXOPT_LOOKUP_STR(outfile, config->args, "-outfile", true,  false);
    12661266  PXOPT_LOOKUP_U64(limit,   config->args, "-limit",   false, false);
     1267  PXOPT_LOOKUP_BOOL(clean, config->args, "-clean", false);
    12671268
    12681269  FILE *f = fopen (outfile, "w");
     
    13131314    }
    13141315    if (!psArrayLength(output)) {
    1315       psTrace("regtool", PS_LOG_INFO, "no rows found");
     1316      psError(PS_ERR_UNKNOWN, true, "no rows found");
    13161317      psFree(output);
    1317       return true;
     1318      return false;
     1319    }
     1320
     1321    if (clean) {
     1322        if (!strcmp(tables[i].tableName, "fakeRun")) {
     1323            if(!pxSetStateCleaned("fakeRun", "state", output)) {
     1324                psFree(output);
     1325                psError(PS_ERR_UNKNOWN, false, "pxSetStateClean failed for table %s",  tables[i].tableName);
     1326                return false;
     1327            }
     1328        }
    13181329    }
    13191330
  • trunk/ippTools/src/faketoolConfig.c

    r23688 r23873  
    306306    psMetadataAddStr(exportrunArgs, PS_LIST_TAIL, "-outfile", 0,          "export to this file (required)", NULL);
    307307    psMetadataAddU64(exportrunArgs, PS_LIST_TAIL, "-limit",   0,          "limit result set to N items", 0);
     308    psMetadataAddBool(exportrunArgs, PS_LIST_TAIL, "-clean",  0,          "mark tables as cleaned", false);
    308309
    309310    // -importrun
  • trunk/ippTools/src/pxtools.c

    r23123 r23873  
    5050// 'scrubbed' is a virtual state equivalent to cleaned, but allows files to be removed
    5151// even if the config files is missing
     52
     53
     54// change the value for tableName.columName from 'full' to 'cleaned' if necessary
     55bool pxSetStateCleaned(const psString tableName, const psString columnName, psArray *rows)
     56{
     57    for (long i = 0; i < psArrayLength(rows); i++) {
     58        psMetadata *row = rows->data[i];
     59        psString state = psMetadataLookupStr(NULL, row, columnName);
     60        if (!state) {
     61            psError(PS_ERR_PROGRAMMING, false, "%s not found in row %" PRId64 " of table %s",
     62                columnName, i, tableName);
     63            return false;
     64        }
     65        if (!strcmp("full", state)) {
     66            // change full to cleaned
     67            psMetadataAddStr(row, PS_LIST_TAIL, columnName, PS_META_REPLACE, "", "cleaned");
     68        } else if (strcmp("cleaned", state)) {
     69            // if state isn't cleaned or full we can't set it to cleaned
     70            psError(PS_ERR_PROGRAMMING, true, "%s with state %s may not be exported cleaned",
     71                tableName, state);
     72            return false;
     73        }
     74    }
     75    return true;
     76}
  • trunk/ippTools/src/pxtools.h

    r23868 r23873  
    5050
    5151bool pxIsValidState(const char *state);
     52bool pxSetStateCleaned(const psString tableName, const psString columnName, psArray *rows);
    5253
    5354bool pxSetFaultCode(psDB *dbh, const char *tableName, psMetadata *where, psS16 code);
  • trunk/ippTools/src/stacktool.c

    r23742 r23873  
    11991199  PXOPT_LOOKUP_S64(det_id, config->args, "-stack_id", true,  false);
    12001200  PXOPT_LOOKUP_STR(outfile, config->args, "-outfile", true,  false);
     1201  PXOPT_LOOKUP_BOOL(clean, config->args, "-clean", false);
    12011202  PXOPT_LOOKUP_U64(limit,   config->args, "-limit",   false, false);
    12021203
     
    12491250    }
    12501251    if (!psArrayLength(output)) {
    1251       psTrace("regtool", PS_LOG_INFO, "no rows found");
     1252      psError(PS_ERR_UNKNOWN, true, "no rows found");
    12521253      psFree(output);
    1253       return true;
    1254     }
     1254      return false;
     1255    }
     1256
     1257    if (clean) {
     1258        if (!strcmp(tables[i].tableName, "stackRun")) {
     1259            if (!pxSetStateCleaned("stackRun", "state", output)) {
     1260                psFree(output);
     1261                psError(PS_ERR_UNKNOWN, false, "pxSetStateClean failed for table %s",  tables[i].tableName);
     1262                return false;
     1263            }
     1264        }
     1265    }
     1266
    12551267      // we must write the export table in non-simple (true) format
    12561268    if (!ippdbPrintMetadatas(f, output, tables[i].tableName, true)) {
  • trunk/ippTools/src/stacktoolConfig.c

    r23688 r23873  
    193193    psMetadataAddStr(exportrunArgs, PS_LIST_TAIL, "-outfile", 0,          "export to this file (required)", NULL);
    194194    psMetadataAddU64(exportrunArgs, PS_LIST_TAIL, "-limit",   0,          "limit result set to N items", 0);
     195    psMetadataAddBool(exportrunArgs, PS_LIST_TAIL, "-clean",  0,          "mark tables as cleaned", false);
    195196
    196197    // -importrun
  • trunk/ippTools/src/warptool.c

    r23809 r23873  
    16061606    PS_ASSERT_PTR_NON_NULL(config, NULL);
    16071607
    1608     PXOPT_LOOKUP_S64(det_id, config->args, "-warp_id", true,  false);
     1608    PXOPT_LOOKUP_S64(det_id,  config->args, "-warp_id", true,  false);
    16091609    PXOPT_LOOKUP_STR(outfile, config->args, "-outfile", true,  false);
    16101610    PXOPT_LOOKUP_U64(limit,   config->args, "-limit",   false, false);
     1611    PXOPT_LOOKUP_BOOL(clean,  config->args, "-clean", false);
    16111612
    16121613    FILE *f = fopen (outfile, "w");
     
    16611662      }
    16621663      if (!psArrayLength(output)) {
    1663         psTrace("regtool", PS_LOG_INFO, "no rows found");
     1664        psError(PS_ERR_UNKNOWN, true, "no rows found");
    16641665        psFree(output);
    1665         return true;
     1666        return false;
    16661667      }
     1668
     1669    if (clean) {
     1670        bool success = true;
     1671        if (!strcmp(tables[i].tableName, "warpRun")) {
     1672            success = pxSetStateCleaned("warpRun", "state", output);
     1673        } else if (!strcmp(tables[i].tableName, "warpSkyfile")) {
     1674            success = pxSetStateCleaned("warpSkyfile", "data_state", output);
     1675        }
     1676        if (!success) {
     1677            psFree(output);
     1678            psError(PS_ERR_UNKNOWN, false, "pxSetStateClean failed for table %s",  tables[i].tableName);
     1679            return false;
     1680        }
     1681    }
    16671682
    16681683      // we must write the export table in non-simple (true) format
  • trunk/ippTools/src/warptoolConfig.c

    r23688 r23873  
    276276    psMetadataAddStr(exportrunArgs, PS_LIST_TAIL, "-outfile", 0,          "export to this file (required)", NULL);
    277277    psMetadataAddU64(exportrunArgs, PS_LIST_TAIL, "-limit",   0,          "limit result set to N items", 0);
     278    psMetadataAddBool(exportrunArgs, PS_LIST_TAIL, "-clean",  0,          "export run in cleaned state", false);
    278279
    279280    // -importrun
Note: See TracChangeset for help on using the changeset viewer.