IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jan 20, 2008, 3:48:37 PM (18 years ago)
Author:
eugene
Message:

merging changes from JHs end_stage branch (new end_stage field and related features; substantial cleanup via macros)

File:
1 edited

Legend:

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

    r15532 r16170  
    108108
    109109    // required options
    110     bool status = false;
    111     psString mode = psMetadataLookupStr(&status, config->args, "-mode");
    112     if (!status) {
    113         psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -survey_mode");
    114         return false;
    115     }
    116     if (!mode) {
    117         psError(PS_ERR_UNKNOWN, true, "-mode is required");
    118         return false;
    119     }
     110    PXOPT_LOOKUP_STR(mode, config->args, "-mode", true, false);
    120111    // check mode
    121112    if (mode && !isValidMode(config, mode)) {
     
    123114        return false;
    124115    }
    125 
    126     psString workdir = psMetadataLookupStr(&status, config->args, "-workdir");
    127     if (!status) {
    128         psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -workdir");
    129         return false;
    130     }
    131     if (!workdir) {
    132         psError(PS_ERR_UNKNOWN, true, "-workdir is required");
    133         return false;
    134     }
    135 
    136     psTime *registered = NULL;
    137     {
    138         psString registeredStr = psMetadataLookupStr(&status, config->args, "-registered");
    139         if (!status) {
    140             psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -registered");
    141             return false;
    142         }
    143         // pass through NULL as this is an optional field
    144         if (registeredStr) {
    145             registered = psTimeFromISO(registeredStr, PS_TIME_UTC);
    146         } else {
    147             registered = NULL;
    148         }
    149     }
     116    PXOPT_LOOKUP_STR(workdir, config->args, "-workdir", true, false);
     117
     118    // optional
     119    PXOPT_LOOKUP_STR(dvodb, config->args, "-dvodb", false, false);
     120    PXOPT_LOOKUP_STR(tess_id, config->args, "-tess_id", false, false);
     121    PXOPT_LOOKUP_STR(end_stage, config->args, "-end_stage", false, false);
     122
     123    // default
     124    PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false);
     125    PXOPT_LOOKUP_TIME(registered, config->args, "-registered", false, false);
    150126
    151127    warpRunRow *warpRun = warpRunRowAlloc(
     
    154130            "reg",      // state
    155131            workdir,
    156             NULL,       // dvodb
     132            "dirty",    // workdir_state
     133            dvodb,
     134            tess_id,
     135            end_stage,
    157136            registered
    158137    );
    159     psFree(registered);
    160138    if (!warpRun) {
    161139        psError(PS_ERR_UNKNOWN, false, "failed to alloc warpRun object");
     
    171149    psS64 warp_id = psDBLastInsertID(config->dbh);
    172150    warpRun->warp_id = warp_id;
    173 
    174     bool simple = false;
    175     {
    176         bool status = false;
    177         simple = psMetadataLookupBool(&status, config->args, "-simple");
    178         if (!status) {
    179             psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -simple");
    180             psFree(warpRun);
    181             return false;
    182         }
    183     }
    184151
    185152    if (!warpRunPrintObject(stdout, warpRun, !simple)) {
     
    255222    PS_ASSERT_PTR_NON_NULL(config, false);
    256223
    257     bool status = false;
    258     psString warp_id = psMetadataLookupStr(&status, config->args, "-warp_id");
    259     if (!status) {
    260         psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -warpt_id");
    261         return false;
    262     }
    263     if (!warp_id) {
    264         psError(PS_ERR_UNKNOWN, true, "-warp_id is required");
    265         return false;
    266     }
    267 
    268     psString state = psMetadataLookupStr(&status, config->args, "-state");
    269     if (!status) {
    270         psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -state");
    271         return false;
    272     }
    273     if (!state) {
    274         psError(PS_ERR_UNKNOWN, true, "-state is required");
    275         return false;
    276     }
     224    PXOPT_LOOKUP_STR(warp_id, config->args, "-warp_id", true, false);
     225    PXOPT_LOOKUP_STR(state, config->args, "-state", true, false);
    277226
    278227    if (state) {
     
    289238    PS_ASSERT_PTR_NON_NULL(config, false);
    290239
    291     bool status = false;
    292     psString warp_id = psMetadataLookupStr(&status, config->args, "-warp_id");
    293     if (!status) {
    294         psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -warp_id");
    295         return false;
    296     }
    297     if (!warp_id) {
    298         psError(PS_ERR_UNKNOWN, true, "-warp_id is required");
    299         return false;
    300     }
    301 
    302     psString cam_id = psMetadataLookupStr(&status, config->args, "-cam_id");
    303     if (!status) {
    304         psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -cam_id");
    305         return false;
    306     }
    307     if (!cam_id) {
    308         psError(PS_ERR_UNKNOWN, true, "-cam_id is required");
    309         return false;
    310     }
     240    PXOPT_LOOKUP_STR(warp_id, config->args, "-warp_id", true, false);
     241    PXOPT_LOOKUP_STR(cam_id, config->args, "-cam_id", true, false);
    311242
    312243    // defaults to false
    313     bool magiced = psMetadataLookupBool(&status, config->args, "-magiced");
    314     if (!status) {
    315         psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -magiced");
    316         return false;
    317     }
    318 
    319     // XXX need to validate the warp_id here
    320     // XXX instead of validiting it here we should just use forgein key
    321     // constrants
     244    PXOPT_LOOKUP_BOOL(magiced, config->args, "-magiced", false);
     245
    322246    if (!warpInputExpInsert(config->dbh,
    323247            (psS64)atoll(warp_id),
     
    337261    PS_ASSERT_PTR_NON_NULL(config, false);
    338262
    339     bool status = false;
    340     psU64 limit = psMetadataLookupU64(&status, config->args, "-limit");
    341     if (!status) {
    342         psError(PXTOOLS_ERR_PROG, false, "failed to lookup value for -limit");
    343         return false;
    344     }
     263    PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false);
     264    PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false);
    345265
    346266    // find all rawImfiles matching the default query
     
    391311    }
    392312
    393     bool simple = false;
    394     {
    395         bool status = false;
    396         simple = psMetadataLookupBool(&status, config->args, "-simple");
    397         if (!status) {
    398             psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -simple");
    399             return false;
    400         }
    401     }
    402 
    403313    if (psArrayLength(output)) {
    404314        if (!convertIdToStr(output)) {
     
    426336    PS_ASSERT_PTR_NON_NULL(config, false);
    427337
    428     bool status = false;
    429     psU64 limit = psMetadataLookupU64(&status, config->args, "-limit");
    430     if (!status) {
    431         psError(PXTOOLS_ERR_PROG, false, "failed to lookup value for -limit");
    432         return false;
    433     }
     338    PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false);
     339    PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false);
    434340
    435341    // find all rawImfiles matching the default query
     
    480386    }
    481387
    482     bool simple = false;
    483     {
    484         bool status = false;
    485         simple = psMetadataLookupBool(&status, config->args, "-simple");
    486         if (!status) {
    487             psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -simple");
    488             return false;
    489         }
    490     }
    491 
    492388    if (psArrayLength(output)) {
    493389        if (!convertIdToStr(output)) {
     
    515411    PS_ASSERT_PTR_NON_NULL(config, false);
    516412
    517     bool status = false;
    518     psU64 limit = psMetadataLookupU64(&status, config->args, "-limit");
    519     if (!status) {
    520         psError(PXTOOLS_ERR_PROG, false, "failed to lookup value for -limit");
    521         return false;
    522     }
     413    PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false);
     414    PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false);
    523415
    524416    // find all rawImfiles matching the default query
     
    569461    }
    570462
    571     bool simple = false;
    572     {
    573         bool status = false;
    574         simple = psMetadataLookupBool(&status, config->args, "-simple");
    575         if (!status) {
    576             psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -simple");
    577             return false;
    578         }
    579     }
    580 
    581463    if (psArrayLength(output)) {
    582464        if (!convertIdToStr(output)) {
     
    599481}
    600482
    601 
     483   
    602484static bool addoverlapMode(pxConfig *config)
    603485{
    604486    PS_ASSERT_PTR_NON_NULL(config, false);
    605487
    606     bool status = false;
    607     psString mapfile = psMetadataLookupStr(&status, config->args, "-mapfile");
    608     if (!status) {
    609         psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -mapfile");
    610         return false;
    611     }
    612     if (!mapfile) {
    613         psError(PS_ERR_UNKNOWN, true, "-mapfile is required");
    614         return false;
    615     }
     488    PXOPT_LOOKUP_STR(mapfile, config->args, "-mapfile", false, false);
    616489
    617490    if (!psDBTransaction(config->dbh)) {
     
    703576    PS_ASSERT_PTR_NON_NULL(config, false);
    704577
    705     bool status = false;
    706     psU64 limit = psMetadataLookupU64(&status, config->args, "-limit");
    707     if (!status) {
    708         psError(PXTOOLS_ERR_PROG, false, "failed to lookup value for -limit");
    709         return false;
    710     }
     578    PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false);
     579    PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false);
    711580
    712581    // find all rawImfiles matching the default query
     
    757626    }
    758627
    759     bool simple = false;
    760     {
    761         bool status = false;
    762         simple = psMetadataLookupBool(&status, config->args, "-simple");
    763         if (!status) {
    764             psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -simple");
    765             return false;
    766         }
    767     }
    768 
    769628    if (psArrayLength(output)) {
    770629        if (!convertIdToStr(output)) {
     
    792651    PS_ASSERT_PTR_NON_NULL(config, false);
    793652
    794     bool status = false;
    795     psU64 limit = psMetadataLookupU64(&status, config->args, "-limit");
    796     if (!status) {
    797         psError(PXTOOLS_ERR_PROG, false, "failed to lookup value for -limit");
    798         return false;
    799     }
     653    PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false);
     654    PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false);
    800655
    801656    // find all rawImfiles matching the default query
     
    846701    }
    847702
    848     bool simple = false;
    849     {
    850         bool status = false;
    851         simple = psMetadataLookupBool(&status, config->args, "-simple");
    852         if (!status) {
    853             psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -simple");
    854             return false;
    855         }
    856     }
    857 
    858703    if (psArrayLength(output)) {
    859704        if (!convertIdToStr(output)) {
     
    881726    PS_ASSERT_PTR_NON_NULL(config, false);
    882727
    883     bool status = false;
    884     psString warp_id = psMetadataLookupStr(&status, config->args, "-warp_id");
    885     if (!status) {
    886         psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -warp_id");
    887         return false;
    888     }
    889     if (!warp_id) {
    890         psError(PS_ERR_UNKNOWN, true, "-warp_id is required");
    891         return false;
    892     }
    893 
    894     psString skycell_id = psMetadataLookupStr(&status, config->args, "-skycell_id");
    895     if (!status) {
    896         psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -skycell_id");
    897         return false;
    898     }
    899     if (!skycell_id) {
    900         psError(PS_ERR_UNKNOWN, true, "-skycell_id is required");
    901         return false;
    902     }
    903 
    904     psString tess_id = psMetadataLookupStr(&status, config->args, "-tess_id");
    905     if (!status) {
    906         psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -tess_id");
    907         return false;
    908     }
    909     if (!tess_id) {
    910         psError(PS_ERR_UNKNOWN, true, "-tess_id is required");
    911         return false;
    912     }
    913 
    914     psString uri = psMetadataLookupStr(&status, config->args, "-uri");
    915     if (!status) {
    916         psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -uri");
    917         return false;
    918     }
    919 
    920     psString path_base = psMetadataLookupStr(&status, config->args, "-path_base");
    921     if (!status) {
    922         psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -path_base");
    923         return false;
    924     }
     728    PXOPT_LOOKUP_STR(warp_id, config->args, "-warp_id", true, false);
     729    PXOPT_LOOKUP_STR(skycell_id, config->args, "-skycell_id", true, false);
     730    PXOPT_LOOKUP_STR(tess_id, config->args, "-tess_id", true, false);
    925731
    926732    // optional
    927     psF64 bg = psMetadataLookupF64(&status, config->args, "-bg");
    928     if (!status) {
    929         psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -bg");
    930         return false;
    931     }
    932 
    933     psF64 bg_stdev = psMetadataLookupF64(&status, config->args, "-bg_stdev");
    934     if (!status) {
    935         psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -bg_stdev");
    936         return false;
    937     }
    938 
    939     psF64 good_frac = psMetadataLookupF64(&status, config->args, "-good_frac");
    940     if (!status) {
    941         psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -good_frac");
    942         return false;
    943     }
    944 
    945     bool ignore = psMetadataLookupBool(&status, config->args, "-ignore");
    946     if (!status) {
    947         psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -ignore");
    948         return false;
    949     }
     733    PXOPT_LOOKUP_STR(uri, config->args, "-uri", false, false);
     734    PXOPT_LOOKUP_STR(path_base, config->args, "-path_base", false, false);
     735    PXOPT_LOOKUP_F64(bg, config->args, "-bg", false, false);
     736    PXOPT_LOOKUP_F64(bg_stdev, config->args, "-bg_stdev", false, false);
     737    PXOPT_LOOKUP_F64(good_frac, config->args, "-good_frac", false, false);
     738    PXOPT_LOOKUP_BOOL(ignore, config->args, "-ignore", false);
    950739
    951740    // default values
    952     psS16 code = psMetadataLookupS16(&status, config->args, "-code");
    953     if (!status) {
    954         psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -code");
    955         return false;
    956     }
     741    PXOPT_LOOKUP_S16(code, config->args, "-code", false, false);
    957742
    958743    // we don't want to insert the last skyfile in a run but then not mark the
     
    1071856        "       USING(warp_id)\n"
    1072857        "   LEFT JOIN warpSkyfile\n"
    1073         "       USING(warp_id, skycell_id, tess_id)\n"
     858        "       USING(warp_id, skycell_id)\n"
    1074859        "   WHERE\n"
    1075860        "       warpRun.state = 'run'\n"
     
    1111896    PS_ASSERT_PTR_NON_NULL(config, false);
    1112897
    1113     bool status = false;
    1114     psU64 limit = psMetadataLookupU64(&status, config->args, "-limit");
    1115     if (!status) {
    1116         psError(PXTOOLS_ERR_PROG, false, "failed to lookup value for -limit");
    1117         return false;
    1118     }
     898    PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false);
     899    PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false);
    1119900
    1120901    // find all rawImfiles matching the default query
     
    1165946    }
    1166947
    1167     bool simple = false;
    1168     {
    1169         bool status = false;
    1170         simple = psMetadataLookupBool(&status, config->args, "-simple");
    1171         if (!status) {
    1172             psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -simple");
    1173             return false;
    1174         }
    1175     }
    1176 
    1177948    if (psArrayLength(output)) {
    1178949        if (!convertIdToStr(output)) {
Note: See TracChangeset for help on using the changeset viewer.