IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 25075


Ignore:
Timestamp:
Aug 14, 2009, 12:45:30 PM (17 years ago)
Author:
bills
Message:

New error codes for postage stamp server requests and jobs

Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/PS-IPP-PStamp/lib/PS/IPP/PStamp/RequestFile.pm

    r24921 r25075  
    2222                    $PSTAMP_SELECT_MASK
    2323                    $PSTAMP_SELECT_WEIGHT
     24                    $PSTAMP_SUCCESS
     25                    $PSTAMP_SYSTEM_ERROR
     26                    $PSTAMP_NOT_IMPLEMENTED
     27                    $PSTAMP_UNKNOWN_ERROR
     28                    $PSTAMP_DUP_REQUEST
     29                    $PSTAMP_INVALID_REQUEST
     30                    $PSTAMP_UNKNOWN_PRODUCT
     31                    $PSTAMP_NO_IMAGE_MATCH
     32                    $PSTAMP_NOT_DESTREAKED
     33                    $PSTAMP_NOT_AVAILABLE
     34                    $PSTAMP_GONE
     35                    $PSTAMP_NO_JOBS_QUEUED
    2436                    );
    2537our %EXPORT_TAGS = (standard => [@EXPORT_OK]);
     
    3345our $PSTAMP_SELECT_MASK      = 2;
    3446our $PSTAMP_SELECT_WEIGHT    = 4;
     47
     48# job and request ERROR_CODE(s)
     49our $PSTAMP_SUCCESS          = 0;
     50our $PSTAMP_SYSTEM_ERROR     = 10;
     51our $PSTAMP_NOT_IMPLEMENTED  = 11;
     52our $PSTAMP_UNKNOWN_ERROR   = 12;
     53
     54our $PSTAMP_DUP_REQUEST      = 20;
     55our $PSTAMP_INVALID_REQUEST  = 21;
     56our $PSTAMP_UNKNOWN_PRODUCT  = 22;
     57our $PSTAMP_NO_IMAGE_MATCH   = 23;
     58our $PSTAMP_NOT_DESTREAKED   = 24;
     59our $PSTAMP_NOT_AVAILABLE    = 25;
     60our $PSTAMP_GONE             = 26;
     61our $PSTAMP_NO_JOBS_QUEUED   = 27;
    3562
    3663use IPC::Cmd 0.36 qw( can_run run );
  • trunk/ippTools/src/pstamptool.c

    r25054 r25075  
    315315    PS_ASSERT_PTR_NON_NULL(config, false);
    316316
    317     PXOPT_LOOKUP_S64(req_id,  config->args, "-req_id", true, false);
     317    PXOPT_LOOKUP_S64(req_id,  config->args, "-req_id", false, false);
     318    PXOPT_LOOKUP_STR(name,  config->args, "-name", false, false);
    318319    PXOPT_LOOKUP_U64(limit,   config->args, "-limit",  false, false);
    319320    PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false);
     321
     322    if (!req_id && !name) {
     323        psError(PS_ERR_UNKNOWN, true, "-req_id or -name must be supplied");
     324        return false;
     325    }
    320326
    321327    psString query = NULL;
     
    342348    }
    343349    if (!psArrayLength(output)) {
    344         psTrace("pstamptool", PS_LOG_INFO, "no rows found");
    345         psFree(output);
    346         return true;
     350        psTrace("pstamptool", PS_LOG_INFO, "request not found");
     351        // This causes main to exit with PS_EXIT_DATA_ERROR which the script is looking for
     352        psError(PXTOOLS_ERR_DATA, true, "request not found");
     353        psFree(output);
     354        // we return false so that the caller can determine that a request does not exist
     355        return false;
    347356    }
    348357
  • trunk/ippTools/src/pstamptoolConfig.c

    r25054 r25075  
    7575    // -listreq
    7676    psMetadata *listreqArgs = psMetadataAlloc();
    77     psMetadataAddS64(listreqArgs, PS_LIST_TAIL, "-req_id", 0,            "define req_id (required)", 0);
     77    psMetadataAddS64(listreqArgs, PS_LIST_TAIL, "-req_id", 0,            "list by req_id", 0);
     78    psMetadataAddStr(listreqArgs, PS_LIST_TAIL, "-name", 0,              "list by name", NULL);
    7879    psMetadataAddU64(listreqArgs, PS_LIST_TAIL, "-limit",  0,            "limit result set to N items", 0);
    7980    psMetadataAddBool(listreqArgs, PS_LIST_TAIL, "-simple", 0,            "use the simple output format", false);
  • trunk/pstamp/scripts/pstampparse.pl

    r25068 r25075  
    9696my_die("wrong EXTVER $extver found in $request_file_name", $PS_EXIT_PROG_ERROR) if ($extver ne "1");
    9797
     98{
     99    my $command = "$pstamptool -listreq  -name $req_name";
     100    $command .= " -dbname $dbname" if $dbname;
     101    $command .= " -dbserver $dbserver" if $dbserver;
     102    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     103        run(command => $command, verbose => $verbose);
     104    my $exitStatus = $error_code >> 8;
     105    if ($success) {
     106        # -listreq succeeded duplicate request name
     107        insertFakeJobForRow(undef, 0, $PSTAMP_DUP_REQUEST);
     108        exit 0;
     109    } elsif ($exitStatus ne $PS_EXIT_DATA_ERROR) {
     110        # wrong error code something else is wrong
     111        my_die("$command failed", $exitStatus);
     112    }
     113}
     114
    98115if ($req_id and !$no_update) {
    99116    # update the database with the request name. This will be used as the
     
    152169    if (!$proj_hash) {
    153170        print STDERR "project $project not found\n"  if $verbose;
    154         insertFakeJobForRow($row, 1, 46);
     171        insertFakeJobForRow($row, 1, $PSTAMP_UNKNOWN_PRODUCT);
    155172        $num_jobs++;
    156173        next;
     
    173190    if (!$skycenter and !$search_component) {
    174191        print STDERR "COMPONENT must be specified for pixel coordinate ROI\n" if $verbose;
    175         insertFakeJobForRow($row, 1, 45);
     192        insertFakeJobForRow($row, 1, $PSTAMP_INVALID_REQUEST);
    176193        $num_jobs++;
    177194        next;
     
    182199    if (($job_type eq "stamp") and ! validROI($row)) {
    183200        print STDERR "invalid ROI for row $rownum\n" if $verbose;
    184         insertFakeJobForRow($row, 1, 46);
     201        insertFakeJobForRow($row, 1, $PSTAMP_INVALID_REQUEST);
    185202        $num_jobs++;
    186203        next;
     
    221238        if (!$skycenter) {
    222239            print STDERR "center must be specified in sky coordintes for bycoord" if $verbose;
    223             insertFakeJobForRow($row, 1, 46);
     240            insertFakeJobForRow($row, 1, $PSTAMP_INVALID_REQUEST);
    224241            $num_jobs++;
    225242            next;
    226243        }
    227244        print STDERR "lookup bycoord is not yet implemented" if $verbose;
    228         insertFakeJobForRow($row, 1, 47);
     245        insertFakeJobForRow($row, 1, $PSTAMP_NOT_IMPLEMENTED);
    229246        $num_jobs++;
    230247        next;
     
    250267if (($mode eq "queue_jobs") and ($num_jobs eq 0)) {
    251268    print STDERR "no jobs created for $req_name\n" if $verbose;
    252     insertFakeJobForRow(undef, 1, 41);
     269    insertFakeJobForRow(undef, 0, $PSTAMP_UNKNOWN_ERROR);
    253270}
    254271
     
    272289    if ( $numComponents == 0 ) {
    273290        print STDERR "no jobs for row $rownum\n" if $verbose;
    274         insertFakeJobForRow($row, 1, 44);
     291        insertFakeJobForRow($row, 1, $PSTAMP_NO_JOBS_QUEUED);
    275292        return 1;
    276293    }
     
    319336            # for now assume yes.
    320337
    321             insertFakeJobForRow($row, $job_num, 43);
     338            insertFakeJobForRow($row, $job_num, $PSTAMP_NOT_DESTREAKED);
    322339
    323340            next;
     
    417434        print STDERR "get_image jobs not implemented yet" if $verbose;
    418435        foreach my $row (@$rowList) {
    419             insertFakeJobForRow($row, 1, 47);
     436            insertFakeJobForRow($row, 1, $PSTAMP_NOT_IMPLEMENTED);
    420437            $num_jobs++;
    421438        }
     
    425442            # the status back to the requestor
    426443            foreach my $row (@$rowList) {
    427                 insertFakeJobForRow($row, 1, 42);
     444                insertFakeJobForRow($row, 1, $PSTAMP_NO_IMAGE_MATCH);
    428445                $num_jobs++;
    429446            }
     
    605622        # if first row has no component all of the images will be retrieved, so
    606623        # the fact that this row has a component is ok. Fall through to return 1
    607         # return 0;
     624        # XXX Nope that doesn't work (yet)
     625        return 0;
    608626    }
    609627
  • trunk/pstamp/src/pstamp.h

    r18243 r25075  
    88#include "pslib.h"
    99#include "psmodules.h"
    10 // #include "psphot.h"
    11 // #include "psastro.h"
    12 // #include "ppStats.h"
    1310#include "pstampErrorCodes.h"
    1411
     
    3128} pspMode;
    3229
     30// error codes returned to users in results flie
     31typedef enum {
     32        PSTAMP_SUCCESS          = 0,
     33        PSTAMP_SYSTEM_ERROR     = 10,
     34        PSTAMP_NOT_IMPLEMENTED  = 11,
     35        PSTAMP_UNKNOWN_ERROR    = 12,
     36        PSTAMP_DUP_REQUEST      = 20,
     37        PSTAMP_INVALID_REQUEST  = 21,
     38        PSTAMP_UNKNOWN_PRODUCT  = 22,
     39        PSTAMP_NO_IMAGE_MATCH   = 23,
     40        PSTAMP_NOT_DESTREAKED   = 24,
     41        PSTAMP_NOT_AVAILABLE    = 25,
     42        PSTAMP_GONE             = 26,
     43        PSTAMP_NO_JOBS_QUEUED   = 27
     44} pstampJobErrors;
     45
     46
    3347#define PSTAMP_SELECT_IMAGE  1
    3448#define PSTAMP_SELECT_MASK   2
     
    4458#define STAMP_RESULTS_VERSION "1"
    4559
     60
     61
    4662#endif
Note: See TracChangeset for help on using the changeset viewer.