Changeset 25822 for trunk/ippTools/src/warptool.c
- Timestamp:
- Oct 9, 2009, 2:02:24 PM (17 years ago)
- File:
-
- 1 edited
-
trunk/ippTools/src/warptool.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippTools/src/warptool.c
r25800 r25822 58 58 static bool exportrunMode(pxConfig *config); 59 59 static bool importrunMode(pxConfig *config); 60 static bool runstateMode(pxConfig *config); 60 61 61 62 static bool parseAndInsertSkyCellMap(pxConfig *config, const char *mapfile); … … 108 109 MODECASE(WARPTOOL_MODE_EXPORTRUN, exportrunMode); 109 110 MODECASE(WARPTOOL_MODE_IMPORTRUN, importrunMode); 111 MODECASE(WARPTOOL_MODE_RUNSTATE, runstateMode); 110 112 111 113 default: … … 1915 1917 return true; 1916 1918 } 1919 1920 static bool runstateMode(pxConfig *config) 1921 { 1922 PS_ASSERT_PTR_NON_NULL(config, false); 1923 1924 psMetadata *where = psMetadataAlloc(); 1925 PXOPT_COPY_S64(config->args, where, "-warp_id", "warpRun.warp_id", "=="); 1926 PXOPT_COPY_S64(config->args, where, "-exp_id", "rawExp.exp_id", "=="); 1927 PXOPT_COPY_STR(config->args, where, "-exp_name", "rawExp.exp_name", "=="); 1928 pxAddLabelSearchArgs (config, where, "-label", "warpRun.label", "LIKE"); 1929 1930 // PXOPT_LOOKUP_BOOL(all, config->args, "-all", false); 1931 PXOPT_LOOKUP_BOOL(no_magic, config->args, "-no_magic", false); 1932 1933 PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false); 1934 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 1935 1936 psString query = pxDataGet("warptool_runstate.sql"); 1937 if (!query) { 1938 psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement"); 1939 return false; 1940 } 1941 1942 if (psListLength(where->list)) { 1943 psString whereClause = psDBGenerateWhereConditionSQL(where, NULL); 1944 psStringAppend(&query, " WHERE %s", whereClause); 1945 psFree(whereClause); 1946 } else { 1947 psError(PXTOOLS_ERR_DATA, true, "search parameters or -all are required"); 1948 return false; 1949 } 1950 psFree(where); 1951 1952 // treat limit == 0 as "no limit" 1953 if (limit) { 1954 psString limitString = psDBGenerateLimitSQL(limit); 1955 psStringAppend(&query, " %s", limitString); 1956 psFree(limitString); 1957 } 1958 1959 if (!p_psDBRunQuery(config->dbh, query)) { 1960 psError(PS_ERR_UNKNOWN, false, "database error"); 1961 psFree(query); 1962 return false; 1963 } 1964 psFree(query); 1965 1966 psArray *output = p_psDBFetchResult(config->dbh); 1967 if (!output) { 1968 psErrorCode err = psErrorCodeLast(); 1969 switch (err) { 1970 case PS_ERR_DB_CLIENT: 1971 psError(PXTOOLS_ERR_SYS, false, "database error"); 1972 case PS_ERR_DB_SERVER: 1973 psError(PXTOOLS_ERR_PROG, false, "database error"); 1974 default: 1975 psError(PXTOOLS_ERR_PROG, false, "unknown error"); 1976 } 1977 1978 return false; 1979 } 1980 if (!psArrayLength(output)) { 1981 psTrace("warptool", PS_LOG_INFO, "no rows found"); 1982 psFree(output); 1983 return true; 1984 } 1985 1986 if (psArrayLength(output)) { 1987 // negative simple so the default is true 1988 if (!ippdbPrintMetadatas(stdout, output, "warpRunState", !simple)) { 1989 psError(PS_ERR_UNKNOWN, false, "failed to print array"); 1990 psFree(output); 1991 return false; 1992 } 1993 } 1994 1995 psFree(output); 1996 1997 return true; 1998 }
Note:
See TracChangeset
for help on using the changeset viewer.
