IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Aug 20, 2009, 11:12:36 AM (17 years ago)
Author:
watersc1
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/czw_branch/cleanup/pstamp/scripts/pstamp_finish.pl

    r25051 r25143  
    88use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt );
    99use Pod::Usage qw( pod2usage );
     10use Carp;
    1011
    1112use Time::Local;
     
    4748
    4849my $ipprc = PS::IPP::Config->new(); # IPP Configuration
    49 
    5050if ($redirect_output) {
    5151    my $logDest = "$out_dir/psfinish.$req_id.log";
     
    9494        if (!mkdir $out_dir) {
    9595            print STDERR "cannot create output directory $out_dir";
    96             stop_request($req_id, $PS_EXIT_UNKNOWN_ERROR);
     96            stop_request_and_exit($req_id, $PS_EXIT_UNKNOWN_ERROR);
    9797        }
    9898
     
    102102        # request
    103103        print STDERR "output directory $out_dir exists but is not a directory";
    104         stop_request($req_id, $PS_EXIT_UNKNOWN_ERROR);
     104        stop_request_and_exit($req_id, $PS_EXIT_UNKNOWN_ERROR);
    105105    }
    106106
    107107    if (! -e $req_file ) {
    108108        print STDERR "request file $req_file is missing\n";
    109         stop_request($req_id, $PS_EXIT_CONFIG_ERROR);
     109        stop_request_and_exit($req_id, $PS_EXIT_CONFIG_ERROR);
    110110    }
    111111
     
    117117        # point
    118118        print STDERR "failed to read request_file $req_file" ;
    119         stop_request($req_id, $PS_EXIT_CONFIG_ERROR);
     119        stop_request_and_exit($req_id, $PS_EXIT_CONFIG_ERROR);
    120120    }
    121121
     
    154154                print STDERR "Request $req_id produced no jobs.\n"
    155155            }
    156             # No Jobs.
    157             # XXXX Ouch. We need results for each rownum (each request specification) in the request file
    158             # including those that produced no jobs.
    159             # for now add an entry for rownum 1 and a phony error code.
    160             # we've included parse_error.txt to the fileset if it exists
    161             #
    162             my $rownum = 0;
    163             my $fault = 42; # get a real error code
    164             print $tdf "$rownum|$fault|0|0|";
    165             print $tdf "0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|\n";
     156            # This should not happen. A fake job should be queued
     157            stop_request_and_exit($req_id, $PS_EXIT_PROG_ERROR);
    166158        } else {
    167159            my $metadata = $mdcParser->parse($output) or die("Unable to parse metdata config doc");
     
    182174        my $exp_id = $job->{exp_id};
    183175
     176        if ($fault eq $PSTAMP_DUP_REQUEST) {
     177            # this request had a duplicate request name. We can't put the results
     178            # on the data store since the product name is already used
     179            # maybe we could be more clever about this and choose a fileset name
     180            stop_request_and_exit($req_id, $fault);
     181        }
     182
    184183        my ($row, $req_info, $project) = get_request_info($rows, $rownum);
    185184
     
    188187        if (!$image_db) {
    189188            carp("failed to find imagedb for project: $project");
    190             stop_request($req_id, $PS_EXIT_CONFIG_ERROR);
     189            if (!$fault) {
     190                stop_request_and_exit($req_id, $PS_EXIT_CONFIG_ERROR);
     191            }
    191192        }
    192193
     
    227228                print $tdf "$exp_info|";
    228229                print $tdf "$req_info|";
     230                print $tdf "\n";
    229231            }
    230232        } else {
     
    277279}
    278280
    279 sub stop_request {
     281sub stop_request_and_exit {
    280282    my $req_id = shift;
    281283    my $fault  = shift;
     
    299301    my $row = $rows->{$rownum};
    300302
     303    # these may be set to null during processing
     304    my $component = $row->{COMPONENT};
     305    $component = "null" if !$component;
     306    my $tess_id = $row->{TESS_ID};
     307    $tess_id = "null" if !$tess_id;
     308
    301309    # This is ugly, error prone and hard to change.
    302310    # Create a results file module and provide a list of the names (we have the data in the columns)
    303311    my $rowinfo = "$row->{PROJECT}|$row->{JOB_TYPE}|$row->{REQ_TYPE}|$row->{IMG_TYPE}|";
    304     $rowinfo   .= "$row->{ID}|$row->{TESS_ID}|$row->{COMPONENT}|$row->{OPTION_MASK}|$row->{MJD_MIN}|$row->{MJD_MAX}|";
     312    $rowinfo   .= "$row->{ID}|$tess_id|$component|$row->{OPTION_MASK}|$row->{MJD_MIN}|$row->{MJD_MAX}|";
    305313    $rowinfo   .= "$row->{REQFILT}|$row->{COORD_MASK}|$row->{CENTER_X}|$row->{CENTER_Y}|";
    306314    $rowinfo   .= "$row->{WIDTH}|$row->{HEIGHT}";
     
    313321    my $exp_id = shift;
    314322
    315     if (!$exp_id) {
     323    if (!$exp_id or !$image_db) {
    316324        # no exposure id just return zeros
    317325        # XXX: we could put a value in for filter, but we don't have a good place to find it
Note: See TracChangeset for help on using the changeset viewer.