Changeset 29611
- Timestamp:
- Oct 29, 2010, 12:36:07 PM (16 years ago)
- Location:
- trunk/ippTools
- Files:
-
- 2 added
- 4 edited
-
share/Makefile.am (modified) (1 diff)
-
share/magicdstool_destreakedfile.sql (added)
-
share/magicdstool_listrun.sql (added)
-
src/magicdstool.c (modified) (3 diffs)
-
src/magicdstool.h (modified) (1 diff)
-
src/magicdstoolConfig.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippTools/share/Makefile.am
r29561 r29611 251 251 magicdstool_definecopy_chip.sql \ 252 252 magicdstool_definecopy_warp.sql \ 253 magicdstool_destreakedfile.sql \ 253 254 magicdstool_getrunids.sql \ 254 255 magicdstool_getskycells.sql \ 256 magicdstool_listrun.sql \ 255 257 magicdstool_revertdestreakedfile.sql \ 256 258 magicdstool_revertupdated.sql \ -
trunk/ippTools/src/magicdstool.c
r29570 r29611 49 49 static bool tocleanedfileMode(pxConfig *config); 50 50 static bool setfiletoupdateMode(pxConfig *config); 51 static bool destreakedfileMode(pxConfig *config); 52 static bool listrunMode(pxConfig *config); 51 53 52 54 static bool setmagicDSRunState(pxConfig *config, psS64 magic_id, psString extraSetString, psMetadata *where, const char *state); … … 87 89 MODECASE(MAGICDSTOOL_MODE_TOCLEANEDFILE, tocleanedfileMode); 88 90 MODECASE(MAGICDSTOOL_MODE_SETFILETOUPDATE, setfiletoupdateMode); 91 MODECASE(MAGICDSTOOL_MODE_DESTREAKEDFILE, destreakedfileMode); 92 MODECASE(MAGICDSTOOL_MODE_LISTRUN, listrunMode); 89 93 default: 90 94 psAbort("invalid option (this should not happen)"); … … 1748 1752 1749 1753 1754 static bool destreakedfileMode(pxConfig *config) 1755 { 1756 PS_ASSERT_PTR_NON_NULL(config, false); 1757 1758 psMetadata *where = psMetadataAlloc(); 1759 1760 PXOPT_COPY_S64(config->args, where, "-magic_ds_id", "magic_ds_id", "=="); 1761 PXOPT_COPY_STR(config->args, where, "-component", "component", "=="); 1762 PXOPT_COPY_STR(config->args, where, "-label", "label", "=="); 1763 PXOPT_COPY_STR(config->args, where, "-stage", "stage", "=="); 1764 PXOPT_COPY_S64(config->args, where, "-stage_id", "stage_id", "=="); 1765 PXOPT_COPY_S64(config->args, where, "-magic_id", "magic_id", "=="); 1766 pxAddLabelSearchArgs (config, where, "-label", "magicDSRun.label", "=="); 1767 PXOPT_LOOKUP_BOOL(faulted, config->args, "-faulted", false); 1768 1769 PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false); 1770 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 1771 1772 1773 psString query = pxDataGet("magicdstool_destreakedfile.sql"); 1774 if (!query) { 1775 psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement"); 1776 return false; 1777 } 1778 1779 if (psListLength(where->list)) { 1780 psString whereClause = psDBGenerateWhereConditionSQL(where, NULL); 1781 psStringAppend(&query, "\nWHERE %s", whereClause); 1782 psFree(whereClause); 1783 } else { 1784 psError(PS_ERR_UNKNOWN, true, "search arguments are required"); 1785 return false; 1786 } 1787 psFree(where); 1788 1789 if (faulted) { 1790 psStringAppend(&query, " AND magicDSFile.fault > 0"); 1791 } 1792 1793 // treat limit == 0 as "no limit" 1794 if (limit) { 1795 psString limitString = psDBGenerateLimitSQL(limit); 1796 psStringAppend(&query, " %s", limitString); 1797 psFree(limitString); 1798 } 1799 1800 if (!p_psDBRunQuery(config->dbh, query)) { 1801 psError(PS_ERR_UNKNOWN, false, "database error"); 1802 psFree(query); 1803 return false; 1804 } 1805 psFree(query); 1806 1807 psArray *output = p_psDBFetchResult(config->dbh); 1808 if (!output) { 1809 psErrorCode err = psErrorCodeLast(); 1810 switch (err) { 1811 case PS_ERR_DB_CLIENT: 1812 psError(PXTOOLS_ERR_SYS, false, "database error"); 1813 case PS_ERR_DB_SERVER: 1814 psError(PXTOOLS_ERR_PROG, false, "database error"); 1815 default: 1816 psError(PXTOOLS_ERR_PROG, false, "unknown error"); 1817 } 1818 1819 return false; 1820 } 1821 if (!psArrayLength(output)) { 1822 psTrace("magicdstool", PS_LOG_INFO, "no rows found"); 1823 psFree(output); 1824 return true; 1825 } 1826 1827 if (psArrayLength(output)) { 1828 // negative simple so the default is true 1829 if (!ippdbPrintMetadatas(stdout, output, "magicDSFile", !simple)) { 1830 psError(PS_ERR_UNKNOWN, false, "failed to print array"); 1831 psFree(output); 1832 return false; 1833 } 1834 } 1835 1836 psFree(output); 1837 1838 return true; 1839 } 1840 static bool listrunMode(pxConfig *config) 1841 { 1842 PS_ASSERT_PTR_NON_NULL(config, false); 1843 1844 psMetadata *where = psMetadataAlloc(); 1845 1846 PXOPT_COPY_S64(config->args, where, "-magic_ds_id", "magic_ds_id", "=="); 1847 PXOPT_COPY_STR(config->args, where, "-label", "label", "=="); 1848 PXOPT_COPY_STR(config->args, where, "-stage", "stage", "=="); 1849 PXOPT_COPY_S64(config->args, where, "-stage_id", "stage_id", "=="); 1850 PXOPT_COPY_S64(config->args, where, "-magic_id", "magic_id", "=="); 1851 pxAddLabelSearchArgs (config, where, "-label", "magicDSRun.label", "=="); 1852 1853 PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false); 1854 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 1855 1856 1857 psString query = pxDataGet("magicdstool_listrun.sql"); 1858 if (!query) { 1859 psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement"); 1860 return false; 1861 } 1862 1863 if (psListLength(where->list)) { 1864 psString whereClause = psDBGenerateWhereConditionSQL(where, NULL); 1865 psStringAppend(&query, "\nWHERE %s", whereClause); 1866 psFree(whereClause); 1867 } else { 1868 psError(PS_ERR_UNKNOWN, true, "search arguments are required"); 1869 return false; 1870 } 1871 psFree(where); 1872 1873 // treat limit == 0 as "no limit" 1874 if (limit) { 1875 psString limitString = psDBGenerateLimitSQL(limit); 1876 psStringAppend(&query, " %s", limitString); 1877 psFree(limitString); 1878 } 1879 1880 if (!p_psDBRunQuery(config->dbh, query)) { 1881 psError(PS_ERR_UNKNOWN, false, "database error"); 1882 psFree(query); 1883 return false; 1884 } 1885 psFree(query); 1886 1887 psArray *output = p_psDBFetchResult(config->dbh); 1888 if (!output) { 1889 psErrorCode err = psErrorCodeLast(); 1890 switch (err) { 1891 case PS_ERR_DB_CLIENT: 1892 psError(PXTOOLS_ERR_SYS, false, "database error"); 1893 case PS_ERR_DB_SERVER: 1894 psError(PXTOOLS_ERR_PROG, false, "database error"); 1895 default: 1896 psError(PXTOOLS_ERR_PROG, false, "unknown error"); 1897 } 1898 1899 return false; 1900 } 1901 if (!psArrayLength(output)) { 1902 psTrace("magicdstool", PS_LOG_INFO, "no rows found"); 1903 psFree(output); 1904 return true; 1905 } 1906 1907 if (psArrayLength(output)) { 1908 // negative simple so the default is true 1909 if (!ippdbPrintMetadatas(stdout, output, "magicDSRun", !simple)) { 1910 psError(PS_ERR_UNKNOWN, false, "failed to print array"); 1911 psFree(output); 1912 return false; 1913 } 1914 } 1915 1916 psFree(output); 1917 1918 return true; 1919 } -
trunk/ippTools/src/magicdstool.h
r29561 r29611 42 42 MAGICDSTOOL_MODE_SETFILETOUPDATE, 43 43 MAGICDSTOOL_MODE_UPDATEDESTREAKEDFILE, 44 MAGICDSTOOL_MODE_LISTRUN, 45 MAGICDSTOOL_MODE_DESTREAKEDFILE, 44 46 } MAGICDStoolMode; 45 47 -
trunk/ippTools/src/magicdstoolConfig.c
r29570 r29611 231 231 psMetadataAddStr(setfiletoupdateArgs, PS_LIST_TAIL, "-set_label", 0, "set new label", NULL); 232 232 233 // -destreakedfile 234 psMetadata *destreakedfileArgs = psMetadataAlloc(); 235 psMetadataAddS64(destreakedfileArgs, PS_LIST_TAIL, "-magic_ds_id", 0, "search by magic_ds_id", 0); 236 psMetadataAddStr(destreakedfileArgs, PS_LIST_TAIL, "-component", 0, "search by component", NULL); 237 psMetadataAddStr(destreakedfileArgs, PS_LIST_TAIL, "-stage", 0, "search by stage", NULL); 238 psMetadataAddS64(destreakedfileArgs, PS_LIST_TAIL, "-stage_id", 0, "search by magic_id", 0); 239 240 psMetadataAddStr(destreakedfileArgs, PS_LIST_TAIL, "-label", PS_META_DUPLICATE_OK, "search by magicRun.label", NULL); 241 psMetadataAddS64(destreakedfileArgs, PS_LIST_TAIL, "-magic_id", 0, "search by magic_id", 0); 242 243 psMetadataAddBool(destreakedfileArgs, PS_LIST_TAIL, "-faulted", 0, "list only faulted components", false); 244 psMetadataAddBool(destreakedfileArgs, PS_LIST_TAIL, "-simple", 0, "use the simple output format", false); 245 psMetadataAddU64(destreakedfileArgs, PS_LIST_TAIL, "-limit", 0, "limit result set to N items", 0); 246 247 // -listrun 248 psMetadata *listrunArgs = psMetadataAlloc(); 249 psMetadataAddS64(listrunArgs, PS_LIST_TAIL, "-magic_ds_id", 0, "search by magic_ds_id", 0); 250 psMetadataAddStr(listrunArgs, PS_LIST_TAIL, "-stage", 0, "define stage", NULL); 251 psMetadataAddS64(listrunArgs, PS_LIST_TAIL, "-stage_id", 0, "search by magic_id", 0); 252 psMetadataAddS64(listrunArgs, PS_LIST_TAIL, "-magic_id", 0, "search by magic_id", 0); 253 254 psMetadataAddStr(listrunArgs, PS_LIST_TAIL, "-label", PS_META_DUPLICATE_OK, "search by magicRun.label", NULL); 255 256 psMetadataAddBool(listrunArgs, PS_LIST_TAIL, "-faulted", 0, "list faulted components", false); 257 258 psMetadataAddBool(listrunArgs, PS_LIST_TAIL, "-simple", 0, "use the simple output format", false); 259 psMetadataAddU64(listrunArgs, PS_LIST_TAIL, "-limit", 0, "limit result set to N items", 0); 260 233 261 psFree(now); 234 262 … … 272 300 PXOPT_ADD_MODE("-updatedestreakedfile", "update parameters of destreaked file", 273 301 MAGICDSTOOL_MODE_UPDATEDESTREAKEDFILE, updatedestreakedfileArgs); 302 PXOPT_ADD_MODE("-destreakedfile", "list destreaked file", 303 MAGICDSTOOL_MODE_DESTREAKEDFILE, destreakedfileArgs); 304 PXOPT_ADD_MODE("-listrun", "list parameters of destreak run", 305 MAGICDSTOOL_MODE_LISTRUN, listrunArgs); 274 306 275 307
Note:
See TracChangeset
for help on using the changeset viewer.
