Changeset 30586 for branches/czw_branch/20101203/ippTools/src/pztool.c
- Timestamp:
- Feb 11, 2011, 4:29:48 PM (15 years ago)
- Location:
- branches/czw_branch/20101203
- Files:
-
- 2 edited
-
. (modified) (1 prop)
-
ippTools/src/pztool.c (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/czw_branch/20101203
- Property svn:mergeinfo changed
-
branches/czw_branch/20101203/ippTools/src/pztool.c
r29982 r30586 47 47 static bool advanceMode(pxConfig *config); 48 48 49 static bool updatepzexpMode(pxConfig *config); 50 static bool updatenewexpMode(pxConfig *config); 51 49 52 // static bool copydoneCompleteExp(pxConfig *config); 50 53 static psArray *pzGetPendingCameras(pxConfig *config); … … 83 86 MODECASE(PZTOOL_MODE_TOADVANCE, toadvanceMode); 84 87 MODECASE(PZTOOL_MODE_ADVANCE, advanceMode); 88 MODECASE(PZTOOL_MODE_UPDATEPZEXP, updatepzexpMode); 89 MODECASE(PZTOOL_MODE_UPDATENEWEXP, updatenewexpMode); 85 90 default: 86 91 psAbort("invalid option (this should not happen)"); … … 294 299 295 300 psMetadata *where = psMetadataAlloc(); 296 PXOPT_COPY_STR(config->args, where, "-exp_name", "exp_name", "=="); 297 PXOPT_COPY_STR(config->args, where, "-inst", "camera", "=="); 298 PXOPT_COPY_STR(config->args, where, "-telescope", "telescope", "=="); 299 PXOPT_COPY_STR(config->args, where, "-exp_type", "exp_type", "=="); 301 PXOPT_COPY_STR(config->args, where, "-exp_name", "exp_name", "=="); 302 PXOPT_COPY_STR(config->args, where, "-inst", "camera", "=="); 303 PXOPT_COPY_STR(config->args, where, "-telescope", "telescope", "=="); 304 PXOPT_COPY_STR(config->args, where, "-exp_type", "exp_type", "=="); 305 PXOPT_COPY_TIME(config->args, where, "-dateobs_begin", "dateobs", ">="); 306 PXOPT_COPY_TIME(config->args, where, "-dateobs_end", "dateobs", "<="); 300 307 301 308 PXOPT_LOOKUP_BOOL(desc, config->args, "-desc", false); … … 325 332 326 333 if (psListLength(where->list)) { 327 psString whereClause = psDBGenerateWhereConditionSQL(where, "pzDownloadImfile");334 psString whereClause = psDBGenerateWhereConditionSQL(where, NULL); 328 335 psStringAppend(&query, " AND %s", whereClause); 329 336 psFree(whereClause); … … 889 896 || (strncmp(state, "stop", 5) == 0) 890 897 || (strncmp(state, "reg", 4) == 0) 898 || (strncmp(state, "drop", 5) == 0) 891 899 ) 892 900 ) { … … 905 913 } 906 914 915 static bool updatepzexpMode(pxConfig *config) 916 { 917 PS_ASSERT_PTR_NON_NULL(config, false); 918 PXOPT_LOOKUP_STR(exp_name, config->args, "-exp_name", true, false); 919 PXOPT_LOOKUP_STR(camera, config->args, "-inst", true, false); 920 PXOPT_LOOKUP_STR(telescope,config->args, "-telescope",true, false); 921 PXOPT_LOOKUP_STR(state, config->args, "-set_state",true, false); 922 923 if (!pzDownloadExpSetState(config,exp_name,camera,telescope,state)) { 924 psError(PS_ERR_UNKNOWN, false, "failed to change state for %s:%s:%s", exp_name, camera, telescope); 925 return false; 926 } 927 return true; 928 } 929 930 931 static bool updatenewexpMode(pxConfig *config) 932 { 933 PS_ASSERT_PTR_NON_NULL(config, false); 934 935 psMetadata *where = psMetadataAlloc(); 936 PXOPT_COPY_S64(config->args, where, "-exp_id", "exp_id", "=="); 937 PXOPT_COPY_STR(config->args, where, "-exp_name", "tmp_exp_name", "=="); 938 939 PXOPT_LOOKUP_STR(new_state, config->args, "-set_state", true, false); 940 941 if (strcmp(new_state, "drop") && strcmp(new_state, "run") && strcmp(new_state, "wait")) { 942 psError(PXTOOLS_ERR_ARGUMENTS, true, "%s is not a valid value for -set_state", new_state); 943 psFree(where); 944 return false; 945 } 946 947 if (psListLength(where->list) < 1) { 948 psFree(where); 949 psError(PXTOOLS_ERR_CONFIG, false, "-exp_name or -exp_id is required"); 950 return false; 951 } 952 953 psString query = NULL; 954 psStringAppend(&query, "UPDATE newExp SET state = '%s'", new_state); 955 956 psString whereClause = psDBGenerateWhereConditionSQL(where, NULL); 957 psStringAppend(&query, "\nWHERE %s", whereClause); 958 959 psFree(whereClause); 960 psFree(where); 961 962 if (!p_psDBRunQuery(config->dbh, query)) { 963 psError(PS_ERR_UNKNOWN, false, "database error"); 964 psFree(query); 965 return false; 966 } 967 psFree(query); 968 969 return true; 970 } 971 972 973 907 974 908 975 #if 0
Note:
See TracChangeset
for help on using the changeset viewer.
