Changeset 28484 for branches/pap/ippTools/src/warptool.c
- Timestamp:
- Jun 24, 2010, 2:59:09 PM (16 years ago)
- Location:
- branches/pap
- Files:
-
- 3 edited
-
. (modified) (1 prop)
-
ippTools/src (modified) (1 prop)
-
ippTools/src/warptool.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/pap
- Property svn:mergeinfo changed
-
branches/pap/ippTools/src
- Property svn:ignore
-
old new 39 39 warptool 40 40 staticskytool 41 42 41 bgtool 42 diffphottool
-
- Property svn:ignore
-
branches/pap/ippTools/src/warptool.c
r28082 r28484 48 48 static bool maskedMode(pxConfig *config); 49 49 static bool unblockMode(pxConfig *config); 50 static bool tosummaryMode(pxConfig *config); 51 static bool addsummaryMode(pxConfig *config); 50 52 static bool pendingcleanuprunMode(pxConfig *config); 51 53 static bool pendingcleanupwarpMode(pxConfig *config); … … 101 103 MODECASE(WARPTOOL_MODE_MASKED, maskedMode); 102 104 MODECASE(WARPTOOL_MODE_UNBLOCK, unblockMode); 105 MODECASE(WARPTOOL_MODE_TOSUMMARY, tosummaryMode); 106 MODECASE(WARPTOOL_MODE_ADDSUMMARY, addsummaryMode); 103 107 MODECASE(WARPTOOL_MODE_PENDINGCLEANUPRUN, pendingcleanuprunMode); 104 108 MODECASE(WARPTOOL_MODE_PENDINGCLEANUPSKYFILE, pendingcleanupwarpMode); … … 426 430 } 427 431 428 psString query = psStringCopy("UPDATE warpRun JOIN warpSkyfile USING(warp_id) JOIN fakeRun USING(fake_id) JOIN camRun USING(cam_id) JOIN chipRun USING(chip_id) JOIN rawExp USING(exp_id)");432 psString query = psStringCopy("UPDATE warpRun"); 429 433 430 434 // pxUpdateRun gets parameters from config->args and updates … … 1548 1552 } 1549 1553 1554 static bool tosummaryMode(pxConfig *config) { 1555 PS_ASSERT_PTR_NON_NULL(config, NULL); 1556 1557 psMetadata *where = psMetadataAlloc(); 1558 PXOPT_COPY_S64(config->args, where, "-warp_id", "warpSkyfile.warp_id", "=="); 1559 PXOPT_COPY_STR(config->args, where, "-tess_id", "warpSkyfile.tess_id", "=="); 1560 PXOPT_COPY_STR(config->args, where, "-state", "warpRun.state", "=="); 1561 PXOPT_COPY_S64(config->args, where, "-exp_id", "rawExp.exp_id", "=="); 1562 PXOPT_COPY_STR(config->args, where, "-exp_name", "rawExp.exp_name", "=="); 1563 PXOPT_COPY_S64(config->args, where, "-fake_id", "fakeRun.fake_id", "=="); 1564 PXOPT_COPY_TIME(config->args, where, "-dateobs_begin", "rawExp.dateobs", ">="); 1565 PXOPT_COPY_TIME(config->args, where, "-dateobs_end", "rawExp.dateobs", "<="); 1566 PXOPT_COPY_STR(config->args, where, "-filter", "rawExp.filter", "LIKE"); 1567 PXOPT_COPY_S64(config->args, where, "-magicked", "warpSkyfile.magicked", "=="); 1568 pxAddLabelSearchArgs (config, where, "-label", "warpRun.label", "LIKE"); 1569 pxAddLabelSearchArgs (config, where, "-data_group", "warpRun.data_group", "LIKE"); 1570 1571 PXOPT_LOOKUP_BOOL(all, config->args, "-all", false); 1572 1573 PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false); 1574 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 1575 1576 // find all rawImfiles matching the default query 1577 psString query = pxDataGet("warptool_tosummary.sql"); 1578 if (!query) { 1579 psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement"); 1580 return false; 1581 } 1582 1583 // generate where strings for arguments that require extra processing 1584 // beyond PXOPT_COPY* 1585 psString where2 = NULL; 1586 if (!pxmagicAddWhere(config, &where2, "warpSkyfile")) { 1587 psError(psErrorCodeLast(), false, "pxMagicAddWhere failed"); 1588 return false; 1589 } 1590 1591 if (psListLength(where->list)) { 1592 psString whereClause = psDBGenerateWhereConditionSQL(where, NULL); 1593 psStringAppend(&query, " AND %s", whereClause); 1594 psFree(whereClause); 1595 } else if (!all && !where2) { 1596 psError(PXTOOLS_ERR_CONFIG, true, "search parameters or -all are required"); 1597 return false; 1598 } 1599 1600 if (where2) { 1601 psStringAppend(&query, " %s", where2); 1602 } 1603 psFree(where); 1604 1605 // treat limit == 0 as "no limit" 1606 if (limit) { 1607 psString limitString = psDBGenerateLimitSQL(limit); 1608 psStringAppend(&query, " %s", limitString); 1609 psFree(limitString); 1610 } 1611 1612 if (!p_psDBRunQuery(config->dbh, query)) { 1613 psError(PS_ERR_UNKNOWN, false, "database error"); 1614 psFree(query); 1615 return false; 1616 } 1617 psFree(query); 1618 1619 psArray *output = p_psDBFetchResult(config->dbh); 1620 if (!output) { 1621 psErrorCode err = psErrorCodeLast(); 1622 switch (err) { 1623 case PS_ERR_DB_CLIENT: 1624 psError(PXTOOLS_ERR_SYS, false, "database error"); 1625 case PS_ERR_DB_SERVER: 1626 psError(PXTOOLS_ERR_PROG, false, "database error"); 1627 default: 1628 psError(PXTOOLS_ERR_PROG, false, "unknown error"); 1629 } 1630 1631 return false; 1632 } 1633 if (!psArrayLength(output)) { 1634 psTrace("warptool", PS_LOG_INFO, "no rows found"); 1635 psFree(output); 1636 return true; 1637 } 1638 1639 if (psArrayLength(output)) { 1640 // negative simple so the default is true 1641 if (!ippdbPrintMetadatas(stdout, output, "warpRun", !simple)) { 1642 psError(PS_ERR_UNKNOWN, false, "failed to print array"); 1643 psFree(output); 1644 return false; 1645 } 1646 } 1647 1648 psFree(output); 1649 return(true); 1650 } 1651 static bool addsummaryMode(pxConfig *config) { 1652 PS_ASSERT_PTR_NON_NULL(config, NULL); 1653 1654 PXOPT_LOOKUP_S64(warp_id, config->args, "-warp_id", true, false); 1655 PXOPT_LOOKUP_STR(projection_cell, config->args, "-projection_cell", true, false); 1656 PXOPT_LOOKUP_STR(path_base, config->args, "-path_base", true, false); 1657 1658 psString query = pxDataGet("warptool_addsummary.sql"); 1659 if (!query) { 1660 psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement"); 1661 return(false); 1662 } 1663 if (!p_psDBRunQueryF(config->dbh, query, warp_id, projection_cell, path_base)) { 1664 psError(PS_ERR_UNKNOWN, false, "database error"); 1665 psFree(query); 1666 return(false); 1667 } 1668 psS64 numUpdated = psDBAffectedRows(config->dbh); 1669 1670 if (numUpdated != 1) { 1671 psError(PS_ERR_UNKNOWN, false, "should have affected 1 row"); 1672 psFree(query); 1673 return false; 1674 } 1675 1676 psFree(query); 1677 1678 // Print anything here? 1679 1680 return(true); 1681 } 1682 1550 1683 static bool pendingcleanuprunMode(pxConfig *config) 1551 1684 {
Note:
See TracChangeset
for help on using the changeset viewer.
