Changeset 16933
- Timestamp:
- Mar 10, 2008, 5:06:08 PM (18 years ago)
- Location:
- trunk/pstamp
- Files:
-
- 1 added
- 1 deleted
- 4 edited
-
scripts/Makefile.am (modified) (2 diffs)
-
scripts/ppstamp_run.pl (deleted)
-
scripts/pstamp_job_run.pl (added)
-
src/pstampfinish.c (modified) (3 diffs)
-
src/pstampparse.c (modified) (9 diffs)
-
src/pstamprequest.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/pstamp/scripts/Makefile.am
r16675 r16933 3 3 4 4 install_files = \ 5 p pstamp_run.pl \5 pstamp_job_run.pl \ 6 6 pstamp_listjobs.pl \ 7 7 pstamp_new_request.sh \ … … 9 9 pstamp_queue_requests.pl \ 10 10 pstamp_runcommand.sh \ 11 pstamp_webrequest.pl 11 pstamp_webrequest.pl \ 12 pstamp_get_image_job.pl 12 13 13 14 install_SCRIPTS = $(install_files) -
trunk/pstamp/src/pstampfinish.c
r16878 r16933 182 182 } 183 183 184 static bool finishRequest(psrfOptions *options, pstampRequestRow *pReq, psArray *stoppedJobs)184 static bool buildResultsFile(psrfOptions *options, pstampRequestRow *pReq, psArray *stoppedJobs) 185 185 { 186 186 // build results file in dsRoot/pReq->outFileset … … 238 238 psString command = NULL; 239 239 240 psStringAppend(&command, "dsreg --add --type PSRES PONSE--product %s --fileset %s",240 psStringAppend(&command, "dsreg --add --type PSRESULTS --product %s --fileset %s", 241 241 options->dsProduct, fileset_id); 242 242 … … 266 266 psError(PS_ERR_UNKNOWN, true, "dsreg failed with status: %d", status); 267 267 return false; 268 } 269 270 return true; 271 } 272 static bool finishRequest(psrfOptions *options, pstampRequestRow *pReq, psArray *stoppedJobs) 273 { 274 if (pReq->resultsFile) { 275 if (!buildResultsFile(options, pReq, stoppedJobs)) { 276 return false; 277 } 268 278 } 269 279 // update the database setting the request state to stop -
trunk/pstamp/src/pstampparse.c
r16897 r16933 72 72 psArgumentRemove(argnum, &argc, argv); 73 73 } 74 74 75 if ((argnum = psArgumentGet(argc, argv, "-req_id"))) { 75 76 psArgumentRemove(argnum, &argc, argv); 76 77 if (argnum == argc) { 77 fprintf(stderr, "value required for mode\n");78 fprintf(stderr, "value required for req_id\n"); 78 79 usage(); 79 80 } … … 598 599 599 600 static bool 600 queueOneJob (pspOptions *options, psString uri, psString outputBase, psString commandArgs)601 queueOneJob (pspOptions *options, psString job_type, psString uri, psString outputBase, psString commandArgs) 601 602 { 602 603 psString cmd = NULL; 603 604 604 psStringAppend(&cmd, "pstamptool -addjob -req_id %ld -uri %s -outputBase ", options->req_id, uri); 605 psStringAppend(&cmd, "pstamptool -addjob -req_id %ld -job_type %s -uri %s ", 606 options->req_id, job_type, uri); 605 607 606 if (options->outputDirectory) { 607 psStringAppend(&cmd, "%s/", options->outputDirectory); 608 } 608 if (outputBase != NULL) { 609 psStringAppend(&cmd, "-outputBase "); 609 610 610 psStringAppend(&cmd, "%s -args '%s' >/dev/null", outputBase, commandArgs); 611 if (options->outputDirectory) { 612 psStringAppend(&cmd, "%s/", options->outputDirectory); 613 } 614 psStringAppend(&cmd, "%s", outputBase); 615 } 616 if (commandArgs) { 617 psStringAppend(&cmd, " -args '%s'", commandArgs); 618 } 619 psStringAppend(&cmd, " > /dev/null"); 611 620 612 621 if (options->verbose) { … … 626 635 627 636 static bool 628 queueJobs (pspOptions *options, ps Array *uris, psString user_tag, psString commandArgs)637 queueJobs (pspOptions *options, psString job_type, psArray *uris, psString user_tag, psString commandArgs) 629 638 { 630 639 int numURIs = psArrayLength(uris); … … 633 642 if (numURIs == 1) { 634 643 // use the user tag as the outputBase 635 status = queueOneJob(options, uris->data[0], user_tag, commandArgs);644 status = queueOneJob(options, job_type, uris->data[0], user_tag, commandArgs); 636 645 } else { 637 646 for (int i = 0; i< numURIs; i++) { … … 641 650 psStringAppend(&outputBase, "%s_%d", user_tag, i); 642 651 643 status = queueOneJob(options, uris->data[i], outputBase, commandArgs);652 status = queueOneJob(options, job_type, uris->data[i], outputBase, commandArgs); 644 653 psFree(outputBase); 645 654 … … 653 662 } 654 663 664 static bool 665 turnOffResultsFile(pspOptions *options) 666 { 667 // turn off the creation of a results file for this request 668 char * query = "UPDATE pstampRequest SET resultsFile = 0 WHERE req_id = %" PRId64; 669 return p_psDBRunQuery(options->config->database, query, options->req_id); 670 } 671 672 static bool 673 queueGetImageJob(pspOptions *options, psArray *uris, psString req_type) 674 { 675 FILE *listFile; 676 psString fileName = NULL; 677 psString img_type = psMetadataLookupStr(NULL, options->md, "IMG_TYPE"); 678 679 if (! turnOffResultsFile(options)) { 680 fprintf(stderr, "failed to update resultsFile for request %" PRId64 "\n", options->req_id); 681 return false; 682 } 683 684 if (options->outputDirectory == NULL) { 685 fprintf(stderr, "outputDirectory is required\n"); 686 return false; 687 } 688 psStringAppend(&fileName, "%s/filelist", options->outputDirectory); 689 690 listFile = fopen(fileName, "w"); 691 if (listFile == NULL) { 692 psError(PS_ERR_UNKNOWN, true, "failed to open get_image file list: %s\n", fileName); 693 return false; 694 } 695 696 for (int i=0; i<psArrayLength(uris); i++) { 697 fprintf(listFile, "%s|%s\n", (psString) uris->data[i], img_type); 698 } 699 fclose(listFile); 700 701 psString cmd = NULL; 702 psStringAppend(&cmd, "pstamptool -addjob -req_id %ld -job_type get_image -uri %s -outputBase %s", 703 options->req_id, fileName, options->outputDirectory); 704 705 int rstatus = system(cmd); 706 if (rstatus) { 707 fprintf(stderr, "%s failed with status: %d\n", cmd, rstatus); 708 } 709 710 return rstatus == 0; 711 } 712 655 713 656 714 static bool … … 658 716 { 659 717 bool status; 718 psString job_type = psMetadataLookupStr(&status, options->md, "JOB_TYPE"); 719 720 if (job_type == NULL) { 721 // XXX: compatiabilty hack change to error at some point 722 job_type = "stamp"; 723 } 724 660 725 psString cmd_mode = psMetadataLookupStr(&status, options->md, "CMD_MODE"); 661 726 662 // if mode is set on the command line ignore the value in the request file727 // if cmd_mode is set on the command line ignore the value in the request file 663 728 if (options->mode == PSP_MODE_UNKNOWN) { 664 729 if (cmd_mode != NULL) { … … 682 747 return false; 683 748 } 749 684 750 psString roiString = parseROI(options); 685 #ifdef notdef686 if (!roiString) {687 return false;688 }689 #endif690 751 691 752 psArray *uris = NULL; 753 692 754 if (!strcmp(req_type, "byid")) { 693 755 // directly by exp_id, chip_id, warp_id etc 756 694 757 uris = parseByID(options); 695 758 } else if (!strcmp(req_type, "byexp")) { 696 759 // images that resulted from a given exposure 760 697 761 uris = parseByExp(options); 698 762 } else if (!strcmp(req_type, "bycoord")) { 699 763 // images from a particular region of the sky 764 700 765 if (!roiString) { 701 fprintf(stderr, " req_type: bycoord with NULL ROI\n");766 fprintf(stderr, "Region of interest required with req_type: bycoord\n"); 702 767 return false; 703 768 } 704 769 uris = parseByCoord(options); 705 770 } else { 771 706 772 psError(PS_ERR_UNKNOWN, true, "unknown REQ_TYPE: %s", req_type); 707 773 return false; … … 728 794 psStringAppend(&commandArgs, " -chip %s", class_id); 729 795 } 730 731 796 psString user_tag = psMetadataLookupStr(&status, options->md, "USER_TAG"); 732 if (user_tag == NULL) {733 psError(PS_ERR_UNKNOWN, true, "no user tag in request file");734 return false;735 }736 797 737 798 if (options->mode == PSP_MODE_LIST_JOB) { 738 799 if (numURIs == 1) { 739 printf("%s %s %s\n", (psString) uris->data[0], user_tag, commandArgs); 800 printf("%s %s %s %s\n", job_type, (psString) uris->data[0], 801 user_tag ? user_tag : "", commandArgs ? commandArgs : "") ; 740 802 } else { 741 803 // add an integer to the user_tag 742 804 for (int i = 0; i < numURIs; i++) { 743 printf("%s %s_%d %s\n", (psString) uris->data[i], user_tag, i, commandArgs); 805 printf("%s %s %s_%d %s\n", job_type, (psString) uris->data[i], user_tag, i, 806 commandArgs ? commandArgs :""); 744 807 } 745 808 } 746 809 } else if (options->mode == PSP_MODE_QUEUE_JOB) { 747 810 748 if (!queueJobs(options, uris, user_tag, commandArgs)) { 749 return false; 811 if (!strcmp(job_type, "stamp")) { 812 // Postage stamp job 813 if (user_tag == NULL) { 814 psError(PS_ERR_UNKNOWN, true, "no user tag in request file"); 815 return false; 816 } 817 818 if (!queueJobs(options, job_type, uris, user_tag, commandArgs)) { 819 return false; 820 } 821 } else { 822 823 return queueGetImageJob(options, uris, req_type); 750 824 } 751 825 -
trunk/pstamp/src/pstamprequest.c
r16898 r16933 105 105 psMetadata *md = psMetadataAlloc(); 106 106 int argnum; 107 bool gotStyle = false;107 bool gotStyle = false; 108 108 bool needCoord = false; 109 109 bool gotCenter = false; 110 bool gotRange = false;111 bool needROI = true;110 bool gotRange = false; 111 bool needROI = true; 112 112 bool makeStamps = true; 113 113 … … 116 116 psMetadataAdd (md, PS_LIST_TAIL, "VERSION", PS_DATA_STRING, "", STAMP_REQUEST_VERSION); 117 117 118 // These mode arguments should be consistent with pstampparse 118 119 if ((argnum = psArgumentGet(argc, argv, "-list"))) { 119 psMetadataAdd (md, PS_LIST_TAIL, "CMD_MODE", PS_DATA_STRING, "", " LIST_URI");120 psMetadataAdd (md, PS_LIST_TAIL, "CMD_MODE", PS_DATA_STRING, "", "list_uri"); 120 121 psArgumentRemove(argnum, &argc, argv); 121 122 // we don't need coordinates if we're listing unless mode is -bycoord. May be set true below. … … 123 124 makeStamps = false; 124 125 } 126 127 if ((argnum = psArgumentGet(argc, argv, "-get_image"))) { 128 psMetadataAdd (md, PS_LIST_TAIL, "JOB_TYPE", PS_DATA_STRING, "", "get_image"); 129 psArgumentRemove(argnum, &argc, argv); 130 // we don't need coordinates if we're listing unless mode is -bycoord. May be set true below. 131 needROI = false; 132 makeStamps = false; 133 } else { 134 psMetadataAdd (md, PS_LIST_TAIL, "JOB_TYPE", PS_DATA_STRING, "", "stamp"); 135 } 136 125 137 126 138 // get project from command line
Note:
See TracChangeset
for help on using the changeset viewer.
