IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jun 25, 2009, 2:00:56 PM (17 years ago)
Author:
eugene
Message:

merging changes from head

Location:
branches/eam_branches/20090522
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/20090522

  • branches/eam_branches/20090522/ippTools/src

    • Property svn:ignore
      •  

        old new  
        3434disttool
        3535receivetool
         36
         37pubtool
  • branches/eam_branches/20090522/ippTools/src/warptool.c

    r24186 r24557  
    3838static bool tooverlapMode(pxConfig *config);
    3939static bool addoverlapMode(pxConfig *config);
     40static bool revertoverlapMode(pxConfig *config);
    4041static bool scmapMode(pxConfig *config);
    4142static bool towarpedMode(pxConfig *config);
     
    8687        MODECASE(WARPTOOL_MODE_TOOVERLAP,          tooverlapMode);
    8788        MODECASE(WARPTOOL_MODE_ADDOVERLAP,         addoverlapMode);
     89        MODECASE(WARPTOOL_MODE_REVERTOVERLAP,      revertoverlapMode);
    8890        MODECASE(WARPTOOL_MODE_SCMAP,              scmapMode);
    8991        MODECASE(WARPTOOL_MODE_TOWARPED,           towarpedMode);
     
    137139    PXOPT_LOOKUP_STR(dvodb, config->args, "-dvodb", false, false);
    138140    PXOPT_LOOKUP_STR(tess_id, config->args, "-tess_id", true, false); // required (no default TESS)
     141    PXOPT_LOOKUP_STR(reduction, config->args, "-reduction", false, false); // required (no default TESS)
    139142    PXOPT_LOOKUP_STR(end_stage, config->args, "-end_stage", false, false);
    140143    PXOPT_LOOKUP_TIME(registered, config->args, "-registered", false, false);
     
    157160            dvodb,
    158161            tess_id,
     162            reduction,
    159163            end_stage,
    160164            registered,
    161             false       // magicked
     165            0       // magicked
    162166    );
    163167    if (!warpRun) {
     
    247251    PXOPT_LOOKUP_STR(dvodb, config->args, "-set_dvodb", false, false);
    248252    PXOPT_LOOKUP_STR(tess_id, config->args, "-set_tess_id", false, false);
     253    PXOPT_LOOKUP_STR(reduction, config->args, "-set_reduction", false, false);
    249254    PXOPT_LOOKUP_STR(end_stage, config->args, "-set_end_stage", false, false);
    250255
     
    308313        }
    309314
    310         if (!tess_id  && !row->tess_id) {
    311             psError(PS_ERR_UNKNOWN, false, "cannot queue warp run without a defined tess id: label: %s, fake_id %" PRId64, row->label, row->fake_id);
     315        if (!tess_id  && !row->tess_id) {
     316            psError(PS_ERR_UNKNOWN, false, "cannot queue warp run without a defined tess id: label: %s, fake_id %" PRId64, row->label, row->fake_id);
    312317            psFree(output);
    313318            return false;
    314         }
     319        }
    315320
    316321        psFree(row);
    317322    }
    318     psFree(output);
    319323
    320324    // loop over our list of fakeRun rows
     
    331335        // queue the exp
    332336        if (!pxwarpQueueByFakeID(config,
    333                     row->fake_id,
    334                     workdir     ? workdir   : row->workdir,
    335                     label       ? label     : row->label,
    336                     dvodb       ? dvodb     : row->dvodb,
    337                     tess_id     ? tess_id   : row->tess_id,
    338                     end_stage   ? end_stage : row->end_stage))
     337                                 row->fake_id,
     338                                 workdir     ? workdir   : row->workdir,
     339                                 label       ? label     : row->label,
     340                                 dvodb       ? dvodb     : row->dvodb,
     341                                 tess_id     ? tess_id   : row->tess_id,
     342                                 reduction   ? reduction : row->reduction,
     343                                 end_stage   ? end_stage : row->end_stage))
    339344          {
    340345            psError(PS_ERR_UNKNOWN, false, "failed to trying to queue fake_id: %" PRId64, row->fake_id);
     
    651656        warpSkyCellMapInsert(config->dbh,
    652657            warp_id,
    653             NULL,   // skycell_id
    654             NULL,   // tess_id
    655             NULL,   // class_id
     658            "faulted",   // skycell_id
     659            "faulted",   // tess_id
     660            "faulted",   // class_id
    656661            fault    // fault
    657662        );
     
    666671    return true;
    667672}
     673
     674static bool revertoverlapMode(pxConfig *config)
     675{
     676    PS_ASSERT_PTR_NON_NULL(config, false);
     677
     678    psMetadata *where = psMetadataAlloc();
     679    PXOPT_COPY_S64(config->args, where, "-warp_id",    "warpSkyCellMap.warp_id", "==");
     680    PXOPT_COPY_STR(config->args, where, "-skycell_id", "warpSkyCellMap.skycell_id", "==");
     681    PXOPT_COPY_STR(config->args, where, "-tess_id",    "warpSkyCellMap.tess_id", "==");
     682    PXOPT_COPY_STR(config->args, where, "-label",      "warpRun.label", "==");
     683    PXOPT_COPY_S16(config->args, where, "-fault",      "warpSkyCellMap.fault", "==");
     684
     685    if (!psListLength(where->list)
     686        && !psMetadataLookupBool(NULL, config->args, "-all")) {
     687        psFree(where);
     688        psError(PXTOOLS_ERR_DATA, false, "search parameters are required");
     689        return false;
     690    }
     691
     692    int numDeleted;                     // Number deleted
     693    {
     694        psString query = pxDataGet("warptool_revertoverlap.sql");
     695        if (!query) {
     696            psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement");
     697            if (!psDBRollback(config->dbh)) {
     698                psError(PS_ERR_UNKNOWN, false, "database error");
     699            }
     700            return false;
     701        }
     702
     703        if (psListLength(where->list)) {
     704            psString whereClause = psDBGenerateWhereConditionSQL(where, NULL);
     705            psStringAppend(&query, " AND %s", whereClause);
     706            psFree(whereClause);
     707        }
     708
     709        if (!p_psDBRunQuery(config->dbh, query)) {
     710            psError(PS_ERR_UNKNOWN, false, "database error");
     711            psFree(query);
     712            if (!psDBRollback(config->dbh)) {
     713                psError(PS_ERR_UNKNOWN, false, "database error");
     714            }
     715            return false;
     716        }
     717        psFree(query);
     718
     719        numDeleted = psDBAffectedRows(config->dbh);
     720    }
     721
     722    psLogMsg("warptool", PS_LOG_INFO, "Deleted %d warpSkycellMap", numDeleted);
     723
     724    psFree(where);
     725
     726    return true;
     727}
     728
    668729
    669730
     
    919980    PXOPT_LOOKUP_STR(hostname, config->args, "-hostname", false, false);
    920981    PXOPT_LOOKUP_F32(good_frac, config->args, "-good_frac", false, false);
    921     PXOPT_LOOKUP_BOOL(magicked, config->args, "-magicked", false);
     982    PXOPT_LOOKUP_S64(magicked, config->args, "-magicked", false, false);
    922983
    923984    // default values
     
    10231084            return false;
    10241085        }
    1025         psS32 magicked = psMetadataLookupS64(&status, row, "magicked");
     1086        psS64 magicked = psMetadataLookupS64(&status, row, "magicked");
    10261087        if (!status) {
    10271088            psError(PS_ERR_UNKNOWN, false, "failed to look up value for magicked");
     
    12241285    }
    12251286
    1226 
    1227     // Update state to 'new'
    1228     int numUpdated;                     // Number updated
    1229     {
    1230         // This query is no longer necessary because we do not set warpRun's to full statte
    1231         // if they have faulted skyfiles.
    1232         // We do have runs in the DB that follow the old convention so we leave this in for
    1233         // now
    1234         psString query = pxDataGet("warptool_revertwarped_update.sql");
    1235         if (!query) {
    1236             psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement");
    1237             if (!psDBRollback(config->dbh)) {
    1238                 psError(PS_ERR_UNKNOWN, false, "database error");
    1239             }
    1240             return false;
    1241         }
    1242 
    1243         if (psListLength(where->list)) {
    1244             psString whereClause = psDBGenerateWhereConditionSQL(where, NULL);
    1245             psStringAppend(&query, " AND %s", whereClause);
    1246             psFree(whereClause);
    1247         }
    1248 
    1249         if (!p_psDBRunQuery(config->dbh, query)) {
    1250             psError(PS_ERR_UNKNOWN, false, "database error");
    1251             psFree(query);
    1252             if (!psDBRollback(config->dbh)) {
    1253                 psError(PS_ERR_UNKNOWN, false, "database error");
    1254             }
    1255             return false;
    1256         }
    1257         psFree(query);
    1258 
    1259         numUpdated = psDBAffectedRows(config->dbh);
    1260 
    1261 #ifdef notdef
    1262         // new warpRuns won't get changed (they're already new) so don't require an update
    1263         if (numUpdated < 1) {
    1264             psError(PS_ERR_UNKNOWN, false, "should have affected at least 1 row");
    1265             if (!psDBRollback(config->dbh)) {
    1266                 psError(PS_ERR_UNKNOWN, false, "database error");
    1267             }
    1268             return false;
    1269         }
    1270 #endif
    1271     }
    1272 
    1273     psLogMsg("warptool", PS_LOG_INFO, "Updated %d warp runs", numUpdated);
    1274 
    12751287    // Delete product
    12761288    int numDeleted;                     // Number deleted
     
    17441756
    17451757    if (clean) {
    1746         bool success = true; 
     1758        bool success = true;
    17471759        if (!strcmp(tables[i].tableName, "warpRun")) {
    17481760            success = pxSetStateCleaned("warpRun", "state", output);
Note: See TracChangeset for help on using the changeset viewer.