IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Mar 30, 2012, 2:49:37 PM (14 years ago)
Author:
eugene
Message:

merge changes from trunk

Location:
branches/eam_branches/ipp-20111122/ippTools/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20111122/ippTools/src

  • branches/eam_branches/ipp-20111122/ippTools/src/disttool.c

    r32851 r33638  
    3434static bool updaterunMode(pxConfig *config);
    3535static bool revertrunMode(pxConfig *config);
    36 static bool rerunMode(pxConfig *config);
     36static bool startoverMode(pxConfig *config);
    3737static bool pendingcomponentMode(pxConfig *config);
    3838static bool addprocessedcomponentMode(pxConfig *config);
     39static bool updateprocessedcomponentMode(pxConfig *config);
     40static bool revertcomponentMode(pxConfig *config);
    3941static bool revertcomponentMode(pxConfig *config);
    4042static bool processedcomponentMode(pxConfig *config);
     
    8486        MODECASE(DISTTOOL_MODE_UPDATERUN, updaterunMode);
    8587        MODECASE(DISTTOOL_MODE_REVERTRUN, revertrunMode);
    86         MODECASE(DISTTOOL_MODE_RERUN, rerunMode);
     88        MODECASE(DISTTOOL_MODE_STARTOVER, startoverMode);
    8789        MODECASE(DISTTOOL_MODE_PENDINGCOMPONENT, pendingcomponentMode);
    8890        MODECASE(DISTTOOL_MODE_ADDPROCESSEDCOMPONENT, addprocessedcomponentMode);
     91        MODECASE(DISTTOOL_MODE_UPDATEPROCESSEDCOMPONENT, updateprocessedcomponentMode);
    8992        MODECASE(DISTTOOL_MODE_PROCESSEDCOMPONENT, processedcomponentMode);
    9093        MODECASE(DISTTOOL_MODE_REVERTCOMPONENT, revertcomponentMode);
     
    165168
    166169    PXOPT_LOOKUP_BOOL(single, config->args, "-singlefilter", false);
     170    PXOPT_LOOKUP_BOOL(rerun, config->args, "-rerun", false);
    167171
    168172    if (use_alternate) {
     
    404408            psStringAppend(&query, " AND (camRun.state = 'full')");
    405409        }
     410    }
     411    if (!rerun) {
     412        psStringAppend(&query, " AND (distRun.dist_id IS NULL)");
    406413    }
    407414
     
    643650}
    644651
    645 static bool rerunMode(pxConfig *config)
     652static bool startoverMode(pxConfig *config)
    646653{
    647654    psMetadata *where = psMetadataAlloc();
     
    653660
    654661    // require data_group or dist_id to be supplied
    655     PXOPT_LOOKUP_STR(data_group, config->args, "-data_group", true, false);
     662    PXOPT_LOOKUP_STR(data_group, config->args, "-data_group", false, false);
    656663    PXOPT_LOOKUP_S64(dist_id, config->args, "-dist_id", false, false);
    657664    if (!data_group && !dist_id) {
     
    969976    return true;
    970977}
     978static bool updateprocessedcomponentMode(pxConfig *config)
     979{
     980
     981    // required values
     982    PXOPT_LOOKUP_S64(dist_id, config->args, "-dist_id", true, false);
     983    PXOPT_LOOKUP_STR(component, config->args, "-component", true, false);
     984
     985    PXOPT_LOOKUP_S16(fault, config->args, "-fault", false, false);
     986    PXOPT_LOOKUP_BOOL(clearfault, config->args, "-clearfault", false);
     987    PXOPT_LOOKUP_S32(bytes, config->args, "-bytes", false, false);
     988    PXOPT_LOOKUP_STR(md5sum, config->args, "-md5sum", false, false);
     989    PXOPT_LOOKUP_STR(outdir, config->args, "-outdir", false, false);
     990    PXOPT_LOOKUP_STR(name, config->args, "-name", false, false);
     991
     992    bool setfault = clearfault || fault;
     993
     994    if (!bytes && !md5sum && !outdir && !name && !setfault && !fault) {
     995        psError(PS_ERR_UNKNOWN, true, "at least one of bytes md5sum outdir name fault or setfault is required");
     996        return false;
     997    }
     998
     999    char *sep = "";
     1000    psString query = psStringCopy("UPDATE distComponent SET ");
     1001    if (setfault) {
     1002        psStringAppend(&query, "%s fault = %d", sep, fault ? 1 : 0);
     1003        sep = ", ";
     1004    }
     1005    if (bytes) {
     1006        psStringAppend(&query, "%s bytes = %d", sep, bytes);
     1007        sep = ", ";
     1008    }
     1009    if (md5sum) {
     1010        psStringAppend(&query, "%s md5sum = '%s'", sep, md5sum);
     1011        sep = ", ";
     1012    }
     1013    if (outdir) {
     1014        psStringAppend(&query, "%s outdir = '%s'", sep, outdir);
     1015        sep = ", ";
     1016    }
     1017    if (name) {
     1018        psStringAppend(&query, "%s name = '%s'", sep, name);
     1019        sep = ", ";
     1020    }
     1021
     1022    psStringAppend(&query, "\nWHERE dist_id = %"PRId64 " AND component = '%s'",
     1023        dist_id, component);
     1024
     1025    if (!p_psDBRunQuery(config->dbh, query)) {
     1026        psError(PS_ERR_UNKNOWN, false, "database error");
     1027        psFree(query);
     1028        return false;
     1029    }
     1030    psFree(query);
     1031
     1032    return true;
     1033}
    9711034
    9721035static bool toadvanceMode(pxConfig *config)
     
    10481111    psMetadata *where = psMetadataAlloc();
    10491112    PXOPT_COPY_S64(config->args, where, "-dist_id", "dist_id", "==");
     1113    PXOPT_COPY_STR(config->args, where, "-component", "component", "==");
    10501114
    10511115    PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false);
     
    21852249    psMetadata *where = psMetadataAlloc();
    21862250    PXOPT_COPY_S64(config->args, where, "-fs_id", "fs_id", "==");
     2251    PXOPT_COPY_S64(config->args, where, "-dist_id", "dist_id", "==");
    21872252
    21882253    if (!psListLength(where->list)) {
Note: See TracChangeset for help on using the changeset viewer.