IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Feb 13, 2007, 12:20:13 PM (19 years ago)
Author:
jhoblitt
Message:

add p4tool -towarped

File:
1 edited

Legend:

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

    r11774 r11776  
    115115static bool definerunMode(pxConfig *config)
    116116{
    117     PS_ASSERT_PTR_NON_NULL(config, NULL);
     117    PS_ASSERT_PTR_NON_NULL(config, false);
    118118
    119119    // required options
     
    236236static bool addinputexpMode(pxConfig *config)
    237237{
    238     PS_ASSERT_PTR_NON_NULL(config, NULL);
     238    PS_ASSERT_PTR_NON_NULL(config, false);
    239239
    240240    bool status = false;
     
    569569static bool addoverlapMode(pxConfig *config)
    570570{
    571     PS_ASSERT_PTR_NON_NULL(config, NULL);
     571    PS_ASSERT_PTR_NON_NULL(config, false);
    572572
    573573    bool status = false;
     
    668668static bool scmapMode(pxConfig *config)
    669669{
    670     PS_ASSERT_PTR_NON_NULL(config, NULL);
     670    PS_ASSERT_PTR_NON_NULL(config, false);
    671671
    672672    bool status = false;
     
    755755static bool towarpedMode(pxConfig *config)
    756756{
    757     PS_ASSERT_PTR_NON_NULL(config, NULL);
     757    PS_ASSERT_PTR_NON_NULL(config, false);
     758
     759    bool status = false;
     760    psU64 limit = psMetadataLookupU64(&status, config->args, "-limit");
     761    if (!status) {
     762        psError(PXTOOLS_ERR_PROG, false, "failed to lookup value for -limit");
     763        return false;
     764    }
     765
     766    // find all rawImfiles matching the default query
     767    psString query = psStringCopy(
     768        "SELECT\n"
     769        "   p4SkyCellMap.*\n"
     770        " FROM p4Run\n"
     771        " JOIN p4SkyCellMap\n"
     772        "   USING(p4_id)\n"
     773        " LEFT JOIN p4Scfile\n"
     774        "   USING(p4_id, skycell_id, tess_id, exp_tag, p3_version)\n"
     775        " WHERE\n"
     776        "   p4Run.state = 'run'\n"
     777        "   AND p4Scfile.p4_id IS NULL\n"
     778        "   AND p4Scfile.skycell_id IS NULL\n"
     779        "   AND p4Scfile.tess_id IS NULL\n"
     780        "   AND p4Scfile.exp_tag IS NULL\n"
     781        "   AND p4Scfile.p3_version IS NULL\n"
     782    );
     783
     784    if (config->where) {
     785        psString whereClause = psDBGenerateWhereConditionSQL(config->where, "p4SkyCellMap");
     786        psStringAppend(&query, " AND %s", whereClause);
     787        psFree(whereClause);
     788    }
     789
     790    // treat limit == 0 as "no limit"
     791    if (limit) {
     792        psString limitString = psDBGenerateLimitSQL(limit);
     793        psStringAppend(&query, " %s", limitString);
     794        psFree(limitString);
     795    }
     796
     797    if (!p_psDBRunQuery(config->dbh, query)) {
     798        psError(PS_ERR_UNKNOWN, false, "database error");
     799        psFree(query);
     800        return false;
     801    }
     802    psFree(query);
     803
     804    psArray *output = p_psDBFetchResult(config->dbh);
     805    if (!output) {
     806        psErrorCode err = psErrorCodeLast();
     807        switch (err) {
     808            case PS_ERR_DB_CLIENT:
     809                psError(PXTOOLS_ERR_SYS, false, "database error");
     810            case PS_ERR_DB_SERVER:
     811                psError(PXTOOLS_ERR_PROG, false, "database error");
     812            default:
     813                psError(PXTOOLS_ERR_PROG, false, "unknown error");
     814        }
     815
     816        return false;
     817    }
     818    if (!psArrayLength(output)) {
     819        psError(PS_ERR_UNKNOWN, false, "no p4PendingSkyCell rows found");
     820        psFree(output);
     821        return true;
     822    }
     823
     824    bool simple = false;
     825    {
     826        bool status = false;
     827        simple = psMetadataLookupBool(&status, config->args, "-simple");
     828        if (!status) {
     829            psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -simple");
     830            return false;
     831        }
     832    }
     833
     834    if (psArrayLength(output)) {
     835        // negative simple so the default is true
     836        if (!ippdbPrintMetadatas(stdout, output, "p4PendingSkyCell", !simple)) {
     837            psError(PS_ERR_UNKNOWN, false, "failed to print array");
     838            psFree(output);
     839            return false;
     840        }
     841    }
     842
     843    psFree(output);
     844
    758845    return true;
    759846}
     
    762849static bool addwarpedMode(pxConfig *config)
    763850{
    764     PS_ASSERT_PTR_NON_NULL(config, NULL);
     851    PS_ASSERT_PTR_NON_NULL(config, false);
    765852
    766853    bool status = false;
     
    856943static bool warpedMode(pxConfig *config)
    857944{
    858     PS_ASSERT_PTR_NON_NULL(config, NULL);
     945    PS_ASSERT_PTR_NON_NULL(config, false);
    859946
    860947    psString query = psStringCopy(
Note: See TracChangeset for help on using the changeset viewer.