IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 27874


Ignore:
Timestamp:
May 6, 2010, 1:55:20 PM (16 years ago)
Author:
bills
Message:

Various changes to the postage stamp server and associated tables.
Implemented cleanup. Added pstampRequest.outdir changed spelling of out_dir
to outdir. various other cleanups

Location:
trunk
Files:
2 added
22 edited

Legend:

Unmodified
Added
Removed
  • trunk/dbconfig/changes.txt

    r27859 r27874  
    16151615) ENGINE=innodb DEFAULT CHARSET=latin1;
    16161616
     1617ALTER TABLE pstampRequest ADD COLUMN outdir VARCHAR(64) after uri;
  • trunk/dbconfig/pstamp.md

    r27855 r27874  
    3030    outProduct  STR         64
    3131    uri         STR         255
     32    outdir      STR         255
    3233    fault       S32         0
    3334END
  • trunk/ippTasks/pstamp.pro

    r27857 r27874  
    1414$pstampRev_DB = 0
    1515$pstampDep_DB = 0
     16$pstampCleanup_DB = 0
    1617
    1718# set PS_DBSERVER if postage stamp database host is not the same as the value for DBSERVER in site.config
     
    3031    book init pstampFinish
    3132    book init pstampDependent
     33    book init pstampCleanup
    3234end
    3335
     
    5860        active true
    5961    end
    60     task pstamp.job.revert
    61         active true
    62     end
    6362    task pstamp.dependent.load
    6463        active true
     
    9493    end
    9594    task pstamp.dependent.load
    96         active true
     95        active false
     96    end
     97    task pstamp.dependent.run
     98        active false
    9799    end
    98100end
     
    105107macro pstamp.revert.off
    106108    task pstamp.job.revert
     109        active false
     110    end
     111end
     112macro pstamp.cleanup.on
     113    task pstamp.cleanup.load
     114        active true
     115    end
     116    task pstamp.cleanup.run
     117        active true
     118    end
     119end
     120macro pstamp.cleanup.off
     121    task pstamp.cleanup.run
     122        active false
     123    end
     124    task pstamp.cleanup.run
    107125        active false
    108126    end
     
    157175
    158176    task.exec
    159         stdout $LOGSUBDIR/pstamp.request.load.log
     177        stdout NULL
    160178        stderr $LOGSUBDIR/pstamp.request.load.log
    161179        $run = pstamptool -pendingreq
     
    200218    periods     -exec $RUNEXEC
    201219    periods     -timeout 300
    202     npending  6
    203 
    204     task.exec
    205         stdout $LOGSUBDIR/pstamp.request.run.log
     220
     221    task.exec
     222        stdout NULL
    206223        stderr $LOGSUBDIR/pstamp.request.run.log
    207224        book npages pstampRequest -var N
     
    216233        book getword pstampRequest $pageName uri -var URI
    217234        book getword pstampRequest $pageName ds_outProduct -var PRODUCT
     235        book getword pstampRequest $pageName outdir -var OUTDIR
    218236        book getword pstampRequest $pageName label -var LABEL
    219237
    220238        host anyhost
    221239
    222         $run = pstamp_parser_run.pl --req_id $REQ_ID --uri $URI --product $PRODUCT --label $LABEL --redirect-output
     240        $run = pstamp_parser_run.pl --req_id $REQ_ID --uri $URI --product $PRODUCT --outdir $OUTDIR --label $LABEL --redirect-output
    223241
    224242        add_standard_args run
     
    261279
    262280    task.exec
    263         stdout $LOGSUBDIR/pstamp.finish.load.log
     281        stdout NULL
    264282        stderr $LOGSUBDIR/pstamp.finish.load.log
    265283        $run = pstamptool  -completedreq
     
    306324
    307325    task.exec
    308         stdout $LOGSUBDIR/request.finish.run.log
     326        stdout NULL
    309327        stderr $LOGSUBDIR/request.finish.run.log
    310328        book npages pstampFinish -var N
     
    321339        book getword pstampFinish $pageName name -var REQ_NAME
    322340        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
    325344
    326345        add_standard_args run
     
    363382
    364383    task.exec
    365         stdout $LOGSUBDIR/pstamp.job.load.log
     384        stdout NULL
    366385        stderr $LOGSUBDIR/pstamp.job.load.log
    367386        $run = pstamptool -pendingjob
     
    411430
    412431    task.exec
    413         stdout $LOGSUBDIR/pstamp.job.run.log
     432        stdout NULL
    414433        stderr $LOGSUBDIR/pstamp.job.run.log
    415434        book npages pstampJob -var N
     
    489508
    490509    task.exec
    491         stdout $LOGSUBDIR/pstamp.job.revert.log
     510        stdout NULL
    492511        stderr $LOGSUBDIR/pstamp.job.revert.log
    493512        $run = pstamptool -revertjob -all
     
    532551
    533552    task.exec
    534         stdout $LOGSUBDIR/pstamp.dependent.load.log
     553        stdout NULL
    535554        stderr $LOGSUBDIR/pstamp.dependent.load.log
    536555        $run = pstamptool -pendingdependent
     
    660679end
    661680
     681task 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
     727end
     728
     729task 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
     795end
     796
  • trunk/ippTools/share/Makefile.am

    r27795 r27874  
    226226     pstamptool_getdependent.sql \
    227227     pstamptool_listjob.sql \
     228     pstamptool_pendingcleanup.sql \
    228229     pstamptool_pendingdependent.sql \
    229230     pstamptool_pendingjob.sql \
  • trunk/ippTools/share/pstamptool_pendingdependent.sql

    r27859 r27874  
    1 SELECT DISTINCT pstampDependent.*,
     1SELECT DISTINCT
     2    pstampDependent.*,
    23    IFNULL(Label.priority, 10000) AS priority
    34FROM pstampDependent
  • trunk/ippTools/share/pstamptool_pendingreq.sql

    r27856 r27874  
    44    pstampDataStore.outProduct AS ds_outProduct,
    55    IFNULL(Label.priority, 10000) AS priority
    6     FROM pstampRequest
     6FROM pstampRequest
    77    LEFT JOIN pstampDataStore USING(ds_id)
    88    LEFT JOIN Label ON pstampRequest.label = Label.label
  • trunk/ippTools/share/pstamptool_updatejob.sql

    r27740 r27874  
    11UPDATE pstampJob LEFT JOIN pstampDependent USING(dep_id)
    2 SET pstampJob.state = '%s'
    3     -- set state hook %s
     2SET
  • trunk/ippTools/share/pxadmin_create_tables.sql

    r27856 r27874  
    13031303        outProduct VARCHAR(64),
    13041304        uri VARCHAR(255),
     1305        outdir     VARCHAR(255),
    13051306        fault SMALLINT,
    13061307        PRIMARY KEY(req_id),
  • trunk/ippTools/src/pstamptool.c

    r27856 r27874  
    4040static bool updatereqMode(pxConfig *config);
    4141static bool revertreqMode(pxConfig *config);
     42static bool pendingcleanupMode(pxConfig *config);
    4243static bool addjobMode(pxConfig *config);
    4344static bool listjobMode(pxConfig *config);
     
    8182        MODECASE(PSTAMPTOOL_MODE_UPDATEREQ, updatereqMode);
    8283        MODECASE(PSTAMPTOOL_MODE_REVERTREQ, revertreqMode);
     84        MODECASE(PSTAMPTOOL_MODE_PENDINGCLEANUP, pendingcleanupMode);
    8385        MODECASE(PSTAMPTOOL_MODE_ADDJOB, addjobMode);
    8486        MODECASE(PSTAMPTOOL_MODE_LISTJOB, listjobMode);
     
    265267        NULL,   // outProduct
    266268        uri,
     269        NULL,   // outdir
    267270        0       // fault
    268271        )) {
     
    341344}
    342345
    343 static bool listreqMode(pxConfig *config)
     346static bool pendingcleanupMode(pxConfig *config)
    344347{
    345348    PS_ASSERT_PTR_NON_NULL(config, false);
     
    347350    psMetadata *where = psMetadataAlloc();
    348351    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);
    353355    PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false);
    354356
    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");
    366371
    367372    // treat limit == 0 as "no limit"
     
    385390    }
    386391    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;
    393395    }
    394396
     
    405407}
    406408
    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);
     409static 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);
    415419    PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false);
    416420
    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);
    427432
    428433    // treat limit == 0 as "no limit"
     
    438443        return false;
    439444    }
     445    psFree(query);
    440446
    441447    psArray *output = p_psDBFetchResult(config->dbh);
     
    444450        return false;
    445451    }
    446 
    447452    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;
    451459    }
    452460
     
    463471}
    464472
     473static 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
    465531static bool updatereqMode(pxConfig *config)
    466532{
    467533    PS_ASSERT_PTR_NON_NULL(config, false);
    468534
    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;
    480561    char c = ' ';
    481562    if (state) {
    482563        psStringAppend(&query, "%c state = '%s'", c, state);
    483564        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 = ',';
    484572    }
    485573    if (outProduct) {
     
    487575        c = ',';
    488576    }
    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) {
    490589        psStringAppend(&query, "%c fault = %d", c, fault);
    491590        c = ',';
     
    503602        c = ',';
    504603    }
    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    }
    511617
    512618    if (!p_psDBRunQuery(config->dbh, query)) {
     
    516622    }
    517623
    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);
    525626
    526627    return true;
     
    778879        return false;
    779880    }
    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    }
    782889
    783890    psMetadata *where = psMetadataAlloc();
     
    786893    PXOPT_COPY_S64(config->args, where, "-dep_id", "dep_id", "==");
    787894
    788     psString faultStr = NULL;
    789     if (!fault) {
    790         faultStr = psStringCopy("");
    791     } else {
    792         psStringAppend(&faultStr, "\n, pstampJob.fault = %d", fault);
    793     }
    794 
    795895    psString query = pxDataGet("pstamptool_updatejob.sql");
    796896
     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   
    797907    psString whereClause = psDBGenerateWhereConditionSQL(where, NULL);
    798908    psStringAppend(&query, " WHERE %s", whereClause);
     
    800910    psFree(where);
    801911
    802     if (!p_psDBRunQueryF(config->dbh, query, state, faultStr)) {
     912    if (!p_psDBRunQuery(config->dbh, query)) {
    803913        psError(PS_ERR_UNKNOWN, false, "database error");
    804914        psFree(query);
    805915        return false;
    806916    }
    807     psFree(faultStr);
    808917    psFree(query);
    809918
     
    11591268    PXOPT_LOOKUP_S64(dep_id,    config->args, "-dep_id", true, false);
    11601269    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);
    11621271
    11631272    if (!fault && !state) {
  • trunk/ippTools/src/pstamptool.h

    r27740 r27874  
    3434    PSTAMPTOOL_MODE_UPDATEREQ,
    3535    PSTAMPTOOL_MODE_REVERTREQ,
     36    PSTAMPTOOL_MODE_PENDINGCLEANUP,
    3637    PSTAMPTOOL_MODE_ADDJOB,
    3738    PSTAMPTOOL_MODE_LISTJOB,
  • trunk/ippTools/src/pstamptoolConfig.c

    r27856 r27874  
    9898    // -updatereq
    9999    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);
    107114
    108115    // -revertreq
     
    112119    psMetadataAddStr(revertreqArgs, PS_LIST_TAIL, "-state", 0,      "state to revert", NULL);
    113120    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);
    114129
    115130    // -addjob
     
    145160    psMetadataAddS64(updatejobArgs, PS_LIST_TAIL, "-job_id", 0,            "req_id for which to change state", 0);
    146161    psMetadataAddS64(updatejobArgs, PS_LIST_TAIL, "-dep_id", 0,            "dep_id for which to change state", 0);
    147     psMetadataAddStr(updatejobArgs, PS_LIST_TAIL, "-state", 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);
    149164
    150165    // -revertjob
     
    160175    // -getdependent
    161176    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
    162179    psMetadataAddS64(getdependentArgs, PS_LIST_TAIL, "-stage_id", 0, "define stage id for dependent (required)", 0);
    163180    psMetadataAddStr(getdependentArgs, PS_LIST_TAIL, "-stage", 0,    "define stage for dependent (required)", NULL);
     
    173190    psMetadataAddS64(updatedependentArgs, PS_LIST_TAIL, "-dep_id", 0, "define id for dependent (required)", 0);
    174191    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);
    176193
    177194    // -revertdependent
     
    227244    PXOPT_ADD_MODE("-completedreq",    "", PSTAMPTOOL_MODE_COMPLETEDREQ, completedreqArgs);
    228245    PXOPT_ADD_MODE("-revertreq",       "", PSTAMPTOOL_MODE_REVERTREQ,    revertreqArgs);
     246    PXOPT_ADD_MODE("-pendingcleanup",  "", PSTAMPTOOL_MODE_PENDINGCLEANUP, pendingcleanupArgs);
    229247
    230248    PXOPT_ADD_MODE("-addjob",          "", PSTAMPTOOL_MODE_ADDJOB,       addjobArgs);
  • trunk/pstamp/scripts/Makefile.am

    r27859 r27874  
    33
    44install_files = \
     5        pstamp_cleanup.pl \
    56        pstamp_finish.pl \
    67        pstamp_insert_request.pl \
  • trunk/pstamp/scripts/dquery_finish.pl

    r27859 r27874  
    2020use PS::IPP::Config qw( :standard );
    2121
    22 my ( $req_id, $req_name, $req_file, $product, $out_dir, $dbname, $dbserver, $verbose, $save_temps );
     22my ( $req_id, $req_name, $req_file, $product, $outdir, $dbname, $dbserver, $verbose, $save_temps );
    2323
    2424GetOptions(
     
    2727           'req_file=s' => \$req_file,
    2828           'product=s'  => \$product,
    29            'out_dir=s'  => \$out_dir,
     29           'outdir=s'   => \$outdir,
    3030           'dbname=s'   => \$dbname,
    3131           'dbserver=s' => \$dbserver,
     
    4141$err .= "--req_name is required\n" if !$req_name;
    4242$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;
    4444
    4545die "$err" if $err;
     
    7676    die "product directory does not exist $prod_dir";
    7777}
    78 my $out_dir = "$prod_dir/$req_name";
     78my $outdir = "$prod_dir/$req_name";
    7979}
    80 if (! -e $out_dir ) {
     80if (! -e $outdir ) {
    8181    # 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 ) {
    8484        stop_request($req_id, $PS_EXIT_SYS_ERROR, $verbose);
    85         die "cannot create output directory $out_dir";
     85        die "cannot create output directory $outdir";
    8686    }
    87 } elsif (! -d $out_dir) {
     87} elsif (! -d $outdir) {
    8888    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";
    9090}
    9191
     
    118118
    119119# 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);
     120my ($REGLIST, $reg_list) = tempfile("$outdir/reqlist.XXXX", UNLINK => !$save_temps);
    121121
    122122foreach my $job (@jobs) {
    123123    my $job_id = $job->{job_id};
    124124    my $response_file = "response${job_id}.fits";
    125     my $response_path = "$out_dir/$response_file";
     125    my $response_path = "$outdir/$response_file";
    126126
    127127    if (-e $response_path) {
     
    131131        # do the same if we have an error file.  Should the parse data be uploaded as well?
    132132        my $err_file = "parse_error.txt";
    133         if (-e "$out_dir/$err_file") {
     133        if (-e "$outdir/$err_file") {
    134134            print $REGLIST "$err_file|||text|\n";
    135135        }
     
    143143if (-s $reg_list) {
    144144    my $command = "$dsreg --add $req_name --product $product --list $reg_list";
    145     $command .= " --copy --datapath $out_dir";
     145    $command .= " --copy --datapath $outdir";
    146146    $command .= " --type MOPS_DETECTABILITY_RESPONSE";
    147147    $command .= " --ps0 $req_id";
     
    166166    my $verbose = shift;
    167167   
    168     my $command = "$pstamptool -updatereq -req_id $req_id -state 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;
    170170    $command   .= " -dbname $dbname" if $dbname;
    171171    $command   .= " -dbserver $dbserver" if $dbserver;
  • trunk/pstamp/scripts/dqueryparse.pl

    r27859 r27874  
    2626
    2727my ($no_update, $imagedb, $label);
    28 my ($req_file, $req_id, $out_dir, $product, $mode, $dbname, $dbserver, $verbose, $save_temps);
     28my ($req_file, $req_id, $outdir, $product, $mode, $dbname, $dbserver, $verbose, $save_temps);
    2929my ($job_id,$rownum); # stuff from the post-update world
    3030#
     
    3737        'job_id=s'        =>      \$job_id,
    3838        'rownum=s'        =>      \$rownum,
    39         'out_dir=s'       =>      \$out_dir,
     39        'outdir=s'       =>      \$outdir,
    4040        'label=s'         =>      \$label,
    4141        'product=s'       =>      \$product,
     
    5252if ($mode ne "list_uri") {
    5353    die "req_id is required" if !$req_id;
    54     die "out_dir is required" if !$out_dir;
     54    die "outdir is required" if !$outdir;
    5555    die "product is required" if !$product;
    5656}
     
    8080# Unless we're running as a job, write the parse arguments in case we need to rerun this parsing.
    8181if (!$job_id) {
    82     my $argslist = "$out_dir/parse.args";
     82    my $argslist = "$outdir/parse.args";
    8383    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";
    8585    close ARGSLIST;
    8686}
     
    105105
    106106# 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);
     107if (! -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);
    111111}
    112112
    113113
    114114# Pass along the request file to the response generator.
    115 my $response_file = "$out_dir/${req_name}.dresponse.${req_id}.fits";
     115my $response_file = "$outdir/${req_name}.dresponse.${req_id}.fits";
    116116my $fault;
    117117my $data_to_update = '';
    118118{
    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";
    120120    $command .= " --save-temps" if $save_temps;
    121121    $command .= " --verbose" if $verbose;
     
    137137# for the completed work, and move the response to a standardized name.
    138138if ($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";
    140140    $command .= " -job_type detect_query -state stop -fault 0";
    141141    $command .= " -rownum 1";
     
    147147        chomp $job_id;
    148148        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";
    150150        }
    151151        $result = 0;
     
    158158    # Failed to run correctly, which means that we need to queue a job and flag data for updating.
    159159    # 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);
    161161
    162162    # 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";
    164164    $command .= " -job_type detect_query -state run -fault 0";
    165165    $command .= " -rownum 1";
     
    174174        if ($job_id && -e $response_file) {
    175175            # 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";
    177177        }
    178178        $result = 0;
     
    186186# which will notice that we've inserted the stopped job and decide we're finished. Easy enough.
    187187{
    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;
    190190
    191191    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     
    201201# If we have to queue an update run, do so and create a new dependent
    202202sub 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) = @_;
    204204
    205205    my ($state, $stage, $stage_id, $component, $need_magic, $imagedb) = split /\s+/, $data_to_update;
     
    211211    my $dep_id;
    212212    my $command = "$pstamptool -getdependent -stage $stage -stage_id $stage_id -imagedb $imagedb -component $component ";
    213     $command .= " -outdir $out_dir";
     213    $command .= " -outdir $outdir";
    214214    $command .= " -need_magic" if $need_magic;
    215215
  • trunk/pstamp/scripts/pstamp_checkdependent.pl

    r27853 r27874  
    575575    my ($state, $stage, $stage_id, $job_fault) = @_;
    576576
    577     my $command = "$pstamptool -updatejob -state stop -fault $job_fault -dep_id $dep_id";
     577    my $command = "$pstamptool -updatejob -set_state stop -set_fault $job_fault -dep_id $dep_id";
    578578    $command .= " -dbname $dbname" if $dbname;
    579579    $command .= " -dbserver $dbserver" if $dbserver;
     
    642642    carp $msg;
    643643
    644     my $command = "$pstamptool -updatedependent -fault $fault -dep_id $dep_id";
     644    my $command = "$pstamptool -updatedependent -set_fault $fault -dep_id $dep_id";
    645645    $command .= " -dbname $dbname" if $dbname;
    646646    $command .= " -dbserver $dbserver" if $dbserver;
  • trunk/pstamp/scripts/pstamp_dorequest.pl

    r19221 r27874  
    106106{
    107107    ## TODO: what about request status
    108     my $command = "$pstamptool -updatereq -req_id $request_id -state stop";
     108    my $command = "$pstamptool -updatereq -req_id $request_id -set_state stop";
    109109    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    110110        run(command => $command, verbose => $verbosity);
  • trunk/pstamp/scripts/pstamp_finish.pl

    r27751 r27874  
    2525use PS::IPP::PStamp::Job qw( :standard );
    2626
    27 my ( $req_id, $req_name, $req_file, $out_dir, $product, $dbname, $dbserver, $verbose, $save_temps, $redirect_output);
     27my ( $req_id, $req_name, $req_file, $outdir, $product, $dbname, $dbserver, $verbose, $save_temps, $redirect_output);
    2828
    2929# the char to the right of the bar may be used as a single - alias for the longer name
     
    3434           'req_file=s'     => \$req_file,
    3535           'product=s'      => \$product,
    36            'out_dir=s'      => \$out_dir,
     36           'outdir=s'      => \$outdir,
    3737           'dbname=s'       => \$dbname,
    3838           'dbserver=s'     => \$dbserver,
     
    4444pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV;
    4545
    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;
     46die "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;
    4848
    4949my $ipprc = PS::IPP::Config->new(); # IPP Configuration
    5050if ($redirect_output) {
    51     my $logDest = "$out_dir/psfinish.$req_id.log";
     51    my $logDest = "$outdir/psfinish.$req_id.log";
    5252    $ipprc->redirect_output($logDest);
    5353}
     
    8282    my $fileset = $req_name;
    8383
    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) {
    8787        # 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";
    9292            stop_request_and_exit($req_id, $PS_EXIT_UNKNOWN_ERROR);
    9393        }
    9494
    9595
    96     } elsif (! -d $out_dir ) {
     96    } elsif (! -d $outdir ) {
    9797        # XXX TODO: fault the request so we pstamp_finish doesn't keep trying to process the
    9898        # 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";
    100100        stop_request_and_exit($req_id, $PS_EXIT_UNKNOWN_ERROR);
    101101    }
     
    122122    # the following is for a postage stamp request
    123123
    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);
    125125    print $rlf "results.fits|||table|\n";
    126126    print $rlf "results.mdc|||text|\n";
    127127
    128128    my $err_file = "parse_error.txt";
    129     if (-e "$out_dir/$err_file" ) {
     129    if (-e "$outdir/$err_file" ) {
    130130        print $rlf "$err_file|||text|\n";
    131131    }
    132132
    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);
    134134
    135135
     
    208208
    209209        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";
    211211            if (open JRL, "<$jreglist") {;
    212212                # process the reglist file to get the list of files produced by this job
     
    225225                    # If not found check the PHU. If that doesn't work just set them to zero.
    226226                    # 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`;
    228228                    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`;
    230230                    }
    231231                    $ra_deg = 0.0 if (!$ra_deg);
     
    258258    # make the results file
    259259    {
    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";
    261261        my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    262262            run(command => $command, verbose => $verbose);
     
    266266        } else {
    267267            # 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";
    269269            my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    270270                run(command => $command, verbose => $verbose);
     
    278278        # register the fileset
    279279        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;
    282283
    283284        my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     
    292293    # set the request's state to stop
    293294    {
    294         my $command = "$pstamptool -updatereq -req_id $req_id -state stop -fault $request_fault";
     295        my $command = "$pstamptool -updatereq -req_id $req_id -set_state stop -set_fault $request_fault";
    295296        $command   .= " -dbname $dbname" if $dbname;
    296297        $command   .= " -dbserver $dbserver" if $dbserver;
     
    308309    my $fault  = shift;
    309310
    310     my $command = "$pstamptool -updatereq -req_id $req_id -state stop -fault $fault";
     311    my $command = "$pstamptool -updatereq -req_id $req_id -set_state stop -set_fault $fault";
    311312    $command   .= " -dbname $dbname" if $dbname;
    312313    $command   .= " -dbserver $dbserver" if $dbserver;
  • trunk/pstamp/scripts/pstamp_get_image_job.pl

    r26215 r27874  
    8787}
    8888
    89 my $out_dir = dirname($output_base);
     89my $outdir = dirname($output_base);
    9090my $prefix = basename($output_base) . "_";
    9191my $results_file = $output_base . ".bundle_results";
     
    102102    my $command = "$dist_bundle --camera $camera --stage $stage --stage_id $stage_id";
    103103    $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";
    105105    $command .= " --prefix $prefix";
    106106    $command .= " --magicked" if $magicked;
     
    139139}
    140140
    141 my $reglist = "$out_dir/reglist$job_id";
     141my $reglist = "$outdir/reglist$job_id";
    142142if (! open(REGLIST, ">$reglist") ) {
    143143    my_die("failed to open registration list: $reglist", $PS_EXIT_UNKNOWN_ERROR);
  • trunk/pstamp/scripts/pstamp_job_run.pl

    r27859 r27874  
    198198# mark the job stopped in the database
    199199{
    200     my $command = "$pstamptool -updatejob -job_id $job_id -state 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;
    202202    $command .= " -dbname $dbname" if $dbname;
    203203    $command .= " -dbserver $dbserver" if $dbserver;
     
    343343        my $command = "$pstamptool -updatejob";
    344344        $command .= " -job_id $job_id";
    345         $command .= " -fault $exit_code";
     345        $command .= " -set_fault $exit_code";
    346346        # XXX: fix pstamptool to not require -state when -fault with nonzero value is provided
    347         $command .= " -state run";
     347        $command .= " -set_state run";
    348348        $command .= " -dbname $dbname" if defined $dbname;
    349349        $command .= " -dbserver $dbserver" if defined $dbserver;
  • trunk/pstamp/scripts/pstamp_parser_run.pl

    r27859 r27874  
    2828my $redirect_output;
    2929my $product;
     30my $outdir;
    3031my $label;
    3132my $verbose;
     
    3738    'uri=s'             =>  \$uri,
    3839    'product=s'         =>  \$product,
     40    'outdir=s'          =>  \$outdir,
    3941    'label=s'           =>  \$label,
    4042    'redirect-output'   =>  \$redirect_output,
     
    8183}
    8284
    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,
     85if (!$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
     98if (! -e $outdir ) {
     99    mkdir $outdir or my_die("failed to create working directory $outdir for request id $req_id", $req_id,
    89100        $PS_EXIT_CONFIG_ERROR);
    90101}
    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   
    97103
    98104if ($redirect_output) {
    99     my $logDest = "$workdir/psparse.$req_id.log";
     105    my $logDest = "$outdir/psparse.$req_id.log";
    100106    $ipprc->redirect_output($logDest);
    101107}
     
    108114
    109115my $fn = basename($uri);
    110 my $new_uri = "$workdir/$fn";
     116my $new_uri = "$outdir/$fn";
    111117if ($uri =~ /^http:/) {
    112118    # if the uri is an http uri download the file
     
    123129    }
    124130    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);
    126132    }
    127133}
     
    173179    # that they sent us a request file that we don't understand
    174180
    175     my $command = "$pstamptool -updatereq -req_id $req_id -state 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";
    178184    $command   .= " -dbname $dbname" if $dbname;
    179185    $command   .= " -dbserver $dbserver" if $dbserver;
     
    186192}
    187193
    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";
    189195$parse_cmd .= " --dbname $dbname" if $dbname;
    190196$parse_cmd .= " --dbserver $dbserver" if $dbserver;
     
    194200my $fault;
    195201{
    196     my $error_file_name = "$workdir/parse_error.txt";
     202    my $error_file_name = "$outdir/parse_error.txt";
    197203    # get rid of any error file from previous attempt to parse this request
    198204    unlink $error_file_name if (-e $error_file_name);
     
    227233#
    228234{
    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;
    233240    $command   .= " -dbname $dbname" if $dbname;
    234241    $command   .= " -dbserver $dbserver" if $dbserver;
     
    269276    carp($msg);
    270277
    271     my $command = "$pstamptool -updatereq -req_id $req_id  -fault $fault";
     278    my $command = "$pstamptool -updatereq -req_id $req_id  -set_fault $fault";
    272279    $command   .= " -dbname $dbname" if $dbname;
    273280    $command   .= " -dbserver $dbserver" if $dbserver;
  • trunk/pstamp/scripts/pstampparse.pl

    r27854 r27874  
    2525my $request_file_name;
    2626my $mode = "list_uri";
    27 my $out_dir;
     27my $outdir;
    2828my $product;
    2929my $label;
     
    3434    'file=s'    =>  \$request_file_name,
    3535    'req_id=s'  =>  \$req_id,
    36     'out_dir=s' =>  \$out_dir,
     36    'outdir=s' =>  \$outdir,
    3737    'product=s' =>  \$product,
    3838    'label=s'   =>  \$label,
     
    5050if ($mode ne "list_uri") {
    5151    die "req_id is required"   if !$req_id;
    52     die "out_dir is required"  if !$out_dir;
     52    die "outdir is required"  if !$outdir;
    5353    die "product is required"  if !$product;
    5454}
     
    129129    # update the database with the request name. This will be used as the
    130130    # 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";
    133133    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    134134        run(command => $command, verbose => $verbose);
     
    522522    $base =~ s/.fits$//;
    523523           
    524     my $output_base = "$out_dir/${rownum}_${job_num}_${base}";
     524    my $output_base = "$outdir/${rownum}_${job_num}_${base}";
    525525    my $argslist = "${output_base}.args";
    526526
     
    712712        my $exp_id = $image->{exp_id};
    713713           
    714         my $output_base = "$out_dir/${rownum}_${job_num}";
     714        my $output_base = "$outdir/${rownum}_${job_num}";
    715715
    716716        write_params($output_base, $image);
     
    894894
    895895    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";
    897897    $command .= " -need_magic" if $need_magic;
    898898
  • trunk/pstamp/scripts/request_finish.pl

    r24831 r27874  
    2121use PS::IPP::Config qw( :standard );
    2222
    23 my ( $req_id, $req_name, $req_file, $req_type, $out_dir, $product, $dbname, $dbserver, $verbose, $save_temps, $redirect_output );
     23my ( $req_id, $req_name, $req_file, $req_type, $outdir, $product, $dbname, $dbserver, $verbose, $save_temps, $redirect_output );
    2424
    2525GetOptions(
     
    2828           'req_file=s' => \$req_file,
    2929           'req_type=s' => \$req_type,
    30            'out_dir=s'  => \$out_dir,
     30           'outdir=s'  => \$outdir,
    3131           'product=s'  => \$product,
    3232           'dbname=s'   => \$dbname,
     
    4646$err .= "--req_name is required\n" if !$req_name;
    4747$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;
    4949
    5050die "$err" if $err;
    5151
    5252
    53 if (!$out_dir) {
    54     $out_dir = dirname($req_file);
     53if (!$outdir) {
     54    $outdir = dirname($req_file);
    5555}
    5656
    5757if ($redirect_output) {
    58     my $logDest = "$out_dir/reqfinish.$req_id.log";
     58    my $logDest = "$outdir/reqfinish.$req_id.log";
    5959    my $ipprc = PS::IPP::Config->new();
    6060    $ipprc->redirect_output($logDest);
     
    7979}
    8080if ($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";
    8282    $command   .= " --dbname $dbname" if $dbname;
    8383    $command   .= " --dbserver $dbserver" if $dbserver;
Note: See TracChangeset for help on using the changeset viewer.