Changeset 18379
- Timestamp:
- Jun 30, 2008, 10:01:31 AM (18 years ago)
- File:
-
- 1 edited
-
trunk/pstamp/src/pstampparse.c (modified) (26 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/pstamp/src/pstampparse.c
r18247 r18379 1 // pstampparse - read a fits table describing a postage stamp request and prepare the request2 // for processing1 // pstampparse ---> imagetool but this program is going to be 2 // deleted so we'll just leave the external name alone 3 3 4 4 #include <pslib.h> … … 6 6 #include <string.h> 7 7 #include <strings.h> 8 #include "pstamp.h" 9 #include "pstampROI.h" 8 9 typedef enum { 10 UNKNOWN_IMAGE = -1, 11 RAW_IMAGE, 12 CHIP_IMAGE, 13 WARP_IMAGE, 14 STACK_IMAGE, 15 DIFF_IMAGE 16 } itImageType; 17 18 typedef enum { 19 BY_ID, 20 BY_EXP, 21 BY_COORD, 22 UNKNOWN_LOOKUP_TYPE 23 } itLookupType; 10 24 11 25 typedef struct { 12 pmConfig *config; 13 psString fileName; 14 psString outputDirectory; 15 psMetadata *md; 16 psString roiString; 17 pspMode mode; 18 psS64 req_id; 19 bool verbose; 20 bool simple; 21 } pspOptions; 26 pmConfig *config; 27 itLookupType lookupType; 28 itImageType imageType; 29 psString id; 30 psString class_id; 31 psString roiString; 32 bool verbose; 33 bool simple; 34 } itOptions; 22 35 23 36 … … 25 38 { 26 39 // XXX: fill this out 27 fprintf(stderr, "argument error\n");40 psErrorStackPrint(stderr, "argument error"); 28 41 exit(1); 29 42 } 30 43 31 static pspMode parseMode(char *modeString) 32 { 33 pspMode mode = PSP_MODE_UNKNOWN; 34 35 if (!strcasecmp(modeString, "list_uri")) { 36 mode = PSP_MODE_LIST_URI; 37 } else if (!strcasecmp(modeString, "list_job")) { 38 mode = PSP_MODE_LIST_JOB; 39 } else if (!strcasecmp(modeString, "queue_job")) { 40 mode = PSP_MODE_QUEUE_JOB; 44 static itImageType parseImageType(psString type) 45 { 46 itImageType itype; 47 48 if (type == NULL) { 49 psError(PS_ERR_UNKNOWN, true, "NULL image type"); 50 itype = UNKNOWN_IMAGE; 51 return itype; 52 } 53 54 if (strcmp(type, "raw") == 0) { 55 itype = RAW_IMAGE; 56 } else if (strcmp(type, "chip") == 0) { 57 itype = CHIP_IMAGE; 58 } else if (strcmp(type, "warp") == 0) { 59 itype = WARP_IMAGE; 60 } else if (strcmp(type, "diff") == 0) { 61 itype = DIFF_IMAGE; 62 } else if (strcmp(type, "stack") == 0) { 63 itype = STACK_IMAGE; 41 64 } else { 42 fprintf(stderr, "unknown command mode: %s\n", modeString); 43 exit(1); 44 } 45 return mode; 46 } 47 48 49 static pspOptions *parseArguments(int argc, char *argv[]) 65 psError(PS_ERR_UNKNOWN, true, "unknown image type %s", type); 66 itype = UNKNOWN_LOOKUP_TYPE; 67 } 68 69 return itype; 70 } 71 static void getParams(itOptions *options, int argnum, int *pArgc, char *argv[]) 72 { 73 if (*pArgc < 3) { 74 fprintf(stderr, "values required for type and id\n"); 75 usage(); 76 } 77 78 options->imageType = parseImageType(argv[argnum]); 79 psArgumentRemove(argnum, pArgc, argv); 80 options->id = argv[argnum]; 81 psArgumentRemove(argnum, pArgc, argv); 82 83 if ((options->imageType == RAW_IMAGE) || (options->imageType == CHIP_IMAGE)) { 84 if (*pArgc < 2) { 85 fprintf(stderr, "value required for class_id\n"); 86 usage(); 87 } 88 options->class_id = argv[argnum]; 89 90 psArgumentRemove(argnum, pArgc, argv); 91 } 92 } 93 94 static itOptions *parseArguments(int argc, char *argv[]) 50 95 { 51 96 int argnum; 52 pspOptions *options = psAlloc(sizeof(pspOptions)); 97 itOptions *options = psAlloc(sizeof(itOptions)); 98 bool gotLookupType = false; 53 99 54 100 memset(options, 0, sizeof(*options)); 55 56 // options to add57 // mode: -queuejobs -execute58 101 59 102 options->config = pmConfigRead(&argc, argv, NULL); … … 64 107 } 65 108 66 // XXX: need to sort out the interactions of this mode option and the JOB_TYPE 67 // listed in the request file. 68 if ((argnum = psArgumentGet(argc, argv, "-mode"))) { 109 if ((argnum = psArgumentGet(argc, argv, "-byid"))) { 110 options->lookupType = BY_ID; 69 111 psArgumentRemove(argnum, &argc, argv); 70 if (argnum == argc) { 71 fprintf(stderr, "value required for mode\n"); 112 getParams(options, argnum, &argc, argv); 113 gotLookupType = true; 114 } 115 if ((argnum = psArgumentGet(argc, argv, "-byexp"))) { 116 if (gotLookupType) { 117 psError(PS_ERR_UNKNOWN, false, "only one of -byid, -byexp, and -bycoord may be used\n"); 72 118 usage(); 73 119 } 74 options->mode = parseMode(argv[argnum]); 120 gotLookupType = true; 121 options->lookupType = BY_EXP; 75 122 psArgumentRemove(argnum, &argc, argv); 76 } else { 77 options->mode = PSP_MODE_LIST_JOB; 78 } 79 80 if ((argnum = psArgumentGet(argc, argv, "-req_id"))) { 123 getParams(options, argnum, &argc, argv); 124 } 125 if ((argnum = psArgumentGet(argc, argv, "-bycoord"))) { 126 if (gotLookupType) { 127 psError(PS_ERR_UNKNOWN, false, "only one of -byid, -byexp, and -bycoord may be used\n"); 128 usage(); 129 } 81 130 psArgumentRemove(argnum, &argc, argv); 82 if (argnum == argc) { 83 fprintf(stderr, "value required for req_id\n"); 84 usage(); 85 } 86 options->req_id = atol(argv[argnum]); 87 psArgumentRemove(argnum, &argc, argv); 88 } 89 90 if ((options->mode == PSP_MODE_QUEUE_JOB) && (options->req_id <= 0)) { 91 psError(PS_ERR_UNKNOWN, true, "need request id in order to queue jobs\n"); 92 return false; 131 gotLookupType = true; 132 options->lookupType = BY_COORD; 133 getParams(options, argnum, &argc, argv); 134 psError(PS_ERR_UNKNOWN, true, "REQ_TYPE: bycoord not implemented yet"); 135 return NULL; 136 } 137 if (!gotLookupType) { 138 psError(PS_ERR_BAD_PARAMETER_NULL , true, "one of -byid, -byexp, or -bycoord must be supplied\n"); 139 usage(); 93 140 } 94 141 … … 102 149 psArgumentRemove(argnum, &argc, argv); 103 150 } 104 if ((argnum = psArgumentGet(argc, argv, "-out_dir"))) { 105 psArgumentRemove(argnum, &argc, argv); 106 if (argnum == argc) { 107 fprintf(stderr, "value required for out_dir\n"); 108 usage(); 109 } 110 options->outputDirectory = argv[argnum]; 111 psArgumentRemove(argnum, &argc, argv); 112 } 113 114 if (argc == 2) { 115 options->fileName = psStringCopy(argv[1]); 116 } else if (argc == 1) { 117 fprintf(stderr, "input file name is required\n"); 118 usage(); 119 } else { 120 fprintf(stderr, "unknown arguments supplied:"); 121 fprintf(stderr, " %s", argv[1]); 151 152 // XXX: Arguments to add for bycoord searches FILTER, DATE_BEGIN, DATE_END 153 154 if (argc > 1) { 155 fprintf(stderr, "unknown arguments supplied: "); 156 157 fprintf(stderr, "%s", argv[1]); 122 158 for (int i=2; i<argc; i++) { 123 159 fprintf(stderr, ", %s", argv[i]); … … 130 166 } 131 167 132 static bool readRequestTable(pspOptions *options) 133 { 134 psFits *fitsFile = psFitsOpen(options->fileName, "r"); 135 if (fitsFile == NULL) { 136 psError(PS_ERR_IO, false, "failed to open %s for output", options->fileName); 137 return false; 138 } 139 140 psArray *array = psFitsReadTable(fitsFile); 141 142 psFitsClose(fitsFile); 143 144 if (array == NULL) { 145 psError(PS_ERR_IO, false, "psFitsReadTable failed for %s", options->fileName); 146 return false; 147 } 148 149 options->md = array->data[0]; 150 151 return true; 152 } 153 154 static bool setupDB(pspOptions *options) 168 static bool setupDB(itOptions *options) 155 169 { 156 170 // XXX: need to select the database name based on the project name specified in the input … … 166 180 } 167 181 168 // TODO: move this to a shared file169 static pstampImageType getImageType(pspOptions *options)170 {171 psString type = psMetadataLookupStr(NULL, options->md, "IMG_TYPE");172 pstampImageType itype;173 174 if (type == NULL) {175 psError(PS_ERR_UNKNOWN, true, "NULL image type");176 itype = PSTAMP_UNKNOWN;177 return itype;178 }179 180 if (strcmp(type, "raw") == 0) {181 itype = PSTAMP_RAW;182 } else if (strcmp(type, "chip") == 0) {183 itype = PSTAMP_CHIP;184 } else if (strcmp(type, "warp") == 0) {185 itype = PSTAMP_WARP;186 } else if (strcmp(type, "diff") == 0) {187 itype = PSTAMP_DIFF;188 } else if (strcmp(type, "stack") == 0) {189 itype = PSTAMP_STACK;190 } else {191 psError(PS_ERR_UNKNOWN, true, "unknown image type %s", type);192 itype = PSTAMP_UNKNOWN;193 }194 195 return itype;196 }197 182 198 183 // return a string with the contents of a unsigned 64 bit value … … 211 196 // the type for the values returned by the query is either a string or psU64. 212 197 213 static psArray *runQuery( pspOptions *options, psString query, psString target,198 static psArray *runQuery(itOptions *options, psString query, psString target, 214 199 psString key1, psString key2, bool targetIsString, psArray *output) 215 200 { … … 268 253 } 269 254 270 static psArray *findURIs( pspOptions *options, psString table, psString id_type, psString id, psString class_id)255 static psArray *findURIs(itOptions *options, psString table, psString id_type, psString id, psString class_id) 271 256 { 272 257 psString query = NULL; … … 325 310 326 311 327 static psArray *findChipURIs( pspOptions *options, psString exp_id, psString class_id)312 static psArray *findChipURIs(itOptions *options, psString exp_id, psString class_id) 328 313 { 329 314 psString chip_id = chipIDForExp(options, exp_id); … … 340 325 } 341 326 342 static psArray *findWarpURIs( pspOptions *options, psString exp_id)327 static psArray *findWarpURIs(itOptions *options, psString exp_id) 343 328 { 344 329 psString chip_id = chipIDForExp(options, exp_id); … … 365 350 } 366 351 367 static psArray *findStackURIs( pspOptions *options, psString exp_id)352 static psArray *findStackURIs(itOptions *options, psString exp_id) 368 353 { 369 354 psString chip_id = chipIDForExp(options, exp_id); … … 406 391 } 407 392 408 static psArray *findDiffURIs( pspOptions *options, psString exp_id)393 static psArray *findDiffURIs(itOptions *options, psString exp_id) 409 394 { 410 395 psString chip_id = chipIDForExp(options, exp_id); … … 446 431 } 447 432 448 static psArray * parseByID(pspOptions *options) 449 { 450 bool status = false; 451 pstampImageType itype = getImageType(options); 452 psString class_id = psMetadataLookupStr(&status, options->md, "CLASS_ID"); 453 psString id = psMetadataLookupStr(NULL, options->md, "ID"); 433 static psArray * parseByID(itOptions *options) 434 { 435 psString id = options->id; 436 psString class_id = options->class_id; 454 437 psArray *uris = NULL; 455 438 … … 459 442 } 460 443 461 switch ( itype) {462 case PSTAMP_RAW:444 switch (options->imageType) { 445 case RAW_IMAGE: 463 446 uris = findURIs(options, "rawImfile", "exp_id", id, class_id); 464 447 break; 465 case PSTAMP_CHIP:448 case CHIP_IMAGE: 466 449 uris = findURIs(options, "chipProcessedImfile", "chip_id", id, class_id); 467 450 break; 468 case PSTAMP_WARP:451 case WARP_IMAGE: 469 452 uris = findURIs(options, "warpSkyfile", "warp_id", id, NULL); 470 453 break; 471 case PSTAMP_DIFF:454 case DIFF_IMAGE: 472 455 uris = findURIs(options, "diffSkyfile", "diff_id", id, NULL); 473 456 break; 474 case PSTAMP_STACK:457 case STACK_IMAGE: 475 458 uris = findURIs(options, "stackSumSkyfile", "stack_id", id, NULL); 476 459 break; 477 460 default: 478 // note: getImageType prints a message461 // note: parseImageType prints a message 479 462 return NULL; 480 463 } … … 491 474 } 492 475 493 psString exposureNameToID( pspOptions *options, psString exposure)476 psString exposureNameToID(itOptions *options, psString exposure) 494 477 { 495 478 psArray *results; … … 501 484 } 502 485 503 static psArray * parseByExp(pspOptions *options) 504 { 505 // psError(PS_ERR_UNKNOWN, true, "REQ_TYPE: byexp not implemented yet"); 506 bool status = false; 507 pstampImageType itype = getImageType(options); 508 psString class_id = psMetadataLookupStr(&status, options->md, "CLASS_ID"); 509 psString exposure = psMetadataLookupStr(NULL, options->md, "EXPOSURE"); 486 static psArray * parseByExp(itOptions *options) 487 { 488 psString class_id = options->class_id; 489 psString exposure = options->id; 510 490 psArray *uris = NULL; 511 491 … … 520 500 } 521 501 522 switch ( itype) {523 case PSTAMP_RAW:502 switch (options->imageType) { 503 case RAW_IMAGE: 524 504 if (class_id == NULL) { 525 505 // XXX: we could relax this requirement if roi is specified in sky coords and … … 530 510 uris = findURIs(options, "rawImfile", "exp_id", exp_id, class_id); 531 511 break; 532 case PSTAMP_CHIP:512 case CHIP_IMAGE: 533 513 if (class_id == NULL) { 534 514 // XXX: we could relax this requirement if roi is specified in sky coords and … … 539 519 uris = findChipURIs(options, exp_id, class_id); 540 520 break; 541 case PSTAMP_WARP:521 case WARP_IMAGE: 542 522 uris = findWarpURIs(options, exp_id); 543 523 break; 544 case PSTAMP_DIFF:524 case DIFF_IMAGE: 545 525 uris = findDiffURIs(options, exp_id); 546 526 break; 547 case PSTAMP_STACK:527 case STACK_IMAGE: 548 528 uris = findStackURIs(options, exp_id); 549 529 break; 550 530 default: 551 // note: getImageType prints an error message531 // note: parseImageType prints an error message 552 532 return NULL; 553 533 } … … 558 538 } 559 539 560 static psArray * parseByCoord( pspOptions *options)561 { 562 psError(PS TAMP_ERR_NOT_IMPLEMENTED, true, "REQ_TYPE: bycoord not implemented yet");540 static psArray * parseByCoord(itOptions *options) 541 { 542 psError(PS_ERR_UNKNOWN, true, "REQ_TYPE: bycoord not implemented yet"); 563 543 return NULL; 564 544 } 565 545 566 static psString parseROI(pspOptions *options) 567 { 546 static psString parseROI(itOptions *options) 547 { 548 psString roiString = NULL; 549 #ifdef notyet 568 550 bool status = false;; 569 psString roiString = NULL;570 571 551 psU32 coord_mask = psMetadataLookupU32(&status, options->md, "COORD_MASK"); 572 552 if (!status) { … … 609 589 } 610 590 591 #endif 611 592 return roiString; 612 593 } 613 594 614 595 static bool 615 queueOneJob (pspOptions *options, psString job_type, psString uri, psString outputBase, psString commandArgs) 616 { 617 psString cmd = NULL; 618 619 psStringAppend(&cmd, "pstamptool -addjob -req_id %" PRId64 " -job_type %s -uri %s ", 620 options->req_id, job_type, uri); 621 622 if (outputBase != NULL) { 623 psStringAppend(&cmd, "-outputBase "); 624 625 if (options->outputDirectory) { 626 psStringAppend(&cmd, "%s/", options->outputDirectory); 627 } 628 psStringAppend(&cmd, "%s", outputBase); 629 } 630 if (commandArgs) { 631 psStringAppend(&cmd, " -args '%s'", commandArgs); 632 } 633 // XXX We may want to have the data store name be different than the default DB 634 psBool status; 635 psString dbName = psMetadataLookupStr(&status, options->config->complete, "DBNAME"); 636 fprintf(stderr, "\n\n dbName is %s\n", dbName); 637 if (dbName) { 638 psStringAppend(&cmd, " -dbname %s", dbName); 639 } 640 641 psStringAppend(&cmd, " > /dev/null"); 642 643 if (options->verbose) { 644 fprintf(stderr, "excuting system(%s)\n", cmd); 645 } 646 647 int rstatus = system(cmd); 648 649 if (rstatus) { 650 fprintf(stderr, "%s failed with status: %d\n", cmd, rstatus); 651 } 652 psFree(cmd); 653 654 // TODO: should we be returning the exit status so that it can be reported? 655 return !rstatus; 656 } 657 658 static bool 659 queueJobs (pspOptions *options, psString job_type, psArray *uris, psString stamp_name, psString commandArgs) 660 { 661 int numURIs = psArrayLength(uris); 662 bool status = false; 663 664 if (numURIs == 1) { 665 // use the user tag as the outputBase 666 status = queueOneJob(options, job_type, uris->data[0], stamp_name, commandArgs); 667 } else { 668 for (int i = 0; i< numURIs; i++) { 669 psString outputBase = NULL; 670 671 // append an integer to the stamp_name to get a uniqueu outputBase 672 psStringAppend(&outputBase, "%s_%d", stamp_name, i); 673 674 status = queueOneJob(options, job_type, uris->data[i], outputBase, commandArgs); 675 psFree(outputBase); 676 677 if (!status) { 678 break; 679 } 680 } 681 } 682 683 return status; 684 } 685 686 static bool 687 turnOnResultsFile(pspOptions *options) 688 { 689 // turn off the creation of a results file for this request 690 char * query = "UPDATE pstampRequest SET resultsFile = 1 WHERE req_id = %" PRId64; 691 return p_psDBRunQuery(options->config->database, query, options->req_id); 692 } 693 694 static bool 695 queueGetImageJob(pspOptions *options, psArray *uris, psString req_type) 696 { 697 FILE *listFile; 698 psString fileName = NULL; 699 psString img_type = psMetadataLookupStr(NULL, options->md, "IMG_TYPE"); 700 701 #ifdef notdef 702 if (! turnOffResultsFile(options)) { 703 fprintf(stderr, "failed to update resultsFile for request %" PRId64 "\n", options->req_id); 704 return false; 705 } 706 #endif 707 708 if (options->outputDirectory == NULL) { 709 fprintf(stderr, "outputDirectory is required\n"); 710 return false; 711 } 712 psStringAppend(&fileName, "%s/filelist", options->outputDirectory); 713 714 listFile = fopen(fileName, "w"); 715 if (listFile == NULL) { 716 psError(PS_ERR_UNKNOWN, true, "failed to open get_image file list: %s\n", fileName); 717 return false; 718 } 719 720 for (int i=0; i<psArrayLength(uris); i++) { 721 fprintf(listFile, "%s|%s\n", (psString) uris->data[i], img_type); 722 } 723 fclose(listFile); 724 725 psString cmd = NULL; 726 psStringAppend(&cmd, "pstamptool -addjob -req_id %" PRId64 " -job_type get_image -uri %s -outputBase %s", 727 options->req_id, fileName, options->outputDirectory); 728 729 int rstatus = system(cmd); 730 if (rstatus) { 731 fprintf(stderr, "%s failed with status: %d\n", cmd, rstatus); 732 } 733 734 return rstatus == 0; 735 } 736 737 738 static bool 739 parseRequestTable(pspOptions *options) 740 { 741 bool status = false; 742 743 psString job_type = psMetadataLookupStr(&status, options->md, "JOB_TYPE"); 744 if (job_type == NULL) { 745 psError(PS_ERR_UNKNOWN, true, "bad request file: JOB_TYPE not specified"); 746 return false; 747 } 748 749 bool isStampJob = (strcmp(job_type, "stamp") == 0); 750 596 go(itOptions *options) 597 { 751 598 // how are we to select the images ? 752 psString req_type = psMetadataLookupStr(&status, options->md, "REQ_TYPE"); 753 if ( !req_type) { 599 if (options->lookupType == UNKNOWN_LOOKUP_TYPE) { 754 600 psError(PS_ERR_UNKNOWN, true, "request file has no REQ_TYPE"); 755 601 return false; … … 757 603 758 604 psString roiString = parseROI(options); 759 if (isStampJob && !roiString) {760 psError(PS_ERR_UNKNOWN, false, "need valid ROI for stamp request");761 return false;762 }763 605 764 606 psArray *uris = NULL; 765 607 766 if (!strcmp(req_type, "byid")) { 608 switch (options->lookupType) { 609 case BY_ID: 767 610 // directly by exp_id, chip_id, warp_id etc 768 769 611 uris = parseByID(options); 770 } else if (!strcmp(req_type, "byexp")) { 612 break; 613 case BY_EXP: 771 614 // images that resulted from a given exposure 772 773 615 uris = parseByExp(options); 774 } else if (!strcmp(req_type, "bycoord")) { 616 break; 617 case BY_COORD: 775 618 // images from a particular region of the sky 776 777 619 if (!roiString) { 778 fprintf(stderr, "Region of interest required with req_type: bycoord\n");620 fprintf(stderr, "Region of interest required with lookupType: bycoord\n"); 779 621 return false; 780 622 } 781 623 uris = parseByCoord(options); 782 } else {783 784 psError(PS_ERR_ UNKNOWN, true, "unknown REQ_TYPE: %s", req_type);624 break; 625 default: 626 psError(PS_ERR_PROGRAMMING, true, "unknown Lookup type: %d\n", options->lookupType); 785 627 return false; 786 628 } … … 790 632 // or are there simply no images matching the request 791 633 fprintf(stderr, "No matching images found.\n"); 792 return false; 634 // don't return an error 635 return true; 793 636 } 794 637 795 638 int numURIs = psArrayLength(uris); 796 if (options->mode == PSP_MODE_LIST_URI) { 797 // Just list the images that would have jobs queued for them 798 for (int i=0; i<numURIs; i++) { 799 fprintf(stdout, "%s\n", (psString) uris->data[i]); 800 } 801 } else { 802 psString commandArgs = roiString; 803 psString class_id = psMetadataLookupStr(&status, options->md, "CLASS_ID"); 804 // We don't check here whether class_id is required. We leave that up to 805 // ppstamp 806 if (class_id && strcmp(class_id, "null")) { 807 // TODO: the ppstamp argument needs to change to class_id 808 // perhaps allow chip as a synonym 809 psStringAppend(&commandArgs, " -chip %s", class_id); 810 } 811 psString stamp_name = psMetadataLookupStr(&status, options->md, "STAMP_NAME"); 812 813 if (options->mode == PSP_MODE_LIST_JOB) { 814 if (numURIs == 1) { 815 printf("%s %s %s %s\n", job_type, (psString) uris->data[0], 816 stamp_name ? stamp_name : "", commandArgs ? commandArgs : "") ; 817 } else { 818 // add an integer to the stamp_name 819 for (int i = 0; i < numURIs; i++) { 820 printf("%s %s %s_%d %s\n", job_type, (psString) uris->data[i], stamp_name, i, 821 commandArgs ? commandArgs :""); 822 } 823 } 824 } else if (options->mode == PSP_MODE_QUEUE_JOB) { 825 826 if (!strcmp(job_type, "stamp")) { 827 // Postage stamp job 828 if (stamp_name == NULL) { 829 psError(PS_ERR_UNKNOWN, true, "no STAMP_NAME in request file"); 830 return false; 831 } 832 833 if (!queueJobs(options, job_type, uris, stamp_name, commandArgs)) { 834 return false; 835 } 836 837 // Note: This is a DB operation 838 if (!turnOnResultsFile(options)) { 839 psError(PS_ERR_UNKNOWN, true, "failed to update resultsFile"); 840 841 // TODO: should we unqueue the jobs, set state of request to false?? 842 // Maybe get rid of the column and just use job_type to trigger creation of 843 // results file. so what if the gui doesn't need it? 844 return false; 845 } 846 } else { 847 return queueGetImageJob(options, uris, req_type); 848 } 849 850 } else { 851 // this error is actually caught by parseMode 852 fprintf(stderr, "unknown command mode found: %d\n", options->mode); 853 exit(1); 854 } 639 // Just list the images that would have jobs queued for them 640 for (int i=0; i<numURIs; i++) { 641 fprintf(stdout, "%s\n", (psString) uris->data[i]); 855 642 } 856 643 … … 860 647 int main(int argc, char *argv[]) 861 648 { 862 pspOptions *options = parseArguments(argc, argv); 863 864 // XXX: create a set of status codes to return so the 865 // scripts can distinguish between different errors. 866 // For example: 867 // If we can't connect to the DB it's a configuration problem. 868 // If a particular image doesn't contain coordinates specified that's a user "error" 869 // if there are no images of a particular ROI outside of a date range, that tells us 870 // something 871 872 if (!options) { 873 psErrorStackPrint(stderr, "unable to parse arguments"); 874 return 1; 875 } 876 877 if (!readRequestTable(options)) { 878 psErrorStackPrint(stderr, "unable to read request table"); 879 return 1; 880 } 649 itOptions *options = parseArguments(argc, argv); 881 650 882 651 if (!setupDB(options)) { … … 885 654 } 886 655 887 if (options->verbose) { 888 psMetadataPrint(stderr, options->md, 0); 889 } 890 891 if (!parseRequestTable(options)) { 892 psErrorStackPrint(stderr, "unable to parse request table"); 656 if (!go(options)) { 657 psErrorStackPrint(stderr, "error processing request"); 893 658 return 1; 894 659 }
Note:
See TracChangeset
for help on using the changeset viewer.
