Changeset 27874
- Timestamp:
- May 6, 2010, 1:55:20 PM (16 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 22 edited
-
dbconfig/changes.txt (modified) (1 diff)
-
dbconfig/pstamp.md (modified) (1 diff)
-
ippTasks/pstamp.pro (modified) (16 diffs)
-
ippTools/share/Makefile.am (modified) (1 diff)
-
ippTools/share/pstamptool_pendingcleanup.sql (added)
-
ippTools/share/pstamptool_pendingdependent.sql (modified) (1 diff)
-
ippTools/share/pstamptool_pendingreq.sql (modified) (1 diff)
-
ippTools/share/pstamptool_updatejob.sql (modified) (1 diff)
-
ippTools/share/pxadmin_create_tables.sql (modified) (1 diff)
-
ippTools/src/pstamptool.c (modified) (17 diffs)
-
ippTools/src/pstamptool.h (modified) (1 diff)
-
ippTools/src/pstamptoolConfig.c (modified) (6 diffs)
-
pstamp/scripts/Makefile.am (modified) (1 diff)
-
pstamp/scripts/dquery_finish.pl (modified) (8 diffs)
-
pstamp/scripts/dqueryparse.pl (modified) (12 diffs)
-
pstamp/scripts/pstamp_checkdependent.pl (modified) (2 diffs)
-
pstamp/scripts/pstamp_cleanup.pl (added)
-
pstamp/scripts/pstamp_dorequest.pl (modified) (1 diff)
-
pstamp/scripts/pstamp_finish.pl (modified) (12 diffs)
-
pstamp/scripts/pstamp_get_image_job.pl (modified) (3 diffs)
-
pstamp/scripts/pstamp_job_run.pl (modified) (2 diffs)
-
pstamp/scripts/pstamp_parser_run.pl (modified) (10 diffs)
-
pstamp/scripts/pstampparse.pl (modified) (7 diffs)
-
pstamp/scripts/request_finish.pl (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/dbconfig/changes.txt
r27859 r27874 1615 1615 ) ENGINE=innodb DEFAULT CHARSET=latin1; 1616 1616 1617 ALTER TABLE pstampRequest ADD COLUMN outdir VARCHAR(64) after uri; -
trunk/dbconfig/pstamp.md
r27855 r27874 30 30 outProduct STR 64 31 31 uri STR 255 32 outdir STR 255 32 33 fault S32 0 33 34 END -
trunk/ippTasks/pstamp.pro
r27857 r27874 14 14 $pstampRev_DB = 0 15 15 $pstampDep_DB = 0 16 $pstampCleanup_DB = 0 16 17 17 18 # set PS_DBSERVER if postage stamp database host is not the same as the value for DBSERVER in site.config … … 30 31 book init pstampFinish 31 32 book init pstampDependent 33 book init pstampCleanup 32 34 end 33 35 … … 58 60 active true 59 61 end 60 task pstamp.job.revert61 active true62 end63 62 task pstamp.dependent.load 64 63 active true … … 94 93 end 95 94 task pstamp.dependent.load 96 active true 95 active false 96 end 97 task pstamp.dependent.run 98 active false 97 99 end 98 100 end … … 105 107 macro pstamp.revert.off 106 108 task pstamp.job.revert 109 active false 110 end 111 end 112 macro pstamp.cleanup.on 113 task pstamp.cleanup.load 114 active true 115 end 116 task pstamp.cleanup.run 117 active true 118 end 119 end 120 macro pstamp.cleanup.off 121 task pstamp.cleanup.run 122 active false 123 end 124 task pstamp.cleanup.run 107 125 active false 108 126 end … … 157 175 158 176 task.exec 159 stdout $LOGSUBDIR/pstamp.request.load.log177 stdout NULL 160 178 stderr $LOGSUBDIR/pstamp.request.load.log 161 179 $run = pstamptool -pendingreq … … 200 218 periods -exec $RUNEXEC 201 219 periods -timeout 300 202 npending 6 203 204 task.exec 205 stdout $LOGSUBDIR/pstamp.request.run.log 220 221 task.exec 222 stdout NULL 206 223 stderr $LOGSUBDIR/pstamp.request.run.log 207 224 book npages pstampRequest -var N … … 216 233 book getword pstampRequest $pageName uri -var URI 217 234 book getword pstampRequest $pageName ds_outProduct -var PRODUCT 235 book getword pstampRequest $pageName outdir -var OUTDIR 218 236 book getword pstampRequest $pageName label -var LABEL 219 237 220 238 host anyhost 221 239 222 $run = pstamp_parser_run.pl --req_id $REQ_ID --uri $URI --product $PRODUCT -- label $LABEL --redirect-output240 $run = pstamp_parser_run.pl --req_id $REQ_ID --uri $URI --product $PRODUCT --outdir $OUTDIR --label $LABEL --redirect-output 223 241 224 242 add_standard_args run … … 261 279 262 280 task.exec 263 stdout $LOGSUBDIR/pstamp.finish.load.log281 stdout NULL 264 282 stderr $LOGSUBDIR/pstamp.finish.load.log 265 283 $run = pstamptool -completedreq … … 306 324 307 325 task.exec 308 stdout $LOGSUBDIR/request.finish.run.log326 stdout NULL 309 327 stderr $LOGSUBDIR/request.finish.run.log 310 328 book npages pstampFinish -var N … … 321 339 book getword pstampFinish $pageName name -var REQ_NAME 322 340 book getword pstampFinish $pageName outProduct -var PRODUCT 323 324 $run = request_finish.pl --req_id $REQ_ID --req_type $REQ_TYPE --req_file $URI --req_name $REQ_NAME --product $PRODUCT --redirect-output 341 book getword pstampFinish $pageName outdir -var OUTDIR 342 343 $run = request_finish.pl --req_id $REQ_ID --req_type $REQ_TYPE --req_file $URI --req_name $REQ_NAME --product $PRODUCT --outdir $OUTDIR --redirect-output 325 344 326 345 add_standard_args run … … 363 382 364 383 task.exec 365 stdout $LOGSUBDIR/pstamp.job.load.log384 stdout NULL 366 385 stderr $LOGSUBDIR/pstamp.job.load.log 367 386 $run = pstamptool -pendingjob … … 411 430 412 431 task.exec 413 stdout $LOGSUBDIR/pstamp.job.run.log432 stdout NULL 414 433 stderr $LOGSUBDIR/pstamp.job.run.log 415 434 book npages pstampJob -var N … … 489 508 490 509 task.exec 491 stdout $LOGSUBDIR/pstamp.job.revert.log510 stdout NULL 492 511 stderr $LOGSUBDIR/pstamp.job.revert.log 493 512 $run = pstamptool -revertjob -all … … 532 551 533 552 task.exec 534 stdout $LOGSUBDIR/pstamp.dependent.load.log553 stdout NULL 535 554 stderr $LOGSUBDIR/pstamp.dependent.load.log 536 555 $run = pstamptool -pendingdependent … … 660 679 end 661 680 681 task pstamp.cleanup.load 682 host local 683 684 periods -poll $LOADPOLL 685 periods -exec $LOADEXEC 686 periods -timeout 300 687 npending 1 688 689 task.exec 690 stdout NULL 691 stderr $LOGSUBDIR/pstamp.cleanup.load.log 692 $run = pstamptool -pendingcleanup 693 if ($DB:n == 0) 694 option DEFAULT 695 else 696 option $DB:$pstampCleanup_DB 697 $run = $run $PS_DBSERVER -dbname $DB:$pstampCleanup_DB 698 $pstampCleanup_DB ++ 699 if ($pstampCleanup_DB >= $DB:n) set pstampCleanup_DB = 0 700 end 701 add_poll_args run 702 add_poll_labels run 703 command $run 704 end 705 706 task.exit $EXIT_SUCCESS 707 ipptool2book stdout pstampCleanup -key req_id -uniq -setword dbname $options:0 -setword pantaskState INIT 708 if ($VERBOSE > 2) 709 echo starting request 710 book listbook pstampCleanup 711 end 712 713 process_cleanup pstampCleanup 714 end 715 716 task.exit default 717 showcommand failure 718 end 719 720 task.exit crash 721 showcommand crash 722 end 723 724 task.exit timeout 725 showcommand timeout 726 end 727 end 728 729 task pstamp.cleanup.run 730 periods -poll $RUNPOLL 731 periods -exec $RUNEXEC 732 periods -timeout 300 733 # since everything is on one file system keep npending low to avoid 734 # overloading nfs 735 736 npending 10 737 738 task.exec 739 book npages pstampCleanup -var N 740 if ($N == 0) 741 periods -exec $RUNEXEC 742 break 743 end 744 periods -exec 0.05 745 746 book getpage pstampCleanup 0 -var pageName -key pantaskState INIT 747 if ("$pageName" == "NULL") break 748 749 book setword pstampCleanup $pageName pantaskState RUN 750 book getword pstampCleanup $pageName req_id -var REQ_ID 751 book getword pstampCleanup $pageName dbname -var DBNAME 752 book getword pstampCleanup $pageName name -var NAME 753 book getword pstampCleanup $pageName outdir -var OUTDIR 754 book getword pstampCleanup $pageName uri -var URI 755 book getword pstampCleanup $pageName reqType -var REQTYPE 756 book getword pstampCleanup $pageName outProduct -var PRODUCT 757 758 # XXX: have the script set this up this 759 $MYLOGFILE=/data/ippdb02.0/pstamp/work/logs/cleanup.$REQ_ID 760 stdout $MYLOGFILE 761 stderr $MYLOGFILE 762 763 host anyhost 764 765 $run = pstamp_cleanup.pl --req_id $REQ_ID --uri $URI --product $PRODUCT --name $NAME --outdir $OUTDIR --reqType $REQTYPE 766 767 add_standard_args run 768 options $pageName 769 770 if ($VERBOSE > 1) 771 echo command $run 772 end 773 command $run 774 end 775 776 777 task.exit $EXIT_SUCCESS 778 process_exit pstampCleanup $options:0 $JOB_STATUS 779 end 780 781 task.exit default 782 showcommand failure 783 process_exit pstampCleanup $options:0 $JOB_STATUS 784 end 785 786 task.exit crash 787 showcommand crash 788 book setword pstampCleanup $options:0 pantaskState CRASH 789 end 790 791 task.exit timeout 792 showcommand timeout 793 book setword pstampCleanup $options:0 pantaskState TIMEOUT 794 end 795 end 796 -
trunk/ippTools/share/Makefile.am
r27795 r27874 226 226 pstamptool_getdependent.sql \ 227 227 pstamptool_listjob.sql \ 228 pstamptool_pendingcleanup.sql \ 228 229 pstamptool_pendingdependent.sql \ 229 230 pstamptool_pendingjob.sql \ -
trunk/ippTools/share/pstamptool_pendingdependent.sql
r27859 r27874 1 SELECT DISTINCT pstampDependent.*, 1 SELECT DISTINCT 2 pstampDependent.*, 2 3 IFNULL(Label.priority, 10000) AS priority 3 4 FROM pstampDependent -
trunk/ippTools/share/pstamptool_pendingreq.sql
r27856 r27874 4 4 pstampDataStore.outProduct AS ds_outProduct, 5 5 IFNULL(Label.priority, 10000) AS priority 6 FROM pstampRequest6 FROM pstampRequest 7 7 LEFT JOIN pstampDataStore USING(ds_id) 8 8 LEFT JOIN Label ON pstampRequest.label = Label.label -
trunk/ippTools/share/pstamptool_updatejob.sql
r27740 r27874 1 1 UPDATE pstampJob LEFT JOIN pstampDependent USING(dep_id) 2 SET pstampJob.state = '%s' 3 -- set state hook %s 2 SET -
trunk/ippTools/share/pxadmin_create_tables.sql
r27856 r27874 1303 1303 outProduct VARCHAR(64), 1304 1304 uri VARCHAR(255), 1305 outdir VARCHAR(255), 1305 1306 fault SMALLINT, 1306 1307 PRIMARY KEY(req_id), -
trunk/ippTools/src/pstamptool.c
r27856 r27874 40 40 static bool updatereqMode(pxConfig *config); 41 41 static bool revertreqMode(pxConfig *config); 42 static bool pendingcleanupMode(pxConfig *config); 42 43 static bool addjobMode(pxConfig *config); 43 44 static bool listjobMode(pxConfig *config); … … 81 82 MODECASE(PSTAMPTOOL_MODE_UPDATEREQ, updatereqMode); 82 83 MODECASE(PSTAMPTOOL_MODE_REVERTREQ, revertreqMode); 84 MODECASE(PSTAMPTOOL_MODE_PENDINGCLEANUP, pendingcleanupMode); 83 85 MODECASE(PSTAMPTOOL_MODE_ADDJOB, addjobMode); 84 86 MODECASE(PSTAMPTOOL_MODE_LISTJOB, listjobMode); … … 265 267 NULL, // outProduct 266 268 uri, 269 NULL, // outdir 267 270 0 // fault 268 271 )) { … … 341 344 } 342 345 343 static bool listreqMode(pxConfig *config)346 static bool pendingcleanupMode(pxConfig *config) 344 347 { 345 348 PS_ASSERT_PTR_NON_NULL(config, false); … … 347 350 psMetadata *where = psMetadataAlloc(); 348 351 PXOPT_COPY_S64(config->args, where, "-req_id", "req_id", "=="); 349 PXOPT_COPY_S64(config->args, where, "-not_req_id", "req_id", "!="); 350 PXOPT_COPY_STR(config->args, where, "-name", "name", "=="); 351 352 PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false); 352 pxAddLabelSearchArgs(config, where, "-label", "label", "LIKE"); 353 354 PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false); 353 355 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 354 356 355 if (!psListLength(where->list)) { 356 psError(PS_ERR_UNKNOWN, true, "-req_id or -name must be supplied"); 357 return false; 358 } 359 360 psString query = psStringCopy("SELECT * from pstampRequest"); 361 362 psString whereClause = psDBGenerateWhereConditionSQL(where, NULL); 363 psStringAppend(&query, " WHERE %s", whereClause); 364 psFree(whereClause); 365 psFree(where); 357 psString query = pxDataGet("pstamptool_pendingcleanup.sql"); 358 if (!query) { 359 psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement"); 360 return false; 361 } 362 363 if (psListLength(where->list)) { 364 psString whereClause = psDBGenerateWhereConditionSQL(where, "pstampRequest"); 365 psStringAppend(&query, " AND %s", whereClause); 366 psFree(whereClause); 367 } 368 psFree(where); 369 370 psStringAppend(&query, " ORDER BY priority DESC, req_id"); 366 371 367 372 // treat limit == 0 as "no limit" … … 385 390 } 386 391 if (!psArrayLength(output)) { 387 psTrace("pstamptool", PS_LOG_INFO, "request not found"); 388 // This causes main to exit with PS_EXIT_DATA_ERROR which the script is looking for 389 psError(PXTOOLS_ERR_CONFIG, true, "request not found"); 390 psFree(output); 391 // we return false so that the caller can determine that a request does not exist 392 return false; 392 psTrace("pstamptool", PS_LOG_INFO, "no rows found"); 393 psFree(output); 394 return true; 393 395 } 394 396 … … 405 407 } 406 408 407 static bool completedreqMode(pxConfig *config) 408 { 409 PS_ASSERT_PTR_NON_NULL(config, false); 410 411 psMetadata *where = psMetadataAlloc(); 412 pxAddLabelSearchArgs(config, where, "-label", "label", "LIKE"); 413 414 PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false); 409 static bool listreqMode(pxConfig *config) 410 { 411 PS_ASSERT_PTR_NON_NULL(config, false); 412 413 psMetadata *where = psMetadataAlloc(); 414 PXOPT_COPY_S64(config->args, where, "-req_id", "req_id", "=="); 415 PXOPT_COPY_S64(config->args, where, "-not_req_id", "req_id", "!="); 416 PXOPT_COPY_STR(config->args, where, "-name", "name", "=="); 417 418 PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false); 415 419 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 416 420 417 psString query = pxDataGet("pstamptool_completedreq.sql"); 418 419 if (psListLength(where->list)) { 420 psString whereClause = psDBGenerateWhereConditionSQL(where, NULL); 421 psStringAppend(&query, " AND %s", whereClause); 422 psFree(whereClause); 423 } 424 psFree(where); 425 426 psStringAppend(&query, " ORDER BY priority DESC, req_id"); 421 if (!psListLength(where->list)) { 422 psError(PS_ERR_UNKNOWN, true, "-req_id or -name must be supplied"); 423 return false; 424 } 425 426 psString query = psStringCopy("SELECT * from pstampRequest"); 427 428 psString whereClause = psDBGenerateWhereConditionSQL(where, NULL); 429 psStringAppend(&query, " WHERE %s", whereClause); 430 psFree(whereClause); 431 psFree(where); 427 432 428 433 // treat limit == 0 as "no limit" … … 438 443 return false; 439 444 } 445 psFree(query); 440 446 441 447 psArray *output = p_psDBFetchResult(config->dbh); … … 444 450 return false; 445 451 } 446 447 452 if (!psArrayLength(output)) { 448 psTrace("pstamptool", PS_LOG_INFO, "no rows found"); 449 psFree(output); 450 return true; 453 psTrace("pstamptool", PS_LOG_INFO, "request not found"); 454 // This causes main to exit with PS_EXIT_DATA_ERROR which the script is looking for 455 psError(PXTOOLS_ERR_CONFIG, true, "request not found"); 456 psFree(output); 457 // we return false so that the caller can determine that a request does not exist 458 return false; 451 459 } 452 460 … … 463 471 } 464 472 473 static bool completedreqMode(pxConfig *config) 474 { 475 PS_ASSERT_PTR_NON_NULL(config, false); 476 477 psMetadata *where = psMetadataAlloc(); 478 pxAddLabelSearchArgs(config, where, "-label", "label", "LIKE"); 479 480 PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false); 481 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 482 483 psString query = pxDataGet("pstamptool_completedreq.sql"); 484 485 if (psListLength(where->list)) { 486 psString whereClause = psDBGenerateWhereConditionSQL(where, NULL); 487 psStringAppend(&query, " AND %s", whereClause); 488 psFree(whereClause); 489 } 490 psFree(where); 491 492 psStringAppend(&query, " ORDER BY priority DESC, req_id"); 493 494 // treat limit == 0 as "no limit" 495 if (limit) { 496 psString limitString = psDBGenerateLimitSQL(limit); 497 psStringAppend(&query, " %s", limitString); 498 psFree(limitString); 499 } 500 501 if (!p_psDBRunQuery(config->dbh, query)) { 502 psError(PS_ERR_UNKNOWN, false, "database error"); 503 psFree(query); 504 return false; 505 } 506 507 psArray *output = p_psDBFetchResult(config->dbh); 508 if (!output) { 509 psError(PS_ERR_UNKNOWN, false, "database error"); 510 return false; 511 } 512 513 if (!psArrayLength(output)) { 514 psTrace("pstamptool", PS_LOG_INFO, "no rows found"); 515 psFree(output); 516 return true; 517 } 518 519 // negative simple so the default is true 520 if (!ippdbPrintMetadatas(stdout, output, "pstampRequest", !simple)) { 521 psError(PS_ERR_UNKNOWN, false, "failed to print array"); 522 psFree(output); 523 return false; 524 } 525 526 psFree(output); 527 528 return true; 529 } 530 465 531 static bool updatereqMode(pxConfig *config) 466 532 { 467 533 PS_ASSERT_PTR_NON_NULL(config, false); 468 534 469 PXOPT_LOOKUP_S64(req_id, config->args, "-req_id", true, false); 470 PXOPT_LOOKUP_STR(state, config->args, "-state", false, false); 471 PXOPT_LOOKUP_STR(outProduct, config->args, "-outProduct", false, false); 472 PXOPT_LOOKUP_S16(fault, config->args, "-fault", false, false); 473 PXOPT_LOOKUP_STR(uri, config->args, "-uri", false, false); 474 PXOPT_LOOKUP_STR(name, config->args, "-name", false, false); 475 PXOPT_LOOKUP_STR(reqType, config->args, "-reqType", false, false); 476 477 psString query = NULL; 478 psStringAppend(&query, "UPDATE pstampRequest SET"); 479 535 // PXOPT_LOOKUP_S64(req_id, config->args, "-req_id", true, false); 536 PXOPT_LOOKUP_STR(state, config->args, "-set_state", false, false); 537 PXOPT_LOOKUP_STR(label, config->args, "-set_label", false, false); 538 PXOPT_LOOKUP_STR(outProduct, config->args, "-set_outProduct", false, false); 539 PXOPT_LOOKUP_S16(fault, config->args, "-set_fault", false, false); 540 PXOPT_LOOKUP_STR(uri, config->args, "-set_uri", false, false); 541 PXOPT_LOOKUP_STR(outdir, config->args, "-set_outdir", false, false); 542 PXOPT_LOOKUP_STR(name, config->args, "-set_name", false, false); 543 PXOPT_LOOKUP_STR(reqType, config->args, "-set_reqType", false, false); 544 PXOPT_LOOKUP_BOOL(clearfault,config->args, "-clearfault", false); 545 546 psMetadata *where = psMetadataAlloc(); 547 PXOPT_COPY_S64(config->args, where, "-req_id", "req_id", "=="); 548 PXOPT_COPY_S64(config->args, where, "-req_id_max", "req_id", "<="); 549 PXOPT_COPY_S32(config->args, where, "-fault", "fault", "=="); 550 PXOPT_COPY_STR(config->args, where, "-state", "state", "=="); 551 pxAddLabelSearchArgs(config, where, "-label", "pstampRequest.label", "LIKE"); 552 if (!psListLength(where->list)) { 553 psFree(where); 554 psError(PXTOOLS_ERR_CONFIG, false, "search parameters are required"); 555 return false; 556 } 557 558 psString query = psStringCopy("UPDATE pstampRequest SET"); 559 560 psString stateCheck = NULL; 480 561 char c = ' '; 481 562 if (state) { 482 563 psStringAppend(&query, "%c state = '%s'", c, state); 483 564 c = ','; 565 if (!strcmp(state, "goto_cleaned")) { 566 psStringAppend(&stateCheck, " AND state != 'cleaned'"); 567 } 568 } 569 if (label) { 570 psStringAppend(&query, "%c label = '%s'", c, label); 571 c = ','; 484 572 } 485 573 if (outProduct) { … … 487 575 c = ','; 488 576 } 489 if (fault) { 577 if (outdir) { 578 psStringAppend(&query, "%c outdir = '%s'", c, outdir); 579 c = ','; 580 } 581 if (clearfault) { 582 if (fault) { 583 psError(PXTOOLS_ERR_CONFIG, true, "only one of -fault and -clearfault is allowed"); 584 return false; 585 } 586 psStringAppend(&query, "%c fault = 0", c); 587 c = ','; 588 } else if (fault) { 490 589 psStringAppend(&query, "%c fault = %d", c, fault); 491 590 c = ','; … … 503 602 c = ','; 504 603 } 505 if (!state && !outProduct && !fault && !uri && !name && !reqType) { 506 psError(PS_ERR_UNKNOWN, true, "at least one of state, outProduct, fault, uri, name, and reqType must be specified"); 507 return false; 508 } 509 510 psStringAppend(&query, " WHERE req_id = %" PRId64, req_id); 604 if (c != ',') { 605 psError(PS_ERR_UNKNOWN, true, "at least one set option is required"); 606 return false; 607 } 608 609 psString whereClause = psDBGenerateWhereConditionSQL(where, NULL); 610 psStringAppend(&query, "\nWHERE %s", whereClause); 611 psFree(whereClause); 612 psFree(where); 613 614 if (stateCheck) { 615 psStringAppend(&query, stateCheck); 616 } 511 617 512 618 if (!p_psDBRunQuery(config->dbh, query)) { … … 516 622 } 517 623 518 psU64 affected = psDBAffectedRows(config->dbh); 519 // note zero is not an error 520 if (affected > 1) { 521 psError(PS_ERR_UNKNOWN, false, "should have affected one row but %" 522 PRIu64 " rows were modified", affected); 523 return false; 524 } 624 // psU64 affected = psDBAffectedRows(config->dbh); 625 // psLogMsg("pstamptool", PS_LOG_INFO, "Updated %" PRIu64 " pstampRequests", affected); 525 626 526 627 return true; … … 778 879 return false; 779 880 } 780 PXOPT_LOOKUP_STR(state, config->args, "-state", true, false); 781 PXOPT_LOOKUP_S32(fault, config->args, "-fault", false, false); 881 882 PXOPT_LOOKUP_STR(state, config->args, "-set_state", false, false); 883 PXOPT_LOOKUP_S32(fault, config->args, "-set_fault", false, false); 884 885 if (!state && !fault) { 886 psError(PS_ERR_UNKNOWN, true, "at least one of -set_state and -set_fault is required"); 887 return false; 888 } 782 889 783 890 psMetadata *where = psMetadataAlloc(); … … 786 893 PXOPT_COPY_S64(config->args, where, "-dep_id", "dep_id", "=="); 787 894 788 psString faultStr = NULL;789 if (!fault) {790 faultStr = psStringCopy("");791 } else {792 psStringAppend(&faultStr, "\n, pstampJob.fault = %d", fault);793 }794 795 895 psString query = pxDataGet("pstamptool_updatejob.sql"); 796 896 897 char c = ' '; 898 if (state) { 899 psStringAppend(&query, "\n %c pstampJob.state = '%s'", c, state); 900 c = ','; 901 } 902 if (fault) { 903 psStringAppend(&query, "\n %c pstampJob.fault = %d", c, fault); 904 c = ','; 905 } 906 797 907 psString whereClause = psDBGenerateWhereConditionSQL(where, NULL); 798 908 psStringAppend(&query, " WHERE %s", whereClause); … … 800 910 psFree(where); 801 911 802 if (!p_psDBRunQuery F(config->dbh, query, state, faultStr)) {912 if (!p_psDBRunQuery(config->dbh, query)) { 803 913 psError(PS_ERR_UNKNOWN, false, "database error"); 804 914 psFree(query); 805 915 return false; 806 916 } 807 psFree(faultStr);808 917 psFree(query); 809 918 … … 1159 1268 PXOPT_LOOKUP_S64(dep_id, config->args, "-dep_id", true, false); 1160 1269 PXOPT_LOOKUP_STR(state, config->args, "-set_state", false, false); 1161 PXOPT_LOOKUP_S16(fault, config->args, "- fault", false, false);1270 PXOPT_LOOKUP_S16(fault, config->args, "-set_fault", false, false); 1162 1271 1163 1272 if (!fault && !state) { -
trunk/ippTools/src/pstamptool.h
r27740 r27874 34 34 PSTAMPTOOL_MODE_UPDATEREQ, 35 35 PSTAMPTOOL_MODE_REVERTREQ, 36 PSTAMPTOOL_MODE_PENDINGCLEANUP, 36 37 PSTAMPTOOL_MODE_ADDJOB, 37 38 PSTAMPTOOL_MODE_LISTJOB, -
trunk/ippTools/src/pstamptoolConfig.c
r27856 r27874 98 98 // -updatereq 99 99 psMetadata *updatereqArgs = psMetadataAlloc(); 100 psMetadataAddS64(updatereqArgs, PS_LIST_TAIL, "-req_id", 0, "req_id for which to change state", 0); 101 psMetadataAddStr(updatereqArgs, PS_LIST_TAIL, "-state", 0, "new state", NULL); 102 psMetadataAddStr(updatereqArgs, PS_LIST_TAIL, "-outProduct", 0, "define request outProduct", NULL); 103 psMetadataAddS16(updatereqArgs, PS_LIST_TAIL, "-fault", 0, "define request fault code", 0); 104 psMetadataAddStr(updatereqArgs, PS_LIST_TAIL, "-uri", 0, "define the uri", NULL); 105 psMetadataAddStr(updatereqArgs, PS_LIST_TAIL, "-name", 0, "define the name", NULL); 106 psMetadataAddStr(updatereqArgs, PS_LIST_TAIL, "-reqType", 0, "define the reqType", NULL); 100 psMetadataAddS64(updatereqArgs, PS_LIST_TAIL, "-req_id", 0, "req_id for which to update", 0); 101 psMetadataAddS64(updatereqArgs, PS_LIST_TAIL, "-req_id_max", 0, "maximum req_id for which to update", 0); 102 psMetadataAddS16(updatereqArgs, PS_LIST_TAIL, "-fault", 0, "search by fault code", 0); 103 psMetadataAddStr(updatereqArgs, PS_LIST_TAIL, "-state", 0, "search by state", NULL); 104 psMetadataAddStr(updatereqArgs, PS_LIST_TAIL, "-label", PS_META_DUPLICATE_OK, "search by pstampJob label (LIKE comparision)", NULL); 105 psMetadataAddStr(updatereqArgs, PS_LIST_TAIL, "-set_state", 0, "new state", NULL); 106 psMetadataAddStr(updatereqArgs, PS_LIST_TAIL, "-set_label", 0, "new label", NULL); 107 psMetadataAddStr(updatereqArgs, PS_LIST_TAIL, "-set_outProduct", 0, "new outProduct", NULL); 108 psMetadataAddStr(updatereqArgs, PS_LIST_TAIL, "-set_outdir", 0, "new outdir", NULL); 109 psMetadataAddS16(updatereqArgs, PS_LIST_TAIL, "-set_fault", 0, "new fault code", 0); 110 psMetadataAddStr(updatereqArgs, PS_LIST_TAIL, "-set_uri", 0, "new uri", NULL); 111 psMetadataAddStr(updatereqArgs, PS_LIST_TAIL, "-set_name", 0, "new name", NULL); 112 psMetadataAddStr(updatereqArgs, PS_LIST_TAIL, "-set_reqType", 0, "new reqType", NULL); 113 psMetadataAddBool(updatereqArgs, PS_LIST_TAIL, "-clearfault", 0, "set fault to zero", false); 107 114 108 115 // -revertreq … … 112 119 psMetadataAddStr(revertreqArgs, PS_LIST_TAIL, "-state", 0, "state to revert", NULL); 113 120 psMetadataAddStr(revertreqArgs, PS_LIST_TAIL, "-label", PS_META_DUPLICATE_OK, "search by pstampRequest label (LIKE comparision)", NULL); 121 122 // -pendingcleanup 123 psMetadata *pendingcleanupArgs = psMetadataAlloc(); 124 psMetadataAddS64(pendingcleanupArgs, PS_LIST_TAIL, "-req_id", 0, "define req_id", 0); 125 psMetadataAddS64(pendingcleanupArgs, PS_LIST_TAIL, "-ds_id", 0, "define ds_id", 0); 126 psMetadataAddStr(pendingcleanupArgs, PS_LIST_TAIL, "-label", PS_META_DUPLICATE_OK, "search by pstampRequest label (LIKE comparision)", NULL); 127 psMetadataAddU64(pendingcleanupArgs, PS_LIST_TAIL, "-limit", 0, "limit result set to N items", 0); 128 psMetadataAddBool(pendingcleanupArgs, PS_LIST_TAIL, "-simple", 0, "use the simple output format", false); 114 129 115 130 // -addjob … … 145 160 psMetadataAddS64(updatejobArgs, PS_LIST_TAIL, "-job_id", 0, "req_id for which to change state", 0); 146 161 psMetadataAddS64(updatejobArgs, PS_LIST_TAIL, "-dep_id", 0, "dep_id for which to change state", 0); 147 psMetadataAddStr(updatejobArgs, PS_LIST_TAIL, "-s tate", 0, "new state", NULL);148 psMetadataAddS16(updatejobArgs, PS_LIST_TAIL, "- fault", 0, "new result", 0);162 psMetadataAddStr(updatejobArgs, PS_LIST_TAIL, "-set_state", 0, "new state", NULL); 163 psMetadataAddS16(updatejobArgs, PS_LIST_TAIL, "-set_fault", 0, "new result", 0); 149 164 150 165 // -revertjob … … 160 175 // -getdependent 161 176 psMetadata *getdependentArgs = psMetadataAlloc(); 177 // arguabely all of these could be -set_ arguments, but since this mode is both a query and 178 // a create if doesn't exist I like it this way 162 179 psMetadataAddS64(getdependentArgs, PS_LIST_TAIL, "-stage_id", 0, "define stage id for dependent (required)", 0); 163 180 psMetadataAddStr(getdependentArgs, PS_LIST_TAIL, "-stage", 0, "define stage for dependent (required)", NULL); … … 173 190 psMetadataAddS64(updatedependentArgs, PS_LIST_TAIL, "-dep_id", 0, "define id for dependent (required)", 0); 174 191 psMetadataAddStr(updatedependentArgs, PS_LIST_TAIL, "-set_state", 0, "new value for state", NULL); 175 psMetadataAddS16(updatedependentArgs, PS_LIST_TAIL, "- fault", 0, "new value for fault", 0);192 psMetadataAddS16(updatedependentArgs, PS_LIST_TAIL, "-set_fault", 0, "new value for fault", 0); 176 193 177 194 // -revertdependent … … 227 244 PXOPT_ADD_MODE("-completedreq", "", PSTAMPTOOL_MODE_COMPLETEDREQ, completedreqArgs); 228 245 PXOPT_ADD_MODE("-revertreq", "", PSTAMPTOOL_MODE_REVERTREQ, revertreqArgs); 246 PXOPT_ADD_MODE("-pendingcleanup", "", PSTAMPTOOL_MODE_PENDINGCLEANUP, pendingcleanupArgs); 229 247 230 248 PXOPT_ADD_MODE("-addjob", "", PSTAMPTOOL_MODE_ADDJOB, addjobArgs); -
trunk/pstamp/scripts/Makefile.am
r27859 r27874 3 3 4 4 install_files = \ 5 pstamp_cleanup.pl \ 5 6 pstamp_finish.pl \ 6 7 pstamp_insert_request.pl \ -
trunk/pstamp/scripts/dquery_finish.pl
r27859 r27874 20 20 use PS::IPP::Config qw( :standard ); 21 21 22 my ( $req_id, $req_name, $req_file, $product, $out _dir, $dbname, $dbserver, $verbose, $save_temps );22 my ( $req_id, $req_name, $req_file, $product, $outdir, $dbname, $dbserver, $verbose, $save_temps ); 23 23 24 24 GetOptions( … … 27 27 'req_file=s' => \$req_file, 28 28 'product=s' => \$product, 29 'out _dir=s' => \$out_dir,29 'outdir=s' => \$outdir, 30 30 'dbname=s' => \$dbname, 31 31 'dbserver=s' => \$dbserver, … … 41 41 $err .= "--req_name is required\n" if !$req_name; 42 42 $err .= "--product is required\n" if !$product; 43 $err .= "--out _dir is required\n" if !$out_dir;43 $err .= "--outdir is required\n" if !$outdir; 44 44 45 45 die "$err" if $err; … … 76 76 die "product directory does not exist $prod_dir"; 77 77 } 78 my $out _dir = "$prod_dir/$req_name";78 my $outdir = "$prod_dir/$req_name"; 79 79 } 80 if (! -e $out _dir ) {80 if (! -e $outdir ) { 81 81 # something must have gone wrong at the parse stage 82 print STDERR "output fileset directory $out _dir does not exist\n" if $verbose;83 if (! mkdir $out _dir ) {82 print STDERR "output fileset directory $outdir does not exist\n" if $verbose; 83 if (! mkdir $outdir ) { 84 84 stop_request($req_id, $PS_EXIT_SYS_ERROR, $verbose); 85 die "cannot create output directory $out _dir";85 die "cannot create output directory $outdir"; 86 86 } 87 } elsif (! -d $out _dir) {87 } elsif (! -d $outdir) { 88 88 stop_request($req_id, $PS_EXIT_SYS_ERROR, $verbose); 89 die "output fileset directory $out _dir exists but is not a directory";89 die "output fileset directory $outdir exists but is not a directory"; 90 90 } 91 91 … … 118 118 119 119 # XXX: have the jobs produce the reglist as with postage stamp requests 120 my ($REGLIST, $reg_list) = tempfile("$out _dir/reqlist.XXXX", UNLINK => !$save_temps);120 my ($REGLIST, $reg_list) = tempfile("$outdir/reqlist.XXXX", UNLINK => !$save_temps); 121 121 122 122 foreach my $job (@jobs) { 123 123 my $job_id = $job->{job_id}; 124 124 my $response_file = "response${job_id}.fits"; 125 my $response_path = "$out _dir/$response_file";125 my $response_path = "$outdir/$response_file"; 126 126 127 127 if (-e $response_path) { … … 131 131 # do the same if we have an error file. Should the parse data be uploaded as well? 132 132 my $err_file = "parse_error.txt"; 133 if (-e "$out _dir/$err_file") {133 if (-e "$outdir/$err_file") { 134 134 print $REGLIST "$err_file|||text|\n"; 135 135 } … … 143 143 if (-s $reg_list) { 144 144 my $command = "$dsreg --add $req_name --product $product --list $reg_list"; 145 $command .= " --copy --datapath $out _dir";145 $command .= " --copy --datapath $outdir"; 146 146 $command .= " --type MOPS_DETECTABILITY_RESPONSE"; 147 147 $command .= " --ps0 $req_id"; … … 166 166 my $verbose = shift; 167 167 168 my $command = "$pstamptool -updatereq -req_id $req_id -s tate stop";169 $command .= " - fault $fault" if $fault;168 my $command = "$pstamptool -updatereq -req_id $req_id -set_state stop"; 169 $command .= " -set_fault $fault" if $fault; 170 170 $command .= " -dbname $dbname" if $dbname; 171 171 $command .= " -dbserver $dbserver" if $dbserver; -
trunk/pstamp/scripts/dqueryparse.pl
r27859 r27874 26 26 27 27 my ($no_update, $imagedb, $label); 28 my ($req_file, $req_id, $out _dir, $product, $mode, $dbname, $dbserver, $verbose, $save_temps);28 my ($req_file, $req_id, $outdir, $product, $mode, $dbname, $dbserver, $verbose, $save_temps); 29 29 my ($job_id,$rownum); # stuff from the post-update world 30 30 # … … 37 37 'job_id=s' => \$job_id, 38 38 'rownum=s' => \$rownum, 39 'out _dir=s' => \$out_dir,39 'outdir=s' => \$outdir, 40 40 'label=s' => \$label, 41 41 'product=s' => \$product, … … 52 52 if ($mode ne "list_uri") { 53 53 die "req_id is required" if !$req_id; 54 die "out _dir is required" if !$out_dir;54 die "outdir is required" if !$outdir; 55 55 die "product is required" if !$product; 56 56 } … … 80 80 # Unless we're running as a job, write the parse arguments in case we need to rerun this parsing. 81 81 if (!$job_id) { 82 my $argslist = "$out _dir/parse.args";82 my $argslist = "$outdir/parse.args"; 83 83 open ARGSLIST, ">$argslist" or my_die("failed to open argslist file $argslist", $job_id, $PS_EXIT_UNKNOWN_ERROR); 84 print ARGSLIST "--label $label --mode $mode --req_id $req_id --product $product --out _dir $out_dir --file $req_file\n";84 print ARGSLIST "--label $label --mode $mode --req_id $req_id --product $product --outdir $outdir --file $req_file\n"; 85 85 close ARGSLIST; 86 86 } … … 105 105 106 106 # Set up the workdir for this query. 107 if (! -e $out _dir ) {108 mkdir $out _dir or my_die("cannot create output directory $out_dir", $PS_EXIT_PROG_ERROR);109 } elsif (! -d $out _dir ) {110 my_die ("output fileset directory $out _dir exists but is not a directory", $PS_EXIT_PROG_ERROR);107 if (! -e $outdir ) { 108 mkdir $outdir or my_die("cannot create output directory $outdir", $PS_EXIT_PROG_ERROR); 109 } elsif (! -d $outdir ) { 110 my_die ("output fileset directory $outdir exists but is not a directory", $PS_EXIT_PROG_ERROR); 111 111 } 112 112 113 113 114 114 # Pass along the request file to the response generator. 115 my $response_file = "$out _dir/${req_name}.dresponse.${req_id}.fits";115 my $response_file = "$outdir/${req_name}.dresponse.${req_id}.fits"; 116 116 my $fault; 117 117 my $data_to_update = ''; 118 118 { 119 my $command = "$detectresponse --input $req_file --output $response_file --workdir $out _dir";119 my $command = "$detectresponse --input $req_file --output $response_file --workdir $outdir"; 120 120 $command .= " --save-temps" if $save_temps; 121 121 $command .= " --verbose" if $verbose; … … 137 137 # for the completed work, and move the response to a standardized name. 138 138 if ($fault == 0) { 139 my $command = "$pstamptool -addjob -req_id $req_id -outputBase $out _dir";139 my $command = "$pstamptool -addjob -req_id $req_id -outputBase $outdir"; 140 140 $command .= " -job_type detect_query -state stop -fault 0"; 141 141 $command .= " -rownum 1"; … … 147 147 chomp $job_id; 148 148 if ($job_id && -e $response_file) { 149 rename $response_file, "$out _dir/response${job_id}.fits";149 rename $response_file, "$outdir/response${job_id}.fits"; 150 150 } 151 151 $result = 0; … … 158 158 # Failed to run correctly, which means that we need to queue a job and flag data for updating. 159 159 # Get the dependency id for the data we're requesting be updated. 160 my $dep_id = queue_update_run($req_id,$job_id,$out _dir,$label,$data_to_update);160 my $dep_id = queue_update_run($req_id,$job_id,$outdir,$label,$data_to_update); 161 161 162 162 # Link this request to a job and link that job to any dependency 163 my $command = "$pstamptool -addjob -req_id $req_id -outputBase $out _dir";163 my $command = "$pstamptool -addjob -req_id $req_id -outputBase $outdir"; 164 164 $command .= " -job_type detect_query -state run -fault 0"; 165 165 $command .= " -rownum 1"; … … 174 174 if ($job_id && -e $response_file) { 175 175 # We shouldn't have a response file at this stage. 176 rename $response_file, "$out _dir/response${job_id}.fits";176 rename $response_file, "$outdir/response${job_id}.fits"; 177 177 } 178 178 $result = 0; … … 186 186 # which will notice that we've inserted the stopped job and decide we're finished. Easy enough. 187 187 { 188 my $command = "$pstamptool -updatereq -req_id $req_id - name $req_name -outProduct $product";189 $command .= " - fault $result" if $result;188 my $command = "$pstamptool -updatereq -req_id $req_id -set_name $req_name -set_outProduct $product"; 189 $command .= " -set_fault $result" if $result; 190 190 191 191 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = … … 201 201 # If we have to queue an update run, do so and create a new dependent 202 202 sub queue_update_run { 203 my ($req_id, $job_id, $out _dir, $label, $data_to_update) = @_;203 my ($req_id, $job_id, $outdir, $label, $data_to_update) = @_; 204 204 205 205 my ($state, $stage, $stage_id, $component, $need_magic, $imagedb) = split /\s+/, $data_to_update; … … 211 211 my $dep_id; 212 212 my $command = "$pstamptool -getdependent -stage $stage -stage_id $stage_id -imagedb $imagedb -component $component "; 213 $command .= " -outdir $out _dir";213 $command .= " -outdir $outdir"; 214 214 $command .= " -need_magic" if $need_magic; 215 215 -
trunk/pstamp/scripts/pstamp_checkdependent.pl
r27853 r27874 575 575 my ($state, $stage, $stage_id, $job_fault) = @_; 576 576 577 my $command = "$pstamptool -updatejob -s tate stop -fault $job_fault -dep_id $dep_id";577 my $command = "$pstamptool -updatejob -set_state stop -set_fault $job_fault -dep_id $dep_id"; 578 578 $command .= " -dbname $dbname" if $dbname; 579 579 $command .= " -dbserver $dbserver" if $dbserver; … … 642 642 carp $msg; 643 643 644 my $command = "$pstamptool -updatedependent - fault $fault -dep_id $dep_id";644 my $command = "$pstamptool -updatedependent -set_fault $fault -dep_id $dep_id"; 645 645 $command .= " -dbname $dbname" if $dbname; 646 646 $command .= " -dbserver $dbserver" if $dbserver; -
trunk/pstamp/scripts/pstamp_dorequest.pl
r19221 r27874 106 106 { 107 107 ## TODO: what about request status 108 my $command = "$pstamptool -updatereq -req_id $request_id -s tate stop";108 my $command = "$pstamptool -updatereq -req_id $request_id -set_state stop"; 109 109 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 110 110 run(command => $command, verbose => $verbosity); -
trunk/pstamp/scripts/pstamp_finish.pl
r27751 r27874 25 25 use PS::IPP::PStamp::Job qw( :standard ); 26 26 27 my ( $req_id, $req_name, $req_file, $out _dir, $product, $dbname, $dbserver, $verbose, $save_temps, $redirect_output);27 my ( $req_id, $req_name, $req_file, $outdir, $product, $dbname, $dbserver, $verbose, $save_temps, $redirect_output); 28 28 29 29 # the char to the right of the bar may be used as a single - alias for the longer name … … 34 34 'req_file=s' => \$req_file, 35 35 'product=s' => \$product, 36 'out _dir=s' => \$out_dir,36 'outdir=s' => \$outdir, 37 37 'dbname=s' => \$dbname, 38 38 'dbserver=s' => \$dbserver, … … 44 44 pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV; 45 45 46 die "usage: --req_id id --req_name name --req_file file --product product --out _dir output_directory [--dbname dbname --verbose]\n"47 if !$req_id or !$req_name or !$req_file or !$product or !$out _dir;46 die "usage: --req_id id --req_name name --req_file file --product product --outdir output_directory [--dbname dbname --verbose]\n" 47 if !$req_id or !$req_name or !$req_file or !$product or !$outdir; 48 48 49 49 my $ipprc = PS::IPP::Config->new(); # IPP Configuration 50 50 if ($redirect_output) { 51 my $logDest = "$out _dir/psfinish.$req_id.log";51 my $logDest = "$outdir/psfinish.$req_id.log"; 52 52 $ipprc->redirect_output($logDest); 53 53 } … … 82 82 my $fileset = $req_name; 83 83 84 print STDERR "product: $product REQ_NAME: $req_name $out _dir\n" if $verbose;85 86 if (!-e $out _dir) {84 print STDERR "product: $product REQ_NAME: $req_name $outdir\n" if $verbose; 85 86 if (!-e $outdir) { 87 87 # something must have gone wrong parsing the request 88 print STDERR "output directory $out _dir does not exist\n";89 90 if (!mkdir $out _dir) {91 print STDERR "cannot create output directory $out _dir";88 print STDERR "output directory $outdir does not exist\n"; 89 90 if (!mkdir $outdir) { 91 print STDERR "cannot create output directory $outdir"; 92 92 stop_request_and_exit($req_id, $PS_EXIT_UNKNOWN_ERROR); 93 93 } 94 94 95 95 96 } elsif (! -d $out _dir ) {96 } elsif (! -d $outdir ) { 97 97 # XXX TODO: fault the request so we pstamp_finish doesn't keep trying to process the 98 98 # request 99 print STDERR "output directory $out _dir exists but is not a directory";99 print STDERR "output directory $outdir exists but is not a directory"; 100 100 stop_request_and_exit($req_id, $PS_EXIT_UNKNOWN_ERROR); 101 101 } … … 122 122 # the following is for a postage stamp request 123 123 124 my ($rlf, $reglist_name) = tempfile ("$out _dir/reglist.XXXX", UNLINK => !$save_temps);124 my ($rlf, $reglist_name) = tempfile ("$outdir/reglist.XXXX", UNLINK => !$save_temps); 125 125 print $rlf "results.fits|||table|\n"; 126 126 print $rlf "results.mdc|||text|\n"; 127 127 128 128 my $err_file = "parse_error.txt"; 129 if (-e "$out _dir/$err_file" ) {129 if (-e "$outdir/$err_file" ) { 130 130 print $rlf "$err_file|||text|\n"; 131 131 } 132 132 133 my ($tdf, $table_def_name) = tempfile ("$out _dir/tabledef.XXXX", UNLINK => !$save_temps);133 my ($tdf, $table_def_name) = tempfile ("$outdir/tabledef.XXXX", UNLINK => !$save_temps); 134 134 135 135 … … 208 208 209 209 if (($job_type eq "stamp") || ($job_type eq "get_image") || ($job_type eq "none")) { 210 my $jreglist = "$out _dir/reglist$job_id";210 my $jreglist = "$outdir/reglist$job_id"; 211 211 if (open JRL, "<$jreglist") {; 212 212 # process the reglist file to get the list of files produced by this job … … 225 225 # If not found check the PHU. If that doesn't work just set them to zero. 226 226 # XXX do this more cleanly 227 my (undef, $ra_deg, $dec_deg) = split " ", `echo $out _dir/$img_name | fields -x 0 RA_DEG DEC_DEG`;227 my (undef, $ra_deg, $dec_deg) = split " ", `echo $outdir/$img_name | fields -x 0 RA_DEG DEC_DEG`; 228 228 if (!defined $ra_deg) { 229 (undef, $ra_deg, $dec_deg) = split " ", `echo $out _dir/$img_name | fields RA_DEG DEC_DEG`;229 (undef, $ra_deg, $dec_deg) = split " ", `echo $outdir/$img_name | fields RA_DEG DEC_DEG`; 230 230 } 231 231 $ra_deg = 0.0 if (!$ra_deg); … … 258 258 # make the results file 259 259 { 260 my $command = "$pstamp_results --input $table_def_name --output $out _dir/results.fits";260 my $command = "$pstamp_results --input $table_def_name --output $outdir/results.fits"; 261 261 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 262 262 run(command => $command, verbose => $verbose); … … 266 266 } else { 267 267 # dump a textual representation 268 my $command = "$pstampdump $out _dir/results.fits > $out_dir/results.mdc";268 my $command = "$pstampdump $outdir/results.fits > $outdir/results.mdc"; 269 269 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 270 270 run(command => $command, verbose => $verbose); … … 278 278 # register the fileset 279 279 my $command = "$dsreg --list $reglist_name --add $fileset --product $product --type PSRESULTS"; 280 $command .= " --link --datapath $out_dir --ps0 $req_id"; 281 $command .= " --dbname $dbname" if $dbname; 280 $command .= " --link --datapath $outdir --ps0 $req_id"; 281 # XXX: let dsreg and config handle resolving dbname and dbserver 282 # $command .= " --dbname $dbname" if $dbname; 282 283 283 284 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = … … 292 293 # set the request's state to stop 293 294 { 294 my $command = "$pstamptool -updatereq -req_id $req_id -s tate stop -fault $request_fault";295 my $command = "$pstamptool -updatereq -req_id $req_id -set_state stop -set_fault $request_fault"; 295 296 $command .= " -dbname $dbname" if $dbname; 296 297 $command .= " -dbserver $dbserver" if $dbserver; … … 308 309 my $fault = shift; 309 310 310 my $command = "$pstamptool -updatereq -req_id $req_id -s tate stop -fault $fault";311 my $command = "$pstamptool -updatereq -req_id $req_id -set_state stop -set_fault $fault"; 311 312 $command .= " -dbname $dbname" if $dbname; 312 313 $command .= " -dbserver $dbserver" if $dbserver; -
trunk/pstamp/scripts/pstamp_get_image_job.pl
r26215 r27874 87 87 } 88 88 89 my $out _dir = dirname($output_base);89 my $outdir = dirname($output_base); 90 90 my $prefix = basename($output_base) . "_"; 91 91 my $results_file = $output_base . ".bundle_results"; … … 102 102 my $command = "$dist_bundle --camera $camera --stage $stage --stage_id $stage_id"; 103 103 $command .= " --component $component"; 104 $command .= " --path_base $path_base --outdir $out _dir --results_file $results_file";104 $command .= " --path_base $path_base --outdir $outdir --results_file $results_file"; 105 105 $command .= " --prefix $prefix"; 106 106 $command .= " --magicked" if $magicked; … … 139 139 } 140 140 141 my $reglist = "$out _dir/reglist$job_id";141 my $reglist = "$outdir/reglist$job_id"; 142 142 if (! open(REGLIST, ">$reglist") ) { 143 143 my_die("failed to open registration list: $reglist", $PS_EXIT_UNKNOWN_ERROR); -
trunk/pstamp/scripts/pstamp_job_run.pl
r27859 r27874 198 198 # mark the job stopped in the database 199 199 { 200 my $command = "$pstamptool -updatejob -job_id $job_id -s tate stop";201 $command .= " - fault $jobStatus" if $jobStatus;200 my $command = "$pstamptool -updatejob -job_id $job_id -set_state stop"; 201 $command .= " -set_fault $jobStatus" if $jobStatus; 202 202 $command .= " -dbname $dbname" if $dbname; 203 203 $command .= " -dbserver $dbserver" if $dbserver; … … 343 343 my $command = "$pstamptool -updatejob"; 344 344 $command .= " -job_id $job_id"; 345 $command .= " - fault $exit_code";345 $command .= " -set_fault $exit_code"; 346 346 # XXX: fix pstamptool to not require -state when -fault with nonzero value is provided 347 $command .= " -s tate run";347 $command .= " -set_state run"; 348 348 $command .= " -dbname $dbname" if defined $dbname; 349 349 $command .= " -dbserver $dbserver" if defined $dbserver; -
trunk/pstamp/scripts/pstamp_parser_run.pl
r27859 r27874 28 28 my $redirect_output; 29 29 my $product; 30 my $outdir; 30 31 my $label; 31 32 my $verbose; … … 37 38 'uri=s' => \$uri, 38 39 'product=s' => \$product, 40 'outdir=s' => \$outdir, 39 41 'label=s' => \$label, 40 42 'redirect-output' => \$redirect_output, … … 81 83 } 82 84 83 # workdir is where all of the files generated for this request are placed 84 # NOTE: this location needs to be kept in sync with the web interface ( request.php ) 85 my $datestr = strftime "%Y%m%d", gmtime; 86 my $datedir = "$pstamp_workdir/$datestr"; 87 if (! -e $datedir ) { 88 mkdir $datedir or my_die( "failed to create working directory $datedir for request id $req_id", $req_id, 85 if (!$outdir or ($outdir eq "NULL")) { 86 # workdir is where all of the files generated for this request are placed 87 # NOTE: this location needs to be kept in sync with the web interface ( request.php ) 88 my $datestr = strftime "%Y%m%d", gmtime; 89 my $datedir = "$pstamp_workdir/$datestr"; 90 if (! -e $datedir ) { 91 mkdir $datedir or my_die( "failed to create working directory $datedir for request id $req_id", $req_id, 92 $PS_EXIT_CONFIG_ERROR); 93 } 94 95 $outdir = "$datedir/$req_id"; 96 } 97 98 if (! -e $outdir ) { 99 mkdir $outdir or my_die("failed to create working directory $outdir for request id $req_id", $req_id, 89 100 $PS_EXIT_CONFIG_ERROR); 90 101 } 91 92 my $workdir = "$datedir/$req_id"; 93 if (! -e $workdir ) { 94 mkdir $workdir or my_die("failed to create working directory $workdir for request id $req_id", $req_id, 95 $PS_EXIT_CONFIG_ERROR); 96 } 102 97 103 98 104 if ($redirect_output) { 99 my $logDest = "$ workdir/psparse.$req_id.log";105 my $logDest = "$outdir/psparse.$req_id.log"; 100 106 $ipprc->redirect_output($logDest); 101 107 } … … 108 114 109 115 my $fn = basename($uri); 110 my $new_uri = "$ workdir/$fn";116 my $new_uri = "$outdir/$fn"; 111 117 if ($uri =~ /^http:/) { 112 118 # if the uri is an http uri download the file … … 123 129 } 124 130 if (! copy $uri, $new_uri) { 125 my_die ("failed to copy request file $uri to workdir $ workdir", $req_id, $PS_EXIT_UNKNOWN_ERROR);131 my_die ("failed to copy request file $uri to workdir $outdir", $req_id, $PS_EXIT_UNKNOWN_ERROR); 126 132 } 127 133 } … … 173 179 # that they sent us a request file that we don't understand 174 180 175 my $command = "$pstamptool -updatereq -req_id $req_id -s tate run";176 $command .= " - reqType unknown";177 $command .= " - fault $PS_EXIT_DATA_ERROR";181 my $command = "$pstamptool -updatereq -req_id $req_id -set_state run"; 182 $command .= " -set_reqType unknown"; 183 $command .= " -set_fault $PS_EXIT_DATA_ERROR"; 178 184 $command .= " -dbname $dbname" if $dbname; 179 185 $command .= " -dbserver $dbserver" if $dbserver; … … 186 192 } 187 193 188 $parse_cmd .= " --mode queue_job --req_id $req_id --product $product --out _dir $workdir --file $uri";194 $parse_cmd .= " --mode queue_job --req_id $req_id --product $product --outdir $outdir --file $uri"; 189 195 $parse_cmd .= " --dbname $dbname" if $dbname; 190 196 $parse_cmd .= " --dbserver $dbserver" if $dbserver; … … 194 200 my $fault; 195 201 { 196 my $error_file_name = "$ workdir/parse_error.txt";202 my $error_file_name = "$outdir/parse_error.txt"; 197 203 # get rid of any error file from previous attempt to parse this request 198 204 unlink $error_file_name if (-e $error_file_name); … … 227 233 # 228 234 { 229 my $command = "$pstamptool -updatereq -req_id $req_id -state $newState"; 230 $command .= " -reqType $reqType" if $reqType; 231 $command .= " -uri $new_uri" if $new_uri; 232 $command .= " -fault $fault" if $fault; 235 my $command = "$pstamptool -updatereq -req_id $req_id -set_state $newState"; 236 $command .= " -set_outdir $outdir"; 237 $command .= " -set_reqType $reqType" if $reqType; 238 $command .= " -set_uri $new_uri" if $new_uri; 239 $command .= " -set_fault $fault" if $fault; 233 240 $command .= " -dbname $dbname" if $dbname; 234 241 $command .= " -dbserver $dbserver" if $dbserver; … … 269 276 carp($msg); 270 277 271 my $command = "$pstamptool -updatereq -req_id $req_id - fault $fault";278 my $command = "$pstamptool -updatereq -req_id $req_id -set_fault $fault"; 272 279 $command .= " -dbname $dbname" if $dbname; 273 280 $command .= " -dbserver $dbserver" if $dbserver; -
trunk/pstamp/scripts/pstampparse.pl
r27854 r27874 25 25 my $request_file_name; 26 26 my $mode = "list_uri"; 27 my $out _dir;27 my $outdir; 28 28 my $product; 29 29 my $label; … … 34 34 'file=s' => \$request_file_name, 35 35 'req_id=s' => \$req_id, 36 'out _dir=s' => \$out_dir,36 'outdir=s' => \$outdir, 37 37 'product=s' => \$product, 38 38 'label=s' => \$label, … … 50 50 if ($mode ne "list_uri") { 51 51 die "req_id is required" if !$req_id; 52 die "out _dir is required" if !$out_dir;52 die "outdir is required" if !$outdir; 53 53 die "product is required" if !$product; 54 54 } … … 129 129 # update the database with the request name. This will be used as the 130 130 # the output data store's product name 131 my $command = "$pstamptool -updatereq -req_id $req_id - name $req_name";132 $command .= " - outProduct $product";131 my $command = "$pstamptool -updatereq -req_id $req_id -set_name $req_name"; 132 $command .= " -set_outProduct $product"; 133 133 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 134 134 run(command => $command, verbose => $verbose); … … 522 522 $base =~ s/.fits$//; 523 523 524 my $output_base = "$out _dir/${rownum}_${job_num}_${base}";524 my $output_base = "$outdir/${rownum}_${job_num}_${base}"; 525 525 my $argslist = "${output_base}.args"; 526 526 … … 712 712 my $exp_id = $image->{exp_id}; 713 713 714 my $output_base = "$out _dir/${rownum}_${job_num}";714 my $output_base = "$outdir/${rownum}_${job_num}"; 715 715 716 716 write_params($output_base, $image); … … 894 894 895 895 my $dep_id; 896 my $command = "$pstamptool -getdependent -stage $stage -stage_id $stage_id -imagedb $imagedb -component $component -outdir $out _dir";896 my $command = "$pstamptool -getdependent -stage $stage -stage_id $stage_id -imagedb $imagedb -component $component -outdir $outdir"; 897 897 $command .= " -need_magic" if $need_magic; 898 898 -
trunk/pstamp/scripts/request_finish.pl
r24831 r27874 21 21 use PS::IPP::Config qw( :standard ); 22 22 23 my ( $req_id, $req_name, $req_file, $req_type, $out _dir, $product, $dbname, $dbserver, $verbose, $save_temps, $redirect_output );23 my ( $req_id, $req_name, $req_file, $req_type, $outdir, $product, $dbname, $dbserver, $verbose, $save_temps, $redirect_output ); 24 24 25 25 GetOptions( … … 28 28 'req_file=s' => \$req_file, 29 29 'req_type=s' => \$req_type, 30 'out _dir=s' => \$out_dir,30 'outdir=s' => \$outdir, 31 31 'product=s' => \$product, 32 32 'dbname=s' => \$dbname, … … 46 46 $err .= "--req_name is required\n" if !$req_name; 47 47 $err .= "--product is required\n" if !$product; 48 # $err .= "--out _dir is required\n" if !$out_dir;48 # $err .= "--outdir is required\n" if !$outdir; 49 49 50 50 die "$err" if $err; 51 51 52 52 53 if (!$out _dir) {54 $out _dir = dirname($req_file);53 if (!$outdir) { 54 $outdir = dirname($req_file); 55 55 } 56 56 57 57 if ($redirect_output) { 58 my $logDest = "$out _dir/reqfinish.$req_id.log";58 my $logDest = "$outdir/reqfinish.$req_id.log"; 59 59 my $ipprc = PS::IPP::Config->new(); 60 60 $ipprc->redirect_output($logDest); … … 79 79 } 80 80 if ($finish_cmd) { 81 my $command = $finish_cmd . " --req_id $req_id --req_name $req_name --req_file $req_file --product $product --out _dir $out_dir";81 my $command = $finish_cmd . " --req_id $req_id --req_name $req_name --req_file $req_file --product $product --outdir $outdir"; 82 82 $command .= " --dbname $dbname" if $dbname; 83 83 $command .= " --dbserver $dbserver" if $dbserver;
Note:
See TracChangeset
for help on using the changeset viewer.
