Changeset 6880 for trunk/ippTools/src/pzgetexp.c
- Timestamp:
- Apr 17, 2006, 3:35:29 PM (20 years ago)
- File:
-
- 1 edited
-
trunk/ippTools/src/pzgetexp.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippTools/src/pzgetexp.c
r6876 r6880 18 18 bool haveLastFileSet = false; 19 19 psString lastFileSet = NULL; 20 // XXX this is a very ugly and brute force way of doing things need to add 21 // a metadatadb function to retrun the last entry without removing it from 22 // the database 20 23 psArray *summitExps = summitExpSelectRowObjects(config->dbh, NULL, 0); 21 24 if (summitExps) { … … 23 26 summitExpRow *lastExps = summitExps->data[psArrayLength(summitExps) - 1]; 24 27 lastFileSet = psMemIncrRefCounter(lastExps->exp_id); 25 psFree(summitExps);26 28 } 27 29 28 30 // invoke dsproductls 29 31 // dsproductls --uri <> --last_fileset <> 30 { 31 bool status = false; 32 psString uri = psMetadataLookupStr(&status, config->args, "-uri"); 33 psString cmd = NULL; 34 if (haveLastFileSet) { 35 psStringAppend(&cmd, "dsproductls --uri %s --last_fileset %s", 36 uri, lastFileSet); 37 } else { 38 psStringAppend(&cmd, "dsproductls --uri %s", uri); 39 } 40 41 FILE *output = popen(cmd, "r"); 42 psFree(cmd); 43 44 if (!output) { 45 psError(PS_ERR_UNKNOWN, true, "popen() failed"); 46 goto FAIL; 47 } 48 psString cmdOutput = fslurp(output); 49 pclose(output); 50 parseFileSets(config, cmdOutput); 32 bool status = false; 33 psString uri = psMetadataLookupStr(&status, config->args, "-uri"); 34 psString cmd = NULL; 35 if (haveLastFileSet) { 36 psStringAppend(&cmd, "dsproductls --uri %s --last_fileset %s", 37 uri, lastFileSet); 38 psFree(lastFileSet); 39 } else { 40 psStringAppend(&cmd, "dsproductls --uri %s", uri); 51 41 } 52 42 53 psFree(lastFileSet);43 fprintf(stderr, "cmd is: %s\n", cmd); 54 44 55 /* 56 psArray *summitExps = parseInput(config); 57 if (!summitExps) { 45 FILE *output = popen(cmd, "r"); 46 psFree(cmd); 47 48 if (!output) { 49 psError(PS_ERR_UNKNOWN, true, "popen() failed"); 50 goto FAIL; 51 } 52 psString cmdOutput = fslurp(output); 53 pclose(output); 54 55 psArray *newSummitExps = parseFileSets(config, cmdOutput); 56 psFree(cmdOutput); 57 if (!newSummitExps) { 58 // XXX not nessicarily an error 59 psError(PS_ERR_UNKNOWN, true, "no new fileSet/exp IDs"); 58 60 goto FAIL; 59 61 } 60 62 63 // try not to insert duplicate summitExp entries 64 // XXX this will become very expensive as the number of summitExp entry 65 // grows -- is just blindly ignoring database errors the best thing to do? 66 if (summitExps) { 67 for (long i = 0; i < psArrayLength(newSummitExps); i++) { 68 summitExpRow *newSummitExp = newSummitExps->data[i]; 69 for (long j = 0; j < psArrayLength(summitExps); j++) { 70 summitExpRow *summitExp = summitExps->data[j]; 71 if (strcmp(newSummitExp->exp_id, 72 summitExp->exp_id) == 0) { 73 psArrayRemove(newSummitExps, newSummitExp); 74 // dec the counter as the array just got shorter 75 // and we don't want to skip elemnts 76 i--; 77 break; 78 } 79 } 80 } 81 psFree(summitExps); 82 } 83 61 84 // insert new entries into the database 62 for (long i = 0; i < psArrayLength( summitExps); i++) {63 if (!summitExpInsertObject(config->dbh, summitExps->data[i])) {85 for (long i = 0; i < psArrayLength(newSummitExps); i++) { 86 if (!summitExpInsertObject(config->dbh, newSummitExps->data[i])) { 64 87 psError(PS_ERR_UNKNOWN, false, "dbh access failed"); 65 88 goto FAIL; 66 89 } 67 90 } 68 */69 91 70 92 psFree(config); … … 74 96 FAIL: 75 97 psFree(config); 98 76 99 exit(EXIT_FAILURE); 77 100 } … … 79 102 static psArray *parseFileSets(pxConfig *config, const char *str) 80 103 { 104 PS_ASSERT_PTR_NON_NULL(config, NULL); 105 PS_ASSERT_PTR_NON_NULL(str, NULL); 106 81 107 psList *lines = psStringSplit(str, "\n"); 82 108
Note:
See TracChangeset
for help on using the changeset viewer.
