IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Oct 18, 2009, 10:23:28 AM (17 years ago)
Author:
eugene
Message:

updated vysos branch from trunk

Location:
branches/eam_branches/20090820
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/20090820

  • branches/eam_branches/20090820/pstamp/scripts/pstampparse.pl

    r25766 r25870  
    7272}
    7373
     74# just deal with these arguments once and for all
     75$pstamptool .= " -dbname $dbname" if $dbname;
     76$pstamptool .= " -dbserver $dbserver" if $dbserver;
     77
    7478# list_job is a deugging mode
    7579$no_update = 1 if $mode eq "list_job";
     
    105109if ($req_id and !$no_update) {
    106110    my $command = "$pstamptool -listreq  -name $req_name -not_req_id $req_id";
    107     $command .= " -dbname $dbname" if $dbname;
    108     $command .= " -dbserver $dbserver" if $dbserver;
    109111    # no verbose so that error message about request not found doesn't appear in parse_error.txt
    110112    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     
    127129    my $command = "$pstamptool -updatereq -req_id $req_id  -name $req_name";
    128130    $command .= " -outProduct $product";
    129     $command .= " -dbname $dbname" if $dbname;
    130     $command .= " -dbserver $dbserver" if $dbserver;
    131131    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    132132        run(command => $command, verbose => $verbose);
     
    195195    my $mjd_max = $row->{MJD_MAX};
    196196    my $label   = $row->{LABEL};
     197    my $x       = $row->{CENTER_X};
     198    my $y       = $row->{CENTER_Y};
    197199
    198200    my $option_mask= $row->{OPTION_MASK};
     
    205207   
    206208    if (!$skycenter and !$search_component) {
    207         print STDERR "COMPONENT must be specified for pixel coordinate ROI\n" if $verbose;
     209        print STDERR "COMPONENT must be specified for pixel coordinate ROI center\n" if $verbose;
    208210        insertFakeJobForRow($row, 1, $PSTAMP_INVALID_REQUEST);
    209211        $num_jobs++;
     
    213215    $search_component = "" if $search_component eq "all";
    214216
    215     if (($job_type eq "stamp") and ! validROI($row)) {
     217    if ((($job_type eq "stamp") or ($req_type eq "bycoord")) and ! validROI($row)) {
    216218        print STDERR "invalid ROI for row $rownum\n" if $verbose;
    217219        insertFakeJobForRow($row, 1, $PSTAMP_INVALID_REQUEST);
     
    262264            next;
    263265        }
    264         print STDERR "lookup bycoord is not yet implemented" if $verbose;
    265         insertFakeJobForRow($row, 1, $PSTAMP_NOT_IMPLEMENTED);
    266         $num_jobs++;
    267         next;
    268     } else {
    269         # Call PS::IPP::PStamp::Job locate_images subroutine to get the images for this
    270         # request specification. An array reference is returned.
    271         my ($x, $y);
    272 
    273         $imageList = locate_images($ipprc, $image_db, $req_type, $stage, $id, $tess_id, $search_component,
     266        if ($stage eq "stack") {
     267            print STDERR "lookup bycoord is not yet implemented for stage stack" if $verbose;
     268            insertFakeJobForRow($row, 1, $PSTAMP_NOT_IMPLEMENTED);
     269            $num_jobs++;
     270            next;
     271        }
     272    }
     273    # Call PS::IPP::PStamp::Job locate_images subroutine to get the images for this
     274    # request specification. An array reference is returned.
     275    $imageList = locate_images($ipprc, $image_db, $req_type, $stage, $id, $tess_id, $search_component,
    274276                $inverse, $need_magic, $x, $y, $mjd_min, $mjd_max, $filter, $label, $verbose);
    275277
    276         if (!$imageList or !@$imageList) {
    277             print STDERR "no matching images found for row $rownum\n" if $verbose;
    278             # note in this case queueJobs inserts the fake job for these rows
    279         }
    280         $row->{need_magic} = $need_magic;
    281         push @rowList, $row;
    282     }
     278    if (!$imageList or !@$imageList) {
     279        print STDERR "no matching images found for row $rownum\n" if $verbose;
     280        # note in this case queueJobs inserts the fake job for these rows
     281    }
     282    $row->{need_magic} = $need_magic;
     283    push @rowList, $row;
    283284}
    284285
     
    397398        my $newState = "run";
    398399        my $fault = 0;
    399 
    400         if (($stage ne 'stack') and ($stage ne 'raw')) {
    401             if (($image->{state} eq 'goto_purged') or ($image->{data_state} eq 'purged')) {
     400        my $dep_id;
     401
     402        if ($stage ne 'raw') {
     403            my $run_state = $image->{state};
     404            my $data_state = $image->{data_state};
     405            $data_state = $run_state if $stage eq "stack";
     406            if (($run_state eq 'goto_purged') or ($data_state eq 'purged') or
     407                ($run_state eq 'goto_scrubbed') or ($data_state eq 'scrubbed')) {
     408                # image is gone and it's not coming back
    402409                $newState = 'stop';
    403410                $fault = $PSTAMP_GONE;
    404             } elsif (($image->{data_state} ne 'full') or ($image->{state} ne 'full' )) {
    405                 # XXX here is where we need to queue an update job
    406                 # for now just say that the image is not available
    407                 $newState = 'stop';
    408                 $fault = $PSTAMP_NOT_AVAILABLE;
     411            } elsif (($data_state ne 'full') or ($run_state ne 'full' )) {
     412                # don't wait for update unless the caller asks us to
     413                if (!($option_mask & $PSTAMP_WAIT_FOR_UPDATE)) {
     414                    $newState = 'stop';
     415                    $fault = $PSTAMP_NOT_AVAILABLE;
     416                } else {
     417                    # cause the image to be re-made
     418                    # set up to queue an update run
     419                    queue_update_run(\$newState, \$fault, \$dep_id, $image->{image_db},
     420                        $run_state, $stage, $image->{stage_id}, $need_magic, $image->{label});
     421                }
    409422            }
    410423        }
     
    415428        $command .= " -fault $fault" if $fault;
    416429        $command .= " -exp_id $exp_id" if $exp_id;
    417         $command .= " -dbname $dbname" if $dbname;
    418         $command .= " -dbserver $dbserver" if $dbserver;
     430        $command .= " -dep_id $dep_id" if $dep_id;
    419431
    420432        if ($mode eq "list_job") {
     
    593605    my $command = "$pstamptool -addjob  -req_id $req_id -job_type $job_type"
    594606                        . " -rownum $rownum -state stop -fault $fault";
    595     $command .= " -dbname $dbname" if $dbname;
    596     $command .= " -dbserver $dbserver" if $dbserver;
    597607
    598608    if ($mode eq "list_job") {
     
    717727}
    718728
     729sub queue_update_run
     730{
     731    my ($r_jobState, $r_fault, $r_dep_id, $imagedb, $state, $stage, $stage_id, $need_magic, $label) = @_;
     732
     733    if (($state ne 'cleaned') and ($state ne 'update') and ($state ne 'goto_cleaned')) {
     734        my_die("$stage $stage_id is in unexpected state $state", $PS_EXIT_PROG_ERROR);
     735    }
     736
     737    my $dep_id;
     738    my $command = "$pstamptool -getdependent -stage $stage -stage_id $stage_id -imagedb $imagedb";
     739    $command .= " -rlabel $label" if $label;
     740    $command .= " -no_magic" if !$need_magic;
     741    if (!$no_update) {
     742        my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     743            run(command => $command, verbose => $verbose);
     744        unless ($success) {
     745            my_die("$command failed", $PS_EXIT_UNKNOWN_ERROR);
     746        }
     747        my $output = join "", @$stdout_buf;
     748        chomp $output;
     749        $dep_id = $output;
     750        my_die("pstamptool -getdependent returned invalid dep_id", $PS_EXIT_PROG_ERROR) if !$dep_id;
     751    } else {
     752        print STDERR "skipping $command\n";
     753        $dep_id = 42;
     754    }
     755   
     756    $$r_dep_id = $dep_id;
     757    $r_fault = 0;
     758    $r_jobState = 'blocked';
     759}
     760
    719761sub my_die
    720762{
Note: See TracChangeset for help on using the changeset viewer.