IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 37272


Ignore:
Timestamp:
Aug 20, 2014, 12:05:13 PM (12 years ago)
Author:
eugene
Message:

failure to affect rows may not be an error

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tags/ipp-pv3-20140717/ippTools/src/remotetool.c

    r37054 r37272  
    9292  PXOPT_LOOKUP_BOOL(simple,    config->args, "-simple",       false);
    9393  PXOPT_LOOKUP_BOOL(pretend,   config->args, "-pretend",      false);
    94  
     94
    9595  set_label = set_label ? set_label : label;
    9696
     
    105105      return(false);
    106106    }
    107    
     107
    108108    if (label) {
    109109      psStringAppend(&whereOption, "\n AND (label = '%s')", label);
     
    116116      return(false);
    117117    }
    118    
     118
    119119    if (label) {
    120120      psStringAppend(&whereOption, "\n AND (label = '%s')", label);
    121121    }
    122   }   
     122  }
    123123  else if (!strcmp(stage,"warp")) {
    124124    query = pxDataGet("remotetool_definebyquery_warp.sql");
     
    127127      return(false);
    128128    }
    129    
     129
    130130    if (label) {
    131131      // Because warp has to check to see if something other than the state is set correctly, I have to use this wonky way to pass the label in.
     
    133133      psStringAppend(&whereOption, "\n AND (label = '%s')", label);
    134134    }
    135   }   
     135  }
    136136  else if (!strcmp(stage,"stack")) {
    137137    query = pxDataGet("remotetool_definebyquery_stack.sql");
     
    140140      return(false);
    141141    }
    142    
     142
    143143    if (label) {
    144144      psStringAppend(&whereOption, "\n AND (label = '%s')", label);
    145145    }
    146   }   
     146  }
    147147  else {
    148148    psError(PS_ERR_UNKNOWN, true, "unknown value for stage: %s", stage);
     
    191191  // Insert the top level run object
    192192  remoteRunRow *run = remoteRunRowAlloc(0, // remote_id
    193                                         "new", // state
    194                                         stage,
    195                                         set_label,
    196                                         path_base,
    197                                         -1, // job_id
    198                                         NULL, // last_poll
    199                                         0   // fault
    200                                           );
     193                                        "new", // state
     194                                        stage,
     195                                        set_label,
     196                                        path_base,
     197                                        -1, // job_id
     198                                        NULL, // last_poll
     199                                        0   // fault
     200                                          );
    201201  if (!run) {
    202202    psError(PS_ERR_UNKNOWN, false, "failed to alloc lapRun object");
    203203    return(true);
    204204  }
    205  
     205
    206206  if (!remoteRunInsertObject(config->dbh, run)) {
    207207    if (!psDBRollback(config->dbh)) {
     
    213213  }
    214214  psS64 remote_id = psDBLastInsertID(config->dbh);
    215  
     215
    216216  psArray *list = psArrayAllocEmpty(limit);
    217217  for (long i=0; i < psArrayLength(output); i++) {
     
    220220
    221221    remoteComponentRow *comp = remoteComponentRowAlloc(remote_id,
    222                                                        stage_id);
     222                                                       stage_id);
    223223    if (!comp) {
    224224      psError(PS_ERR_UNKNOWN, false, "failed to alloc lapRun object");
    225225      return(true);
    226226    }
    227    
     227
    228228    if (!remoteComponentInsertObject(config->dbh, comp)) {
    229229      if (!psDBRollback(config->dbh)) {
    230         psError(PS_ERR_UNKNOWN, false, "database error");
     230        psError(PS_ERR_UNKNOWN, false, "database error");
    231231      }
    232232      psError(PS_ERR_UNKNOWN, false, "database error");
     
    237237    psArrayAdd(list, list->n, comp);
    238238    psFree(comp);
    239    
     239
    240240  }
    241241  psFree(run);
     
    245245    return false;
    246246  }
    247  
     247
    248248  if (!remoteComponentPrintObjects(stdout, list, !simple)) {
    249249    if (!psDBRollback(config->dbh)) {
     
    254254    return false;
    255255  }
    256  
     256
    257257  psFree(list);
    258258  psFree(output);
    259                                        
     259
    260260  return true;
    261261}
     
    265265{
    266266  psMetadata *where = psMetadataAlloc();
    267  
     267
    268268  PXOPT_COPY_S64(config->args, where, "-remote_id", "remote_id", "==");
    269269  PXOPT_COPY_STR(config->args, where, "-state", "state", "==");
     
    274274  PXOPT_COPY_TIME(config->args, where, "-poll_begin", "last_poll", ">=");
    275275  PXOPT_COPY_TIME(config->args, where, "-poll_end", "last_poll", "<=");
    276  
     276
    277277  PXOPT_COPY_S16(config->args, where, "-fault", "fault", "==");
    278278
    279279  PXOPT_LOOKUP_S16(limit,   config->args, "-limit",  false, false);
    280280  PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false);
    281  
     281
    282282
    283283  psArray *remRuns = NULL;
    284284  remRuns = psDBSelectRows(config->dbh, "remoteRun", where, limit);
    285  
     285
    286286  if (!ippdbPrintMetadatas(stdout, remRuns, "remoteRun", !simple)) {
    287287    psError(PS_ERR_UNKNOWN, false, "failed to print array");
     
    300300  PXOPT_COPY_S64(config->args, where, "-remote_id", "remote_id", "==");
    301301  PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false);
    302  
     302
    303303  psArray *remComps = NULL;
    304304  remComps = psDBSelectRows(config->dbh, "remoteComponent", where, 0);
    305  
     305
    306306  if (!ippdbPrintMetadatas(stdout, remComps, "remoteComponent", !simple)) {
    307307    psError(PS_ERR_UNKNOWN, false, "failed to print array");
     
    329329    return false;
    330330  }
    331  
     331
    332332  if (!psDBTransaction(config->dbh)) {
    333333    psError(PS_ERR_UNKNOWN, false, "database error");
     
    341341  }
    342342  psFree(query);
    343  
    344  
     343
     344
    345345
    346346  // point of no return
     
    349349    return false;
    350350  }
    351  
     351
    352352  return true;
    353353}
     
    364364  // Wheres
    365365  PXOPT_COPY_S64(config->args, where, "-remote_id", "remote_id", "==");
    366  
     366
    367367  // Values to set
    368368  PXOPT_COPY_STR(config->args, values, "-set_label", "label", "==");
     
    375375
    376376  if (rows < 1) {
    377     psError(PS_ERR_UNKNOWN,false, "no rows affected");
    378     return(false);
    379   }
    380  
     377      fprintf (stderr, "no rows changed (run may already be in desired state)\n");
     378  }
    381379  return(true);
    382380}
     
    393391  psString whereClause = psDBGenerateWhereConditionSQL(where, NULL);
    394392  psFree(where);
    395  
     393
    396394  psString query = NULL;
    397395  query = pxDataGet("remotetool_updatepoll.sql");
     
    412410  return(true);
    413411}
    414  
    415 
    416  
     412
     413
     414
    417415
    418416static bool revertrunMode(pxConfig *config)
     
    426424  PXOPT_COPY_S64(config->args, where, "-remote_id", "remote_id", "==");
    427425  PXOPT_COPY_STR(config->args, where, "-label", "label", "==");
    428  
     426
    429427  // Value to set
    430428  PXOPT_COPY_S16(config->args, values, "-fault", "fault", "==");
     
    451449  PXOPT_COPY_STR(config->args, where, "-label", "label", "==");
    452450
    453   psMetadataAddStr(where, PS_LIST_TAIL, "state", 0, "==", "auth"); 
     451  psMetadataAddStr(where, PS_LIST_TAIL, "state", 0, "==", "auth");
    454452
    455453  // Value to set
    456454  psMetadataAddStr(values, PS_LIST_TAIL, "state", 0, "==", "run");
    457  
     455
    458456  long rows = psDBUpdateRows(config->dbh, "remoteRun", where, values);
    459457  psFree(values);
     
    466464  return(true);
    467465}
    468    
     466
Note: See TracChangeset for help on using the changeset viewer.