IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Sep 15, 2009, 4:02:42 PM (17 years ago)
Author:
eugene
Message:

updates from trunk

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/20090715/pstamp/scripts/pstamp_finish.pl

    r25022 r25406  
    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";
     
    6868}
    6969
     70if ($product eq "NULL") {
     71    stop_request_and_exit($req_id, $PS_EXIT_PROG_ERROR);
     72}
    7073
    7174my $outputDataStoreRoot = metadataLookupStr($ipprc->{_siteConfig}, 'DATA_STORE_ROOT');
     
    9497        if (!mkdir $out_dir) {
    9598            print STDERR "cannot create output directory $out_dir";
    96             stop_request($req_id, $PS_EXIT_UNKNOWN_ERROR);
     99            stop_request_and_exit($req_id, $PS_EXIT_UNKNOWN_ERROR);
    97100        }
    98101
     
    102105        # request
    103106        print STDERR "output directory $out_dir exists but is not a directory";
    104         stop_request($req_id, $PS_EXIT_UNKNOWN_ERROR);
     107        stop_request_and_exit($req_id, $PS_EXIT_UNKNOWN_ERROR);
    105108    }
    106109
    107110    if (! -e $req_file ) {
    108111        print STDERR "request file $req_file is missing\n";
    109         stop_request($req_id, $PS_EXIT_CONFIG_ERROR);
     112        stop_request_and_exit($req_id, $PS_EXIT_CONFIG_ERROR);
    110113    }
    111114
     
    117120        # point
    118121        print STDERR "failed to read request_file $req_file" ;
    119         stop_request($req_id, $PS_EXIT_CONFIG_ERROR);
     122        stop_request_and_exit($req_id, $PS_EXIT_CONFIG_ERROR);
    120123    }
    121124
     
    154157                print STDERR "Request $req_id produced no jobs.\n"
    155158            }
    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";
     159            # This should not happen. A fake job should be queued
     160            stop_request_and_exit($req_id, $PS_EXIT_PROG_ERROR);
    166161        } else {
    167162            my $metadata = $mdcParser->parse($output) or die("Unable to parse metdata config doc");
     
    182177        my $exp_id = $job->{exp_id};
    183178
     179        if ($fault eq $PSTAMP_DUP_REQUEST) {
     180            # this request had a duplicate request name. We can't put the results
     181            # on the data store since the product name is already used
     182            # maybe we could be more clever about this and choose a fileset name
     183            stop_request_and_exit($req_id, $fault);
     184        }
     185
    184186        my ($row, $req_info, $project) = get_request_info($rows, $rownum);
    185187
     
    188190        if (!$image_db) {
    189191            carp("failed to find imagedb for project: $project");
    190             stop_request($req_id, $PS_EXIT_CONFIG_ERROR);
     192            if (!$fault) {
     193                stop_request_and_exit($req_id, $PS_EXIT_CONFIG_ERROR);
     194            }
    191195        }
    192196
     
    227231                print $tdf "$exp_info|";
    228232                print $tdf "$req_info|";
     233                print $tdf "\n";
    229234            }
    230235        } else {
     
    251256        # register the fileset
    252257        my $command = "$dsreg --list $reglist_name --add $fileset --product $product --type PSRESULTS";
    253         $command .= " --link --datapath $out_dir";
     258        $command .= " --link --datapath $out_dir --ps0 $req_id";
    254259        $command .= " --dbname $dbname" if $dbname;
    255260
     
    277282}
    278283
    279 sub stop_request {
     284sub stop_request_and_exit {
    280285    my $req_id = shift;
    281286    my $fault  = shift;
     
    299304    my $row = $rows->{$rownum};
    300305
     306    # these may be set to null during processing
     307    my $component = $row->{COMPONENT};
     308    $component = "null" if !$component;
     309    my $tess_id = $row->{TESS_ID};
     310    $tess_id = "null" if !$tess_id;
     311
    301312    # This is ugly, error prone and hard to change.
    302313    # Create a results file module and provide a list of the names (we have the data in the columns)
    303314    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}|";
     315    $rowinfo   .= "$row->{ID}|$tess_id|$component|$row->{OPTION_MASK}|$row->{MJD_MIN}|$row->{MJD_MAX}|";
    305316    $rowinfo   .= "$row->{REQFILT}|$row->{COORD_MASK}|$row->{CENTER_X}|$row->{CENTER_Y}|";
    306317    $rowinfo   .= "$row->{WIDTH}|$row->{HEIGHT}";
     
    313324    my $exp_id = shift;
    314325
    315     if (!$exp_id) {
     326    if (!$exp_id or !$image_db) {
    316327        # no exposure id just return zeros
    317328        # 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.