IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Dec 22, 2019, 4:11:49 PM (7 years ago)
Author:
cclin33
Message:

update addstar for multiple hosts

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/ccl_branches/ipponly-20191108/ippTools/src/addtool.c

    r41072 r41211  
    118118    psMetadata *where = psMetadataAlloc();
    119119    //  pxcamGetSearchArgs (config, where);
    120     PXOPT_COPY_S64(config->args, where,  "-cam_id",    "camRun.cam_id", "==");
    121     PXOPT_COPY_S64(config->args, where,  "-stack_id",    "stackRun.stack_id", "==");
     120    PXOPT_COPY_S64(config->args, where,  "-cam_id",    "camRun.cam_id",       "==");
     121    PXOPT_COPY_S64(config->args, where,  "-stack_id",  "stackRun.stack_id",  "==");
    122122    PXOPT_COPY_S64(config->args, where,  "-sky_id",    "staticskyRun.sky_id", "==");
    123     PXOPT_COPY_S64(config->args, where,  "-skycal_id",  "skycalRun.skycal_id", "==");
    124     PXOPT_COPY_S64(config->args, where,  "-diff_id",  "diffRun.diff_id", "==");
    125     PXOPT_COPY_S64(config->args, where,  "-ff_id",  "fullForceRun.ff_id", "==");
     123    PXOPT_COPY_S64(config->args, where,  "-skycal_id", "skycalRun.skycal_id", "==");
     124    PXOPT_COPY_S64(config->args, where,  "-diff_id",   "diffRun.diff_id",    "==");
     125    PXOPT_COPY_S64(config->args, where,  "-ff_id",     "fullForceRun.ff_id", "==");
    126126       
    127127    // PXOPT_LOOKUP_STR(stage,       config->args, "-stage", false, false);
    128     PXOPT_LOOKUP_STR(workdir,     config->args, "-set_workdir", false, false);
    129     PXOPT_LOOKUP_STR(dvodb,       config->args, "-set_dvodb", false, false);
    130     PXOPT_LOOKUP_STR(label,       config->args, "-set_label", false, false);
    131     PXOPT_LOOKUP_STR(data_group,  config->args, "-set_data_group", false, false);
    132     PXOPT_LOOKUP_STR(reduction,   config->args, "-set_reduction", false, false);
    133     PXOPT_LOOKUP_STR(note,        config->args, "-set_note", false, false);
    134     PXOPT_LOOKUP_STR(minidvodb_name,  config->args, "-set_minidvodb_name", false, false);
     128    PXOPT_LOOKUP_STR(workdir,         config->args, "-set_workdir",        false, false);
     129    PXOPT_LOOKUP_STR(dvodb,           config->args, "-set_dvodb",          false, false);
     130    PXOPT_LOOKUP_STR(label,           config->args, "-set_label",          false, false);
     131    PXOPT_LOOKUP_STR(data_group,      config->args, "-set_data_group",      false, false);
     132    PXOPT_LOOKUP_STR(reduction,       config->args, "-set_reduction",      false, false);
     133    PXOPT_LOOKUP_STR(note,            config->args, "-set_note",            false, false);
     134    PXOPT_LOOKUP_BOOL(minidvodb,      config->args, "-set_minidvodb",              false);
    135135    PXOPT_LOOKUP_STR(minidvodb_group, config->args, "-set_minidvodb_group", false, false);
    136     PXOPT_LOOKUP_BOOL(image_only, config->args, "-image_only", false);
    137     PXOPT_LOOKUP_BOOL(minidvodb,  config->args, "-set_minidvodb", false);
    138     PXOPT_LOOKUP_BOOL(destreaked, config->args, "-destreaked", false);
    139     PXOPT_LOOKUP_BOOL(uncensored, config->args, "-uncensored", false);
    140 
    141     PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false);
    142 
    143     PXOPT_LOOKUP_BOOL(pretend,    config->args, "-pretend", false);
    144     PXOPT_LOOKUP_BOOL(simple,     config->args, "-simple", false);
     136    PXOPT_LOOKUP_STR(minidvodb_name,  config->args, "-set_minidvodb_name",  false, false);
     137    PXOPT_LOOKUP_STR(minidvodb_host,  config->args, "-set_minidvodb_host",  false, false);
     138    PXOPT_LOOKUP_BOOL(image_only,     config->args, "-image_only",          false);
     139    PXOPT_LOOKUP_BOOL(destreaked,     config->args, "-destreaked",          false);
     140    PXOPT_LOOKUP_BOOL(uncensored,     config->args, "-uncensored",          false);
     141
     142    PXOPT_LOOKUP_BOOL(pretend, config->args, "-pretend",       false);
     143    PXOPT_LOOKUP_BOOL(simple,  config->args, "-simple",        false);
     144    PXOPT_LOOKUP_U64(limit,    config->args, "-limit",  false, false);
    145145   
    146     PXOPT_LOOKUP_F32(minra,     config->args, "-set_minra", false, false);
    147     PXOPT_LOOKUP_F32(maxra,     config->args, "-set_maxra", false, false);
    148     PXOPT_LOOKUP_F32(mindec,     config->args, "-set_mindec", false, false);
    149     PXOPT_LOOKUP_F32(maxdec,     config->args, "-set_maxdec", false, false);
     146    PXOPT_LOOKUP_F32(minra,  config->args, "-set_minra", false, false);
     147    PXOPT_LOOKUP_F32(maxra,  config->args, "-set_maxra", false, false);
     148    PXOPT_LOOKUP_F32(mindec, config->args, "-set_mindec", false, false);
     149    PXOPT_LOOKUP_F32(maxdec, config->args, "-set_maxdec", false, false);
    150150
    151151    // Handle stages
     
    153153    if (strcmp(stage, "cam") == 0) {
    154154      pxcamGetSearchArgs (config, where);
    155       pxAddLabelSearchArgs (config, where, "-label",     "camRun.label", "=="); // define using camRun label
    156       pxAddLabelSearchArgs (config, where, "-data_group","camRun.data_group", "=="); // define using camRun label
    157       PXOPT_COPY_STR(config->args, where,  "-reduction", "camRun.reduction", "==");
     155      pxAddLabelSearchArgs (config, where,      "-label",      "camRun.label", "=="); // define using camRun label
     156      pxAddLabelSearchArgs (config, where, "-data_group", "camRun.data_group", "=="); // define using camRun label
     157      PXOPT_COPY_STR(config->args,  where,  "-reduction", "camRun.reduction", "==");
    158158    }
    159159    else if (strcmp(stage, "stack") == 0) {
    160       pxAddLabelSearchArgs (config, where, "-label",     "stackRun.label", "=="); // define using camRun label
    161       pxAddLabelSearchArgs (config, where, "-data_group","stackRun.data_group", "=="); // define using camRun label
    162       PXOPT_COPY_STR(config->args, where,  "-reduction", "stackRun.reduction", "==");
    163       pxAddLabelSearchArgs (config, where, "-filter",     "stackRun.filter", "=="); // define using camRun label
     160      pxAddLabelSearchArgs (config, where,      "-label",      "stackRun.label", "=="); // define using camRun label
     161      pxAddLabelSearchArgs (config, where, "-data_group", "stackRun.data_group", "=="); // define using camRun label
     162      PXOPT_COPY_STR(config->args,  where,  "-reduction", "stackRun.reduction", "==");
     163      pxAddLabelSearchArgs (config, where,     "-filter",     "stackRun.filter", "=="); // define using camRun label
    164164    }
    165165    else if (strcmp(stage, "staticsky") == 0) {
    166       pxAddLabelSearchArgs (config, where, "-label",     "staticskyRun.label", "=="); // define using camRun label
    167       pxAddLabelSearchArgs (config, where, "-data_group","staticskyRun.data_group", "=="); // define using camRun label
    168       PXOPT_COPY_STR(config->args, where,  "-reduction", "staticskyRun.reduction", "==");
     166      pxAddLabelSearchArgs (config, where,      "-label",      "staticskyRun.label", "=="); // define using camRun label
     167      pxAddLabelSearchArgs (config, where, "-data_group", "staticskyRun.data_group", "=="); // define using camRun label
     168      PXOPT_COPY_STR(config->args,  where,  "-reduction", "staticskyRun.reduction", "==");
    169169      //no filter here
    170170    }
    171171    else if (strcmp(stage, "skycal") == 0) {
    172       pxAddLabelSearchArgs (config, where, "-label",     "skycalRun.label", "=="); //define using skycalRun label
    173       pxAddLabelSearchArgs (config, where, "-data_group","skycalRun.data_group", "==");
    174       PXOPT_COPY_STR(config->args, where,  "-reduction", "skycalRun.reduction", "==");
     172      pxAddLabelSearchArgs (config, where,      "-label",      "skycalRun.label", "=="); //define using skycalRun label
     173      pxAddLabelSearchArgs (config, where, "-data_group", "skycalRun.data_group", "==");
     174      PXOPT_COPY_STR(config->args,  where,  "-reduction",  "skycalRun.reduction", "==");
    175175    }
    176176    else if (strcmp(stage, "diff") == 0) {
    177177      pxAddLabelSearchArgs (config, where, "-label",     "diffRun.label", "=="); //define using diffRun label
    178178      pxAddLabelSearchArgs (config, where, "-data_group","diffRun.data_group", "==");
    179       PXOPT_COPY_STR(config->args, where, "-reduction", "diffRun.reduction",  "==");
     179      PXOPT_COPY_STR(config->args,  where, "-reduction", "diffRun.reduction",  "==");
    180180    }
    181181    else if (strcmp(stage, "fullforce") == 0) {
    182182      pxAddLabelSearchArgs (config, where, "-label",     "fullForceRun.label", "=="); //define using fullForceRun label
    183183      pxAddLabelSearchArgs (config, where, "-data_group","fullForceRun.data_group", "==");
    184       PXOPT_COPY_STR(config->args, where, "-reduction", "fullForceRun.reduction",  "==");
     184      PXOPT_COPY_STR(config->args,  where, "-reduction", "fullForceRun.reduction",  "==");
    185185    }
    186186    else if (strcmp(stage, "fullforce_summary")==0) {
     
    201201      //if one of destreaked and uncensored is true, but not both
    202202      if (destreaked) {
    203         psTrace("addtool.c", PS_LOG_INFO, "using -destreaked\n");
     203        psTrace("addtool.c", PS_LOG_INFO, "using -destreaked\n");
    204204      } else {
    205         psTrace("addtool.c", PS_LOG_INFO, "using -unscensored\n");
     205        psTrace("addtool.c", PS_LOG_INFO, "using -unscensored\n");
    206206      }
    207207    } else {
    208208      if (destreaked && uncensored) {
    209         psError(PS_ERR_UNKNOWN, false, "Both -destreaked and -uncensored are selected. Please use one or the other, not both, \n");
    210         return false;
     209        psError(PS_ERR_UNKNOWN, false, "Both -destreaked and -uncensored are selected. Please use one or the other, not both, \n");
     210        return false;
    211211      }
    212212      if (!destreaked && !uncensored) {
    213         psError(PS_ERR_UNKNOWN, false, "Neither -destreaked or -uncensored are selected. Please use one.\n");
    214         return false;
     213        psError(PS_ERR_UNKNOWN, false, "Neither -destreaked or -uncensored are selected. Please use one.\n");
     214        return false;
    215215      }
    216216    }
    217217    if ((strcmp(stage,"diff") == 0) ||
    218         (strcmp(stage,"fullforce") == 0) ||
    219         (strcmp(stage,"fullforce_summary") == 0)) {
     218        (strcmp(stage,"fullforce") == 0) ||
     219        (strcmp(stage,"fullforce_summary") == 0)) {
    220220      if (! (dvodb)) {
    221         psError(PS_ERR_UNKNOWN, false, "The SQL is not correctly written to handle this case (-set_dvodb not specified), so stopping here.");
    222         return(false);
     221        psError(PS_ERR_UNKNOWN, false, "The SQL is not correctly written to handle this case (-set_dvodb not specified), so stopping here.");
     222        return(false);
    223223      }
    224224    }
     
    232232    if (strcmp(stage,"cam") == 0 ) {
    233233      if (dvodb) {
    234         psTrace("addtool.c", PS_LOG_INFO, "dvodb argument found (%s) using addtool_find_cam_id_dvo.sql\n%s\n", dvodb,stage);
     234        psTrace("addtool.c", PS_LOG_INFO, "dvodb argument found (%s) using addtool_find_cam_id_dvo.sql\n%s\n", dvodb,stage);
    235235        // find the cam_id of all the exposures that we want to queue up.
    236236        bare_query = pxDataGet("addtool_find_cam_id_dvo.sql");
    237         // user supplied dvodb
    238         psStringAppend(&dvodb_string, "addRun.dvodb = '%s'", dvodb);
     237        // user supplied dvodb
     238        psStringAppend(&dvodb_string, "addRun.dvodb = '%s'", dvodb);
    239239      } else {
    240         psTrace("addtool.c", PS_LOG_INFO, "dvodb argument not found using addtool_find_cam_id.sql\n%s\n",stage);
     240        psTrace("addtool.c", PS_LOG_INFO, "dvodb argument not found using addtool_find_cam_id.sql\n%s\n",stage);
    241241        // find the cam_id of all the exposures that we want to queue up.
    242242        bare_query = pxDataGet("addtool_find_cam_id.sql");
     
    248248    else if (strcmp(stage,"stack") == 0) {
    249249      if (dvodb) {
    250         psTrace("addtool.c", PS_LOG_INFO, "dvodb argument found (%s) using addtool_find_stack_id_dvo.sql\n%s\n", dvodb,stage);
     250        psTrace("addtool.c", PS_LOG_INFO, "dvodb argument found (%s) using addtool_find_stack_id_dvo.sql\n%s\n", dvodb,stage);
    251251        // find the cam_id of all the exposures that we want to queue up.
    252252        bare_query = pxDataGet("addtool_find_stack_id_dvo.sql");
    253         // user supplied dvodb
    254         psStringAppend(&dvodb_string, "addRun.dvodb = '%s'", dvodb);
     253        // user supplied dvodb
     254        psStringAppend(&dvodb_string, "addRun.dvodb = '%s'", dvodb);
    255255      } else {
    256         psTrace("addtool.c", PS_LOG_INFO, "dvodb argument not found using addtool_find_stack_id.sql\n%s\n",stage);
     256        psTrace("addtool.c", PS_LOG_INFO, "dvodb argument not found using addtool_find_stack_id.sql\n%s\n",stage);
    257257        // find the cam_id of all the exposures that we want to queue up.
    258258        bare_query = pxDataGet("addtool_find_stack_id.sql");
     
    264264    else if (strcmp(stage,"staticsky") == 0) {
    265265      if (dvodb ) {
    266         psTrace("addtool.c", PS_LOG_INFO, "dvodb argument found (%s) using addtool_find_sky_id_multi_dvo.sql\n%s\n", dvodb,stage);
     266        psTrace("addtool.c", PS_LOG_INFO, "dvodb argument found (%s) using addtool_find_sky_id_multi_dvo.sql\n%s\n", dvodb,stage);
    267267        // find the cam_id of all the exposures that we want to queue up.
    268268        bare_query = pxDataGet("addtool_find_sky_id_multi_dvo.sql");
    269         // user supplied dvodb
    270         psStringAppend(&dvodb_string, "addRun.dvodb = '%s'", dvodb);
     269        // user supplied dvodb
     270        psStringAppend(&dvodb_string, "addRun.dvodb = '%s'", dvodb);
    271271      } else {
    272         psTrace("addtool.c", PS_LOG_INFO, "dvodb argument not found using addtool_find_sky_id_multi.sql\n%s\n",stage);
     272        psTrace("addtool.c", PS_LOG_INFO, "dvodb argument not found using addtool_find_sky_id_multi.sql\n%s\n",stage);
    273273        // find the cam_id of all the exposures that we want to queue up.
    274274        bare_query = pxDataGet("addtool_find_sky_id_multi.sql");
     
    291291        // inherit dvodb from skycalRun, avoid matching NULL
    292292        psStringAppend(&dvodb_string, "(skycalRun.dvodb IS NOT NULL AND previous_dvodb = skycalRun.dvodb)");
    293         // this is silly, there is no dvodb in skycalRun...?
     293        // this is silly, there is no dvodb in skycalRun...?
    294294      }
    295295    }
     
    308308        // inherit dvodb from skycalRun, avoid matching NULL
    309309        psStringAppend(&dvodb_string, "(diffRun.dvodb IS NOT NULL AND previous_dvodb = diffRun.dvodb)");
    310         // this is silly, there is no dvodb in skycalRun...?
     310        // this is silly, there is no dvodb in skycalRun...?
    311311      }
    312312    }
     
    325325        // inherit dvodb from skycalRun, avoid matching NULL
    326326        psStringAppend(&dvodb_string, "(fullForceRun.dvodb IS NOT NULL AND previous_dvodb = fullForceRun.dvodb)");
    327         // this is silly, there is no dvodb in skycalRun...?
     327        // this is silly, there is no dvodb in skycalRun...?
    328328      }
    329329    }
     
    341341        // inherit dvodb from skycalRun, avoid matching NULL
    342342        psStringAppend(&dvodb_string, "(fullForceRun.dvodb IS NOT NULL AND previous_dvodb = fullForceRun.dvodb)");
    343         // this is silly, there is no dvodb in skycalRun...?
     343        // this is silly, there is no dvodb in skycalRun...?
    344344      }
    345345    }
     
    347347    if (!bare_query) {
    348348        psError(PXTOOLS_ERR_SYS, false, "failed to retrieve SQL statement");
    349         psFree(where);
    350         return false;
     349        psFree(where);
     350        return false;
    351351    }
    352352   
     
    362362        psStringAppend(&query, " AND %s", whereClause);
    363363
    364         if ((strcmp(stage,"diff") == 0)||
    365             (strcmp(stage,"fullforce") == 0)||
    366             (strcmp(stage,"fullforce_summary") == 0)) {
    367           //diff needs the ra /deg stuff
    368           //ff needs the ra /deg stuff
    369           //ff summary needs the ra /deg stuff
    370           psStringAppend(&query, " AND radeg >= %f", minra);
    371           psStringAppend(&query, " AND radeg <= %f", maxra);
    372           psStringAppend(&query, " AND decdeg >= %f", mindec);
    373           psStringAppend(&query, " AND decdeg <= %f", maxdec);
    374         }
    375 
     364        if ((strcmp(stage,"diff") == 0)||
     365            (strcmp(stage,"fullforce") == 0)||
     366            (strcmp(stage,"fullforce_summary") == 0)) {
     367          //diff needs the ra /deg stuff
     368          //ff needs the ra /deg stuff
     369          //ff summary needs the ra /deg stuff
     370          psStringAppend(&query, " AND radeg >= %f", minra);
     371          psStringAppend(&query, " AND radeg <= %f", maxra);
     372          psStringAppend(&query, " AND decdeg >= %f", mindec);
     373          psStringAppend(&query, " AND decdeg <= %f", maxdec);
     374        }
    376375        psFree(whereClause);
    377376    } else {
     
    384383      //This picks the magicked/censored ones
    385384      if ((strcmp(stage,"cam") == 0)||
    386           (strcmp(stage,"stack") == 0)) {
     385          (strcmp(stage,"stack") == 0)) {
    387386        psStringAppend(&query, " AND (camRun.magicked > 0)");
    388387      }
     
    391390      //This picks only the unmagicked/uncensored ones
    392391      //if (strcmp(stage,"cam") == 0) {
    393         //we can now properly handle the magicked case in ippScripts, so we queue camRuns in any magic state now if -uncensored.
     392        //we can now properly handle the magicked case in ippScripts, so we queue camRuns in any magic state now if -uncensored.
    394393        //psStringAppend(&query, " AND (camRun.magicked = 0)");
    395         //}
     394        //}
    396395      if (strcmp(stage,"stack") == 0) {
    397         psStringAppend(&query, " AND (stackRun.magicked = 0)");
     396        psStringAppend(&query, " AND (stackRun.magicked = 0)");
    398397      }
    399398    }
     
    457456      // negative simple so the default is true
    458457      if (!ippdbPrintMetadatas(stdout, output, "addRun", !simple)) {
    459         psError(PS_ERR_UNKNOWN, false, "failed to print array");
    460         psFree(output);
    461         return false;
     458        psError(PS_ERR_UNKNOWN, false, "failed to print array");
     459        psFree(output);
     460        return false;
    462461      }
    463462      psFree(output);
     
    469468      for (long i = 0; i < psArrayLength(output); i++) {
    470469        psMetadata *md = output->data[i];
    471        
    472         camRunRow *row = camRunObjectFromMetadata(md);
    473        
     470       
     471        camRunRow *row = camRunObjectFromMetadata(md);
     472       
    474473        if (!row) {
    475           psError(PS_ERR_UNKNOWN, false, "failed to convert metadata into camRun");
    476           psFree(output);
    477           return false;
    478         }
    479        
     474          psError(PS_ERR_UNKNOWN, false, "failed to convert metadata into camRun");
     475          psFree(output);
     476          return false;
     477        }
     478       
    480479        if (!dvodb && !row->dvodb) {
    481           psError(PS_ERR_UNKNOWN, false, "cannot queue addstar run without a defined dvodb: label: %s, cam_id %" PRId64, row->label, row->cam_id);
    482           psFree(output);
    483           return false;
     480          psError(PS_ERR_UNKNOWN, false, "cannot queue addstar run without a defined dvodb: label: %s, cam_id %" PRId64, row->label, row->cam_id);
     481          psFree(output);
     482          return false;
    484483        }
    485484        if (!workdir && !row->workdir) {
    486           psError(PS_ERR_UNKNOWN, false, "cannot queue addstar run without a defined workdir: label: %s, cam_id %" PRId64, row->label, row->cam_id);
    487           psFree(output);
    488           return false;
    489         }
    490        
     485          psError(PS_ERR_UNKNOWN, false, "cannot queue addstar run without a defined workdir: label: %s, cam_id %" PRId64, row->label, row->cam_id);
     486          psFree(output);
     487          return false;
     488        }
     489       
    491490        psFree(row);
    492491      }
     
    495494      for (long i = 0; i < psArrayLength(output); i++) {
    496495        psMetadata *md = output->data[i];
    497        
    498         stackRunRow *row = stackRunObjectFromMetadata(md);
    499        
     496       
     497        stackRunRow *row = stackRunObjectFromMetadata(md);
     498       
    500499        if (!row) {
    501           psError(PS_ERR_UNKNOWN, false, "failed to convert metadata into camRun");
    502           psFree(output);
    503           return false;
    504         }
    505        
     500          psError(PS_ERR_UNKNOWN, false, "failed to convert metadata into camRun");
     501          psFree(output);
     502          return false;
     503        }
     504       
    506505        if (!dvodb && !row->dvodb) {
    507           psError(PS_ERR_UNKNOWN, false, "cannot queue addstar run without a defined dvodb: label: %s, stack_id %" PRId64, row->label, row->stack_id);
    508           psFree(output);
    509           return false;
     506          psError(PS_ERR_UNKNOWN, false, "cannot queue addstar run without a defined dvodb: label: %s, stack_id %" PRId64, row->label, row->stack_id);
     507          psFree(output);
     508          return false;
    510509        }
    511510        if (!workdir && !row->workdir) {
    512           psError(PS_ERR_UNKNOWN, false, "cannot queue addstar run without a defined workdir: label: %s, stack_id %" PRId64, row->label, row->stack_id);
    513           psFree(output);
    514           return false;
    515         }
    516        
     511          psError(PS_ERR_UNKNOWN, false, "cannot queue addstar run without a defined workdir: label: %s, stack_id %" PRId64, row->label, row->stack_id);
     512          psFree(output);
     513          return false;
     514        }
     515       
    517516        psFree(row);
    518517      }
     
    521520      for (long i = 0; i < psArrayLength(output); i++) {
    522521        psMetadata *md = output->data[i];
    523         bool status = false;
    524         psS32 num_inputs = psMetadataLookupS32(&status, md, "num_inputs");
    525         if (!status) {
    526           psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item num_inputs");
    527           return false;
    528         }
    529         if (num_inputs < 0) {
    530           psError(PS_ERR_UNKNOWN, true, "invalid value for num_inputs");
    531           return false;
    532         }
    533        
    534         staticskyRunRow *row = staticskyRunObjectFromMetadata(md);
    535        
     522        bool status = false;
     523        psS32 num_inputs = psMetadataLookupS32(&status, md, "num_inputs");
     524        if (!status) {
     525          psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item num_inputs");
     526          return false;
     527        }
     528        if (num_inputs < 0) {
     529          psError(PS_ERR_UNKNOWN, true, "invalid value for num_inputs");
     530          return false;
     531        }
     532       
     533        staticskyRunRow *row = staticskyRunObjectFromMetadata(md);
     534       
    536535        if (!row) {
    537           psError(PS_ERR_UNKNOWN, false, "failed to convert metadata into camRun");
    538           psFree(output);
    539           return false;
    540         }
    541        
     536          psError(PS_ERR_UNKNOWN, false, "failed to convert metadata into camRun");
     537          psFree(output);
     538          return false;
     539        }
     540       
    542541        if (!dvodb) {  //there's no staticsky.dvodb
    543           psError(PS_ERR_UNKNOWN, false, "cannot queue addstar run without a defined dvodb: label: %s, sky_id %" PRId64, row->label, row->sky_id);
    544           psFree(output);
    545           return false;
     542          psError(PS_ERR_UNKNOWN, false, "cannot queue addstar run without a defined dvodb: label: %s, sky_id %" PRId64, row->label, row->sky_id);
     543          psFree(output);
     544          return false;
    546545        }
    547546        if (!workdir && !row->workdir) {
    548           psError(PS_ERR_UNKNOWN, false, "cannot queue addstar run without a defined workdir: label: %s, sky_id %" PRId64, row->label, row->sky_id);
    549           psFree(output);
    550           return false;
    551         }
    552        
     547          psError(PS_ERR_UNKNOWN, false, "cannot queue addstar run without a defined workdir: label: %s, sky_id %" PRId64, row->label, row->sky_id);
     548          psFree(output);
     549          return false;
     550        }
     551       
    553552        psFree(row);
    554553      }
     
    557556      for (long i = 0; i < psArrayLength(output); i++) {
    558557        psMetadata *md = output->data[i];
    559        
     558       
    560559        skycalRunRow *row = skycalRunObjectFromMetadata(md);
    561560
    562561        if (!row) {
    563           psError(PS_ERR_UNKNOWN, false, "failed to convert metadata into skycalRun");
    564           psFree(output);
    565           return false;
    566         }
    567        
    568         if (!dvodb) {  // there's no skycalRun.dvodb
    569           psError(PS_ERR_UNKNOWN, false, "cannot queue addstar run without a defined dvodb: label: %s, skycal_id %" PRId64, row->label, row->skycal_id);
    570           psFree(output);
    571           return false;
     562          psError(PS_ERR_UNKNOWN, false, "failed to convert metadata into skycalRun");
     563          psFree(output);
     564          return false;
     565        }
     566       
     567        if (!dvodb) {  // there's no skycalRun.dvodb
     568           psError(PS_ERR_UNKNOWN, false, "cannot queue addstar run without a defined dvodb: label: %s, skycal_id %" PRId64, row->label, row->skycal_id);
     569          psFree(output);
     570          return false;
    572571        }
    573572        if (!workdir && !row->workdir) {
    574           psError(PS_ERR_UNKNOWN, false, "cannot queue addstar run without a defined workdir: label: %s, skycal_id %" PRId64, row->label, row->skycal_id);
    575           psFree(output);
    576           return false;
    577         }
    578        
     573          psError(PS_ERR_UNKNOWN, false, "cannot queue addstar run without a defined workdir: label: %s, skycal_id %" PRId64, row->label, row->skycal_id);
     574          psFree(output);
     575          return false;
     576        }
     577       
    579578        psFree(row);
    580579      }
     
    583582      for (long i = 0; i < psArrayLength(output); i++) {
    584583        psMetadata *md = output->data[i];
    585        
     584       
    586585        diffRunRow *row = diffRunObjectFromMetadata(md);
    587        
     586       
    588587        if (!row) {
    589           psError(PS_ERR_UNKNOWN, false, "failed to convert metadata into diffRun");
    590           psFree(output);
    591           return false;
    592         }
    593        
    594         if (!dvodb) {  // there's no skycalRun.dvodb
    595           psError(PS_ERR_UNKNOWN, false, "cannot queue addstar run without a defined dvodb: label: %s, diff_id %" PRId64, row->label, row->diff_id);
    596           psFree(output);
    597           return false;
     588          psError(PS_ERR_UNKNOWN, false, "failed to convert metadata into diffRun");
     589          psFree(output);
     590          return false;
     591        }
     592       
     593        if (!dvodb) {  // there's no skycalRun.dvodb
     594           psError(PS_ERR_UNKNOWN, false, "cannot queue addstar run without a defined dvodb: label: %s, diff_id %" PRId64, row->label, row->diff_id);
     595          psFree(output);
     596          return false;
    598597        }
    599598        if (!workdir && !row->workdir) {
    600           psError(PS_ERR_UNKNOWN, false, "cannot queue addstar run without a defined workdir: label: %s, diff_id %" PRId64, row->label, row->diff_id);
    601           psFree(output);
    602           return false;
    603         }
    604        
     599          psError(PS_ERR_UNKNOWN, false, "cannot queue addstar run without a defined workdir: label: %s, diff_id %" PRId64, row->label, row->diff_id);
     600          psFree(output);
     601          return false;
     602        }
     603       
    605604        psFree(row);
    606605      }
     
    609608      for (long i = 0; i < psArrayLength(output); i++) {
    610609        psMetadata *md = output->data[i];
    611        
     610       
    612611        fullForceRunRow *row = fullForceRunObjectFromMetadata(md);
    613        
     612       
    614613        if (!row) {
    615           psError(PS_ERR_UNKNOWN, false, "failed to convert metadata into fullforceRun");
    616           psFree(output);
    617           return false;
    618         }
    619 
    620         if (!dvodb) {  // there's no skycalRun.dvodb
    621           psError(PS_ERR_UNKNOWN, false, "cannot queue addstar run without a defined dvodb: label: %s, ff_id %" PRId64, row->label, row->ff_id);
    622           psFree(output);
    623           return false;
     614          psError(PS_ERR_UNKNOWN, false, "failed to convert metadata into fullforceRun");
     615          psFree(output);
     616          return false;
     617        }
     618
     619        if (!dvodb) {  // there's no skycalRun.dvodb
     620           psError(PS_ERR_UNKNOWN, false, "cannot queue addstar run without a defined dvodb: label: %s, ff_id %" PRId64, row->label, row->ff_id);
     621          psFree(output);
     622          return false;
    624623        }
    625624        if (!workdir && !row->workdir) {
    626           psError(PS_ERR_UNKNOWN, false, "cannot queue addstar run without a defined workdir: label: %s, ff_id %" PRId64, row->label, row->ff_id);
    627           psFree(output);
    628           return false;
    629         }
    630        
     625          psError(PS_ERR_UNKNOWN, false, "cannot queue addstar run without a defined workdir: label: %s, ff_id %" PRId64, row->label, row->ff_id);
     626          psFree(output);
     627          return false;
     628        }
     629       
    631630        psFree(row);
    632631      }
     
    635634      for (long i = 0; i < psArrayLength(output); i++) {
    636635        psMetadata *md = output->data[i];
    637         //i believe this is correct for ff_summary as well:
     636        //i believe this is correct for ff_summary as well:
    638637        fullForceRunRow *row = fullForceRunObjectFromMetadata(md);
    639        
     638       
    640639        if (!row) {
    641           psError(PS_ERR_UNKNOWN, false, "failed to convert metadata into fullforceRun");
    642           psFree(output);
    643           return false;
    644         }
    645        
    646         if (!dvodb) {  // there's no skycalRun.dvodb
    647           psError(PS_ERR_UNKNOWN, false, "cannot queue addstar run without a defined dvodb: label: %s, ff_id %" PRId64, row->label, row->ff_id);
    648           psFree(output);
    649           return false;
     640          psError(PS_ERR_UNKNOWN, false, "failed to convert metadata into fullforceRun");
     641          psFree(output);
     642          return false;
     643        }
     644       
     645        if (!dvodb) {  // there's no skycalRun.dvodb
     646           psError(PS_ERR_UNKNOWN, false, "cannot queue addstar run without a defined dvodb: label: %s, ff_id %" PRId64, row->label, row->ff_id);
     647          psFree(output);
     648          return false;
    650649        }
    651650        if (!workdir && !row->workdir) {
    652           psError(PS_ERR_UNKNOWN, false, "cannot queue addstar run without a defined workdir: label: %s, ff_id %" PRId64, row->label, row->ff_id);
    653           psFree(output);
    654           return false;
    655         }
    656        
     651          psError(PS_ERR_UNKNOWN, false, "cannot queue addstar run without a defined workdir: label: %s, ff_id %" PRId64, row->label, row->ff_id);
     652          psFree(output);
     653          return false;
     654        }
     655       
    657656        psFree(row);
    658657      }
     
    678677      for (long i = 0; i < psArrayLength(output); i++) {
    679678        psMetadata *md = output->data[i];
    680         psS64 stage_id =0;
    681        
    682         camRunRow *row = camRunObjectFromMetadata(md);
    683         stage_id = row->cam_id;
    684        
     679        psS64 stage_id =0;
     680       
     681        camRunRow *row = camRunObjectFromMetadata(md);
     682        stage_id = row->cam_id;
     683       
    685684        if (!row) {
    686           psError(PS_ERR_UNKNOWN, false, "failed to convert metadata into camRun");
    687           psFree(output);
    688           return false;
    689         }
    690        
     685          psError(PS_ERR_UNKNOWN, false, "failed to convert metadata into camRun");
     686          psFree(output);
     687          return false;
     688        }
     689       
    691690        // queue the exp
    692691        if (!pxaddQueueByCamID(config,
    693                                stage,
     692                               stage,
    694693                               stage_id,
    695                                0,
     694                               0,
    696695                               workdir     ? workdir   : row->workdir,
    697696                               reduction   ? reduction : row->reduction,
     
    703702                               minidvodb,
    704703                               minidvodb_group,
    705                                minidvodb_name
    706                                )) {
    707           if (!psDBRollback(config->dbh)) {
    708             psError(PS_ERR_UNKNOWN, false, "database error sfg");
    709           }
    710           psError(PS_ERR_UNKNOWN, false,
    711                   "failed to trying to queue stage %s %" PRId64,stage, stage_id);
    712           psFree(row);
    713           psFree(output);
    714           return false;
     704                               minidvodb_name,
     705                               minidvodb_host
     706                               )) {
     707          if (!psDBRollback(config->dbh)) {
     708            psError(PS_ERR_UNKNOWN, false, "database error sfg");
     709          }
     710          psError(PS_ERR_UNKNOWN, false,
     711                  "failed to trying to queue stage %s %" PRId64,stage, stage_id);
     712          psFree(row);
     713          psFree(output);
     714          return false;
    715715        }
    716716        psFree(row);
     
    720720      for (long i = 0; i < psArrayLength(output); i++) {
    721721        psMetadata *md = output->data[i];
    722         psS64 stage_id =0;
    723        
    724         stackRunRow *row = stackRunObjectFromMetadata(md);
    725         stage_id = row->stack_id;
    726        
     722        psS64 stage_id =0;
     723       
     724        stackRunRow *row = stackRunObjectFromMetadata(md);
     725        stage_id = row->stack_id;
     726       
    727727        if (!row) {
    728           psError(PS_ERR_UNKNOWN, false, "failed to convert metadata into camRun");
    729           psFree(output);
    730           return false;
    731         }
    732        
     728          psError(PS_ERR_UNKNOWN, false, "failed to convert metadata into camRun");
     729          psFree(output);
     730          return false;
     731        }
     732       
    733733        // queue the exp
    734734        if (!pxaddQueueByCamID(config,
    735                                stage,
     735                               stage,
    736736                               stage_id,
    737                                0,
     737                               0,
    738738                               workdir     ? workdir   : row->workdir,
    739739                               reduction   ? reduction : row->reduction,
     
    745745                               minidvodb,
    746746                               minidvodb_group,
    747                                minidvodb_name
    748                                )) {
    749           if (!psDBRollback(config->dbh)) {
    750             psError(PS_ERR_UNKNOWN, false, "database error sfg");
    751           }
    752           psError(PS_ERR_UNKNOWN, false,
    753                   "failed to trying to queue stage %s %" PRId64,stage, stage_id);
    754           psFree(row);
    755           psFree(output);
    756           return false;
     747                               minidvodb_name,
     748                               minidvodb_host
     749                               )) {
     750          if (!psDBRollback(config->dbh)) {
     751            psError(PS_ERR_UNKNOWN, false, "database error sfg");
     752          }
     753          psError(PS_ERR_UNKNOWN, false,
     754                  "failed to trying to queue stage %s %" PRId64,stage, stage_id);
     755          psFree(row);
     756          psFree(output);
     757          return false;
    757758        }
    758759        psFree(row);
     
    762763      for (long i = 0; i < psArrayLength(output); i++) {
    763764        psMetadata *md = output->data[i];
    764         psS64 stage_id =0;
    765         bool status = false;
    766         //psS32 num_inputs = psMetadataLookupS32(&status, md, "num_inputs");
    767         psS32 stack_id = psMetadataLookupS32(&status, md, "stack_id");
    768        
    769         if (!status) {
    770           psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item stack_id");
    771           return false;
    772         }
    773         staticskyRunRow *row = staticskyRunObjectFromMetadata(md);
    774         stage_id = row->sky_id;
    775        
     765        psS64 stage_id =0;
     766        bool status = false;
     767        //psS32 num_inputs = psMetadataLookupS32(&status, md, "num_inputs");
     768        psS32 stack_id = psMetadataLookupS32(&status, md, "stack_id");
     769       
     770        if (!status) {
     771          psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item stack_id");
     772          return false;
     773        }
     774        staticskyRunRow *row = staticskyRunObjectFromMetadata(md);
     775        stage_id = row->sky_id;
     776       
    776777        if (!row) {
    777           psError(PS_ERR_UNKNOWN, false, "failed to convert metadata into camRun");
    778           psFree(output);
    779           return false;
    780         }
    781        
     778          psError(PS_ERR_UNKNOWN, false, "failed to convert metadata into camRun");
     779          psFree(output);
     780          return false;
     781        }
     782       
    782783        // queue the exp
    783         //for (int filter_id = 0; filter_id < num_inputs; filter_id++) { 
    784         if (!pxaddQueueByCamID(config,
    785                                stage,
    786                                stage_id,
    787                                stack_id,
     784              //for (int filter_id = 0; filter_id < num_inputs; filter_id++) { 
     785        if (!pxaddQueueByCamID(config,
     786                               stage,
     787                               stage_id,
     788                               stack_id,
    788789                               workdir     ? workdir   : row->workdir,
    789790                               reduction   ? reduction : row->reduction,
     
    795796                               minidvodb,
    796797                               minidvodb_group,
    797                                minidvodb_name
    798                                )) {
    799           if (!psDBRollback(config->dbh)) {
    800             psError(PS_ERR_UNKNOWN, false, "database error sfg");
    801           }
    802           psError(PS_ERR_UNKNOWN, false,
    803                   "failed to trying to queue stage %s %" PRId64,stage, stage_id);
    804           psFree(row);
    805           psFree(output);
    806           return false;
    807         }
    808         //}
     798                               minidvodb_name,
     799                               minidvodb_host
     800                               )) {
     801          if (!psDBRollback(config->dbh)) {
     802            psError(PS_ERR_UNKNOWN, false, "database error sfg");
     803          }
     804          psError(PS_ERR_UNKNOWN, false,
     805                  "failed to trying to queue stage %s %" PRId64,stage, stage_id);
     806          psFree(row);
     807          psFree(output);
     808          return false;
     809        }
     810        //}
    809811        psFree(row);
    810812      }
     
    813815      for (long i = 0; i < psArrayLength(output); i++) {
    814816        psMetadata *md = output->data[i];
    815         psS64 stage_id =0;
    816        
    817         skycalRunRow *row = skycalRunObjectFromMetadata(md);
    818         stage_id = row->skycal_id;
    819        
     817        psS64 stage_id =0;
     818       
     819        skycalRunRow *row = skycalRunObjectFromMetadata(md);
     820        stage_id = row->skycal_id;
     821       
    820822        if (!row) {
    821           psError(PS_ERR_UNKNOWN, false, "failed to convert metadata into skycalRun");
    822           psFree(output);
    823           return false;
    824         }
    825        
     823          psError(PS_ERR_UNKNOWN, false, "failed to convert metadata into skycalRun");
     824          psFree(output);
     825          return false;
     826        }
     827       
    826828        // queue the exp
    827829        if (!pxaddQueueByCamID(config,
    828                                stage,
     830                               stage,
    829831                               stage_id,
    830                                0,
     832                               0,
    831833                               workdir     ? workdir   : row->workdir,
    832834                               reduction   ? reduction : row->reduction,
     
    838840                               minidvodb,
    839841                               minidvodb_group,
    840                                minidvodb_name
    841                                )) {
    842           if (!psDBRollback(config->dbh)) {
    843             psError(PS_ERR_UNKNOWN, false, "database error sfg");
    844           }
    845           psError(PS_ERR_UNKNOWN, false,
    846                   "failed to trying to queue stage %s %" PRId64,stage, stage_id);
    847           psFree(row);
    848           psFree(output);
    849           return false;
     842                               minidvodb_name,
     843                               minidvodb_host
     844                               )) {
     845          if (!psDBRollback(config->dbh)) {
     846            psError(PS_ERR_UNKNOWN, false, "database error sfg");
     847          }
     848          psError(PS_ERR_UNKNOWN, false,
     849                  "failed to trying to queue stage %s %" PRId64,stage, stage_id);
     850          psFree(row);
     851          psFree(output);
     852          return false;
    850853        }
    851854        psFree(row);
     
    855858      for (long i = 0; i < psArrayLength(output); i++) {
    856859        psMetadata *md = output->data[i];
    857         psS64 stage_id =0;
    858         //      psS64 stage_extra1 = 0;
    859         diffRunRow *row = diffRunObjectFromMetadata(md);
    860         stage_id = row->diff_id;
    861         bool status = false;
    862         psS32 stage_extra1 = psMetadataLookupS32(&status, md, "diff_skyfile_id");
    863         if (!status) {
    864           psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item diff_skyfile_id");
    865           return false;
    866         }
    867        
     860        psS64 stage_id =0;
     861        //        psS64 stage_extra1 = 0;
     862        diffRunRow *row = diffRunObjectFromMetadata(md);
     863        stage_id = row->diff_id;
     864        bool status = false;
     865        psS32 stage_extra1 = psMetadataLookupS32(&status, md, "diff_skyfile_id");
     866        if (!status) {
     867          psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item diff_skyfile_id");
     868          return false;
     869        }
     870       
    868871        if (!row) {
    869           psError(PS_ERR_UNKNOWN, false, "failed to convert metadata into skycalRun");
    870           psFree(output);
    871           return false;
    872         }
    873        
     872          psError(PS_ERR_UNKNOWN, false, "failed to convert metadata into skycalRun");
     873          psFree(output);
     874          return false;
     875        }
     876       
    874877        // queue the exp
    875878        if (!pxaddQueueByCamID(config,
    876                                stage,
     879                               stage,
    877880                               stage_id,
    878                                stage_extra1,
     881                               stage_extra1,
    879882                               workdir     ? workdir   : row->workdir,
    880883                               reduction   ? reduction : row->reduction,
     
    886889                               minidvodb,
    887890                               minidvodb_group,
    888                                minidvodb_name
    889                                )) {
    890           if (!psDBRollback(config->dbh)) {
    891             psError(PS_ERR_UNKNOWN, false, "database error sfg");
    892           }
    893           psError(PS_ERR_UNKNOWN, false,
    894                   "failed to trying to queue stage %s %" PRId64,stage, stage_id);
    895           psFree(row);
    896           psFree(output);
    897           return false;
     891                               minidvodb_name,
     892                               minidvodb_host
     893                               )) {
     894          if (!psDBRollback(config->dbh)) {
     895            psError(PS_ERR_UNKNOWN, false, "database error sfg");
     896          }
     897          psError(PS_ERR_UNKNOWN, false,
     898                  "failed to trying to queue stage %s %" PRId64,stage, stage_id);
     899          psFree(row);
     900          psFree(output);
     901          return false;
    898902        }
    899903        psFree(row);
     
    903907      for (long i = 0; i < psArrayLength(output); i++) {
    904908        psMetadata *md = output->data[i];
    905         psS64 stage_id =0;
    906        
    907         fullForceRunRow *row = fullForceRunObjectFromMetadata(md);
    908         stage_id = row->ff_id;
    909         bool status = false;
    910         psS32 stage_extra1 = psMetadataLookupS32(&status, md, "warp_id");
    911         if (!status) {
    912           psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item warp_id");
    913           return false;
    914         }
    915        
     909        psS64 stage_id =0;
     910       
     911        fullForceRunRow *row = fullForceRunObjectFromMetadata(md);
     912        stage_id = row->ff_id;
     913        bool status = false;
     914        psS32 stage_extra1 = psMetadataLookupS32(&status, md, "warp_id");
     915        if (!status) {
     916          psError(PS_ERR_UNKNOWN, true, "failed to lookup value for item warp_id");
     917          return false;
     918        }
     919       
    916920        if (!row) {
    917           psError(PS_ERR_UNKNOWN, false, "failed to convert metadata into skycalRun");
    918           psFree(output);
    919           return false;
    920         }
    921        
     921          psError(PS_ERR_UNKNOWN, false, "failed to convert metadata into skycalRun");
     922          psFree(output);
     923          return false;
     924        }
     925       
    922926        // queue the exp
    923927        if (!pxaddQueueByCamID(config,
    924                                stage,
     928                               stage,
    925929                               stage_id,
    926                                stage_extra1,
     930                               stage_extra1,
    927931                               workdir     ? workdir   : row->workdir,
    928932                               reduction   ? reduction : row->reduction,
     
    934938                               minidvodb,
    935939                               minidvodb_group,
    936                                minidvodb_name
    937                                )) {
    938           if (!psDBRollback(config->dbh)) {
    939             psError(PS_ERR_UNKNOWN, false, "database error sfg");
    940           }
    941           psError(PS_ERR_UNKNOWN, false,
    942                   "failed to trying to queue stage %s %" PRId64,stage, stage_id);
    943           psFree(row);
    944           psFree(output);
    945           return false;
     940                               minidvodb_name,
     941                               minidvodb_host
     942                               )) {
     943          if (!psDBRollback(config->dbh)) {
     944            psError(PS_ERR_UNKNOWN, false, "database error sfg");
     945          }
     946          psError(PS_ERR_UNKNOWN, false,
     947                  "failed to trying to queue stage %s %" PRId64,stage, stage_id);
     948          psFree(row);
     949          psFree(output);
     950          return false;
    946951        }
    947952        psFree(row);
     
    951956      for (long i = 0; i < psArrayLength(output); i++) {
    952957        psMetadata *md = output->data[i];
    953         psS64 stage_id =0;
    954        
    955         fullForceRunRow *row = fullForceRunObjectFromMetadata(md);
    956         stage_id = row->ff_id;
    957        
     958        psS64 stage_id =0;
     959       
     960        fullForceRunRow *row = fullForceRunObjectFromMetadata(md);
     961        stage_id = row->ff_id;
     962       
    958963        if (!row) {
    959           psError(PS_ERR_UNKNOWN, false, "failed to convert metadata into fullforceRun");
    960           psFree(output);
    961           return false;
    962         }
    963        
     964          psError(PS_ERR_UNKNOWN, false, "failed to convert metadata into fullforceRun");
     965          psFree(output);
     966          return false;
     967        }
     968       
    964969        // queue the exp
    965970        if (!pxaddQueueByCamID(config,
    966                                stage,
     971                               stage,
    967972                               stage_id,
    968                                0,
     973                               0,
    969974                               workdir     ? workdir   : row->workdir,
    970975                               reduction   ? reduction : row->reduction,
     
    976981                               minidvodb,
    977982                               minidvodb_group,
    978                                minidvodb_name
    979                                )) {
    980           if (!psDBRollback(config->dbh)) {
    981             psError(PS_ERR_UNKNOWN, false, "database error sfg");
    982           }
    983           psError(PS_ERR_UNKNOWN, false,
    984                   "failed to trying to queue stage %s %" PRId64,stage, stage_id);
    985           psFree(row);
    986           psFree(output);
    987           return false;
     983                               minidvodb_name,
     984                               minidvodb_host
     985                               )) {
     986          if (!psDBRollback(config->dbh)) {
     987            psError(PS_ERR_UNKNOWN, false, "database error sfg");
     988          }
     989          psError(PS_ERR_UNKNOWN, false,
     990                  "failed to trying to queue stage %s %" PRId64,stage, stage_id);
     991          psFree(row);
     992          psFree(output);
     993          return false;
    988994        }
    989995        psFree(row);
     
    10061012
    10071013    psMetadata *where = psMetadataAlloc();
    1008     PXOPT_COPY_S64(config->args, where, "-add_id",    "addRun.add_id", "==");
    1009     PXOPT_COPY_S64(config->args, where, "-cam_id",    "camRun.cam_id", "==");
    1010     PXOPT_COPY_S64(config->args, where, "-stack_id",    "stackRun.stack_id", "==");
     1014    PXOPT_COPY_S64(config->args, where, "-add_id",    "addRun.add_id",       "==");
     1015    PXOPT_COPY_S64(config->args, where, "-cam_id",    "camRun.cam_id",       "==");
     1016    PXOPT_COPY_S64(config->args, where, "-stack_id",  "stackRun.stack_id",  "==");
    10111017    PXOPT_COPY_S64(config->args, where, "-sky_id",    "staticskyRun.sky_id", "==");
    10121018    PXOPT_COPY_S64(config->args, where, "-skycal_id", "skycalRun.skycal_id", "==");
    1013     PXOPT_COPY_S64(config->args, where, "-diff_id", "diffRun.diff_id", "==");
    1014     PXOPT_COPY_S64(config->args, where, "-ff_id", "fullForceRun.ff_id", "==");
     1019    PXOPT_COPY_S64(config->args, where, "-diff_id",   "diffRun.diff_id",    "==");
     1020    PXOPT_COPY_S64(config->args, where, "-ff_id",     "fullForceRun.ff_id", "==");
    10151021
    10161022    PXOPT_LOOKUP_STR(stage,       config->args, "-stage", false, false);
    10171023    pxcamGetSearchArgs (config, where); // most search arguments based on camera
    1018     PXOPT_COPY_STR(config->args, where, "-label",     "addRun.label", "==");
    1019     PXOPT_COPY_STR(config->args, where, "-state",     "addRun.state", "==");
     1024    PXOPT_COPY_STR(config->args, where, "-label",     "addRun.label",     "==");
     1025    PXOPT_COPY_STR(config->args, where, "-state",     "addRun.state",     "==");
    10201026    PXOPT_COPY_STR(config->args, where, "-reduction", "addRun.reduction", "==");
    1021     PXOPT_COPY_STR(config->args, where, "-dvodb", "addRun.dvodb", "==");
     1027    PXOPT_COPY_STR(config->args, where, "-dvodb",     "addRun.dvodb",    "==");
    10221028
    10231029    if (!psListLength(where->list)) {
     
    11351141      //this group by is needed to join against all the warps (to get camera)
    11361142      if (multiadd) {
    1137         psStringAppend(&query, " GROUP BY %s", "diff_id");
     1143        psStringAppend(&query, " GROUP BY %s", "diff_id");
    11381144      } else {
    1139         psStringAppend(&query, " GROUP BY %s", "diff_id, stage_extra1");
     1145        psStringAppend(&query, " GROUP BY %s", "diff_id, stage_extra1");
    11401146      }
    11411147    }
     
    11431149      //this group by is needed to join against all the warps (to get camera)
    11441150      if (multiadd) {
    1145         psStringAppend(&query, "GROUP BY %s", "ff_id");
     1151        psStringAppend(&query, "GROUP BY %s", "ff_id");
    11461152      } else {
    1147         psStringAppend(&query, " GROUP BY %s", "ff_id, stage_extra1");
     1153        psStringAppend(&query, " GROUP BY %s", "ff_id, stage_extra1");
    11481154      }
    11491155    }
     
    11991205   
    12001206    // optional
    1201     PXOPT_LOOKUP_STR(path_base,     config->args, "-path_base", false, false);
    1202     PXOPT_LOOKUP_F32(dtime_addstar, config->args, "-dtime_addstar", false, false);
    1203     PXOPT_LOOKUP_STR(dvodb_path, config->args, "-dvodb_path", false, false);
     1207    PXOPT_LOOKUP_STR(path_base,      config->args, "-path_base",      false, false);
     1208    PXOPT_LOOKUP_F32(dtime_addstar,  config->args, "-dtime_addstar", false, false);
     1209    PXOPT_LOOKUP_STR(dvodb_path,     config->args, "-dvodb_path",    false, false);
    12041210    PXOPT_LOOKUP_STR(minidvodb_name, config->args, "-minidvodb_name", false, false);
    1205     PXOPT_LOOKUP_S16(fault,         config->args, "-fault", false, false);
    1206     PXOPT_LOOKUP_S64(stage_extra1, config->args, "-stage_extra1", false, false);
    1207    
    1208     PXOPT_LOOKUP_BOOL(multiadd, config->args, "-multiadd", false);
     1211    PXOPT_LOOKUP_STR(minidvodb_host, config->args, "-minidvodb_host", false, false);
     1212    PXOPT_LOOKUP_S16(fault,          config->args, "-fault",          false, false);
     1213    PXOPT_LOOKUP_S64(stage_extra1,   config->args, "-stage_extra1",   false, false);
     1214
     1215    PXOPT_LOOKUP_BOOL(multiadd,      config->args, "-multiadd",              false);
    12091216    // generate restrictions
    12101217    psMetadata *where = psMetadataAlloc();
     
    12471254      PXOPT_LOOKUP_STR(stage_extra1_list, config->args, "-stage_extra1_list", false, false);
    12481255      if (stage_extra1_list) {
    1249         psStringAppend(&query, " AND stage_extra1 IN (%s)", stage_extra1_list);
     1256        psStringAppend(&query, " AND stage_extra1 IN (%s)", stage_extra1_list);
    12501257      }
    12511258    }
     
    12861293     
    12871294      addProcessedExpRow *row = addProcessedExpRowAlloc(
    1288                                                         pendingRow->add_id,
    1289                                                         dtime_addstar,
    1290                                                         path_base,
    1291                                                         dvodb_path,
    1292                                                         fault
    1293                                                         );
     1295                                                        pendingRow->add_id,
     1296                                                        dtime_addstar,
     1297                                                        path_base,
     1298                                                        dvodb_path,
     1299                                                        fault
     1300                                                        );
    12941301     
    12951302      if (!addProcessedExpInsertObject(config->dbh, row)) {
    12961303        // rollback
    12971304        if (!psDBRollback(config->dbh)) {
    1298           psError(PS_ERR_UNKNOWN, false, "database error");
     1305          psError(PS_ERR_UNKNOWN, false, "database error");
    12991306        }
    13001307        psError(PS_ERR_UNKNOWN, false, "database error");
     
    13061313      //if there is a minidvodb_name, set it in addRun (it's not known until it is processed)
    13071314      if (minidvodb_name) {
    1308         psString setName = NULL;
    1309         psStringAppend (&setName, "UPDATE addRun set minidvodb_name = '%s' where add_id = %" PRId64, minidvodb_name, row->add_id);
    1310         if (!p_psDBRunQuery(config->dbh, setName)) {
    1311           if (!psDBRollback(config->dbh)) {
    1312             psError(PS_ERR_UNKNOWN, false, "database error");
    1313           }
    1314           psError(PS_ERR_UNKNOWN, false, "database error");
    1315          
    1316           return false;
    1317         }
    1318       }
     1315        psString setName = NULL;
     1316        psStringAppend (&setName, "UPDATE addRun set minidvodb_name = '%s' where add_id = %" PRId64, minidvodb_name, row->add_id);
     1317        if (!p_psDBRunQuery(config->dbh, setName)) {
     1318          if (!psDBRollback(config->dbh)) {
     1319            psError(PS_ERR_UNKNOWN, false, "database error");
     1320          }
     1321          psError(PS_ERR_UNKNOWN, false, "database error");
     1322         
     1323          return false;
     1324        }
     1325      }
     1326
     1327      //if there is a minidvodb_host, set it in addRun (it's not known until it is processed)
     1328      if (minidvodb_host) {
     1329        psString setName = NULL;
     1330        psStringAppend (&setName, "UPDATE addRun set minidvodb_host = '%s' where add_id = %" PRId64, minidvodb_host, row->add_id);
     1331        if (!p_psDBRunQuery(config->dbh, setName)) {
     1332          if (!psDBRollback(config->dbh)) {
     1333            psError(PS_ERR_UNKNOWN, false, "database error");
     1334          }
     1335          psError(PS_ERR_UNKNOWN, false, "database error");
     1336         
     1337          return false;
     1338        }
     1339      }
     1340
    13191341      //if there is a stage_extra1, set it in addRun (it's not known until it is processed)
    13201342      if (stage_extra1) {
    1321         psString setExtra = NULL;
    1322         psStringAppend (&setExtra, "UPDATE addRun set stage_extra1 = %" PRId64, stage_extra1);
    1323         psStringAppend (&setExtra, " where add_id = %" PRId64, row->add_id);
    1324        
    1325         if (!p_psDBRunQuery(config->dbh, setExtra)) {
    1326           if (!psDBRollback(config->dbh)) {
    1327             psError(PS_ERR_UNKNOWN, false, "database error");
    1328           }
    1329           psError(PS_ERR_UNKNOWN, false, "database error");
    1330          
    1331           return false;
    1332         }
    1333       }
    1334      
    1335      
    1336      
     1343        psString setExtra = NULL;
     1344        psStringAppend (&setExtra, "UPDATE addRun set stage_extra1 = %" PRId64, stage_extra1);
     1345        psStringAppend (&setExtra, " where add_id = %" PRId64, row->add_id);
     1346       
     1347        if (!p_psDBRunQuery(config->dbh, setExtra)) {
     1348          if (!psDBRollback(config->dbh)) {
     1349            psError(PS_ERR_UNKNOWN, false, "database error");
     1350          }
     1351          psError(PS_ERR_UNKNOWN, false, "database error");
     1352         
     1353          return false;
     1354        }
     1355      }
    13371356     
    13381357      // since there is only one exp per 'new' set addRun.state = 'full'
     
    13401359     
    13411360      if (!fault) {
    1342         if (!pxaddRunSetState(config, row->add_id, "full")) {
    1343           psError(PS_ERR_UNKNOWN, false, "failed to change addRun.state for add_id: %" PRId64, row->add_id);
    1344           psFree(row);
    1345           psFree(pendingRow);
    1346           return false;
    1347         }
     1361        if (!pxaddRunSetState(config, row->add_id, "full")) {
     1362          psError(PS_ERR_UNKNOWN, false, "failed to change addRun.state for add_id: %" PRId64, row->add_id);
     1363          psFree(row);
     1364          psFree(pendingRow);
     1365          return false;
     1366        }
    13481367      }
    13491368      psFree(row);
     
    15061525      psString query = NULL;
    15071526      if (strcmp(stage, "cam") == 0) {
    1508         query = pxDataGet("addtool_revertprocessedexp_cam.sql");
     1527        query = pxDataGet("addtool_revertprocessedexp_cam.sql");
    15091528      }
    15101529      else if (strcmp(stage, "stack") == 0) {
    1511         query = pxDataGet("addtool_revertprocessedexp_stack.sql");
     1530        query = pxDataGet("addtool_revertprocessedexp_stack.sql");
    15121531      }
    15131532      else if (strcmp(stage, "staticsky") == 0) {
    1514         query = pxDataGet("addtool_revertprocessedexp_staticsky_multi.sql");
     1533        query = pxDataGet("addtool_revertprocessedexp_staticsky_multi.sql");
    15151534      }
    15161535      else if (strcmp(stage, "skycal") == 0) {
    1517         query = pxDataGet("addtool_revertprocessedexp_skycal.sql");
     1536        query = pxDataGet("addtool_revertprocessedexp_skycal.sql");
    15181537      }
    15191538      else if (strcmp(stage, "diff") == 0) {
    1520         query = pxDataGet("addtool_revertprocessedexp_diff.sql");
     1539        query = pxDataGet("addtool_revertprocessedexp_diff.sql");
    15211540      }
    15221541      else if (strcmp(stage, "fullforce") == 0) {
    1523         query = pxDataGet("addtool_revertprocessedexp_ff.sql");
     1542        query = pxDataGet("addtool_revertprocessedexp_ff.sql");
    15241543      }
    15251544      else if (strcmp(stage, "fullforce_summary") == 0) {
    1526         query = pxDataGet("addtool_revertprocessedexp_ffsummary.sql");
     1545        query = pxDataGet("addtool_revertprocessedexp_ffsummary.sql");
    15271546      }
    15281547     
    15291548      if (!query) {
    1530         // rollback
    1531         if (!psDBRollback(config->dbh)) {
    1532           psError(PS_ERR_UNKNOWN, false, "database error");
    1533         }
    1534         psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement");
    1535         psFree(where);
    1536         return false;
     1549        // rollback
     1550        if (!psDBRollback(config->dbh)) {
     1551          psError(PS_ERR_UNKNOWN, false, "database error");
     1552        }
     1553        psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement");
     1554        psFree(where);
     1555        return false;
    15371556      }
    15381557     
    15391558      // use psDBGenerateWhereConditionalSQL with AND ... because the SQL ends in a WHERE
    15401559      if (where && psListLength(where->list)) {
    1541         psString whereClause = psDBGenerateWhereConditionSQL(where, NULL);
    1542         psStringAppend(&query, " AND %s", whereClause);
    1543         psFree(whereClause);
     1560        psString whereClause = psDBGenerateWhereConditionSQL(where, NULL);
     1561        psStringAppend(&query, " AND %s", whereClause);
     1562        psFree(whereClause);
    15441563      }
    15451564     
    15461565      if (!p_psDBRunQuery(config->dbh, query)) {
    1547         // rollback
    1548         if (!psDBRollback(config->dbh)) {
    1549           psError(PS_ERR_UNKNOWN, false, "database error");
    1550         }
    1551         psError(PS_ERR_UNKNOWN, false, "database error");
    1552         psFree(query);
    1553         psFree(where);
    1554         return false;
     1566        // rollback
     1567        if (!psDBRollback(config->dbh)) {
     1568          psError(PS_ERR_UNKNOWN, false, "database error");
     1569        }
     1570        psError(PS_ERR_UNKNOWN, false, "database error");
     1571        psFree(query);
     1572        psFree(where);
     1573        return false;
    15551574      }
    15561575      psFree(query);
     
    16631682  // required
    16641683  PXOPT_LOOKUP_STR(minidvodb_group, config->args, "-set_minidvodb_group", true, false);
    1665 
     1684  PXOPT_LOOKUP_STR(minidvodb_path,  config->args, "-set_minidvodb_path",  true, false);
     1685  PXOPT_LOOKUP_STR(minidvodb_host,  config->args, "-set_minidvodb_host",  true, false);
    16661686  //optional
    1667   PXOPT_LOOKUP_STR(minidvodb_name, config->args, "-set_minidvodb_name", false, false);
    1668   PXOPT_LOOKUP_STR(minidvodb_path, config->args, "-set_minidvodb_path", false, false);
    1669   PXOPT_LOOKUP_STR(state, config->args, "-set_state", false, false);
     1687  PXOPT_LOOKUP_STR(minidvodb_name,  config->args, "-set_minidvodb_name", false, false);
     1688  PXOPT_LOOKUP_STR(state,           config->args, "-set_state",          false, false);
     1689  PXOPT_LOOKUP_STR(note,            config->args, "-set_note",            false, false);
    16701690 
    1671 
    16721691  if (!psDBTransaction(config->dbh)) {
    16731692    psError(PS_ERR_UNKNOWN, false, "database error");
     
    16751694  }
    16761695
    1677   psString minidvodbpath = "NULL";
     1696//  psString minidvodbpath = "NULL";
    16781697
    16791698  // I don't know how to get around the complaints of minidvodb_path can't be null. this 'fixes' it, but someone smarter can fix it properly.
    1680   if (minidvodb_path) {
    1681     minidvodbpath = minidvodb_path;
    1682   } else {
    1683     psError(PS_ERR_UNKNOWN, false, "require minidvodb_path");
    1684     return false;
    1685   }
     1699//  if (minidvodb_path) {
     1700//    minidvodbpath = minidvodb_path;
     1701//  } else {
     1702//    psError(PS_ERR_UNKNOWN, false, "require minidvodb_path");
     1703//    return false;
     1704//  }
    16861705 
    16871706  if (!minidvodbRunInsert(config->dbh,
    1688                           0, // job_id
    1689                           minidvodb_name,
    1690                           minidvodb_group,
    1691                           minidvodbpath,
    1692                           "new",
    1693                           0
    1694                           )) {
     1707                          0, // job_id
     1708                          minidvodb_name,
     1709                          minidvodb_group,
     1710                          minidvodb_path,
     1711                          minidvodb_host,
     1712                          "new",
     1713                          note,
     1714                          0
     1715                          )) {
    16951716    psError(PS_ERR_UNKNOWN, false, "database error");
    16961717    return false;
     
    17461767    PXOPT_LOOKUP_STR(minidvodb_name,  config->args, "-set_minidvodb_name", false, false);
    17471768    PXOPT_LOOKUP_STR(minidvodb_path,  config->args, "-set_minidvodb_path", false, false);
     1769    PXOPT_LOOKUP_STR(minidvodb_host,  config->args, "-set_minidvodb_host", false, false);
    17481770    PXOPT_LOOKUP_STR(state,  config->args, "-set_state", false, false);
    17491771    PXOPT_LOOKUP_STR(minidvodb_group,  config->args, "-set_minidvodb_group", false, false);
     
    17661788    if (minidvodb_path) {
    17671789      if (cnt) {
    1768         psStringAppend(&query, "%s", comma);
     1790        psStringAppend(&query, "%s", comma);
    17691791      }
    17701792     
    17711793      psStringAppend(&query, " minidvodb_path = '%s'", minidvodb_path);
     1794      cnt++;
     1795    }
     1796
     1797    if (minidvodb_host) {
     1798      if (cnt) {
     1799        psStringAppend(&query, "%s", comma);
     1800      }
     1801     
     1802      psStringAppend(&query, " minidvodb_host = '%s'", minidvodb_host);
    17721803      cnt++;
    17731804    }
     
    21152146  psFree(output);
    21162147  minidvodbProcessedRow *row = minidvodbProcessedRowAlloc(
    2117                                                           pendingRow->minidvodb_id,
    2118                                                           dtime_resort,
    2119                                                           dtime_relphot,
    2120                                                           dtime_script,
    2121                                                           epoch,
    2122                                                           fault
    2123                                                           );
     2148                                                          pendingRow->minidvodb_id,
     2149                                                          dtime_resort,
     2150                                                          dtime_relphot,
     2151                                                          dtime_script,
     2152                                                          epoch,
     2153                                                          fault
     2154                                                          );
    21242155 
    21252156  if (!minidvodbProcessedInsertObject(config->dbh, row)) {
Note: See TracChangeset for help on using the changeset viewer.