Index: trunk/pstamp/scripts/pstampparse.pl
===================================================================
--- trunk/pstamp/scripts/pstampparse.pl	(revision 25540)
+++ trunk/pstamp/scripts/pstampparse.pl	(revision 25712)
@@ -16,5 +16,5 @@
 use File::Basename qw(basename);
 use Carp;
-use POSIX qw( strftime );
+use POSIX;
 
 my $verbose;
@@ -72,4 +72,5 @@
 }
 
+# list_job is a deugging mode
 $no_update = 1 if $mode eq "list_job";
 
@@ -185,11 +186,13 @@
     }
     my $req_type = $row->{REQ_TYPE};
-    $stage = $row->{IMG_TYPE};
-    my $id       = $row->{ID};
+    $stage       = $row->{IMG_TYPE};
+    my $id      = $row->{ID};
     my $component = $row->{COMPONENT};
-
-    my $filter   = $row->{REQFILT};
+    my $tess_id = $row->{TESS_ID};
+
+    my $filter  = $row->{REQFILT};
     my $mjd_min = $row->{MJD_MIN};
     my $mjd_max = $row->{MJD_MAX};
+    my $label   = $row->{LABEL};
 
     my $option_mask= $row->{OPTION_MASK};
@@ -222,5 +225,4 @@
     my_die("job_type is list_uri but mode is $mode", $PS_EXIT_PROG_ERROR) if ($job_type eq "list_uri") and ($mode ne "list_uri");
 
-
     my $image_db   = $proj_hash->{dbname};
     my $camera     = $proj_hash->{camera};
@@ -228,5 +230,5 @@
 
     # Temporary hack so that MOPS can get at non-magicked data
-    if ($product eq "mops-pstamp-results") {
+    if ($product and ($product eq "mops-pstamp-results")) {
         $need_magic = 0;
     }
@@ -269,6 +271,6 @@
         my ($x, $y);
 
-        $imageList = locate_images($ipprc, $image_db, $req_type, $stage, $id, $search_component,
-                $inverse, $skycenter, $x, $y, $mjd_min, $mjd_max, $filter, $verbose);
+        $imageList = locate_images($ipprc, $image_db, $req_type, $stage, $id, $tess_id, $search_component,
+                $inverse, $need_magic, $x, $y, $mjd_min, $mjd_max, $filter, $label, $verbose);
 
         if (!$imageList or !@$imageList) {
@@ -305,4 +307,5 @@
     my $num_jobs = 0;
     my $rownum = $row->{ROWNUM};
+    my $option_mask = $row->{OPTION_MASK};
     my $components = $row->{components};
 
@@ -346,4 +349,6 @@
         if (($stage ne "stack") and ($need_magic and !$image->{magicked})) {
             # XXX: should we add a faulted job so the client can know what happened if no images come back?
+            # This test is made in locate_images now so this code never runs. This leads to no feedback
+            # to users, but speeds up processing significatnly
             print STDERR "skipping non-magicked image $imagefile\n" if $verbose;
 
@@ -369,8 +374,8 @@
         $args .= " -file $imagefile";
 
-        if (($row->{OPTION_MASK} & $PSTAMP_SELECT_MASK) &&  $image->{mask} ) {
+        if (($option_mask & $PSTAMP_SELECT_MASK) &&  $image->{mask} ) {
             $args .= " -mask $image->{mask}";
         }
-        if (($row->{OPTION_MASK} & $PSTAMP_SELECT_WEIGHT) and $image->{weight} ) {
+        if (($option_mask & $PSTAMP_SELECT_WEIGHT) and $image->{weight} ) {
             $args .= " -variance $image->{weight}";
         }
@@ -407,5 +412,5 @@
         $num_jobs++;
         my $command = "$pstamptool -addjob  -req_id $req_id -job_type $row->{JOB_TYPE}"
-                        . " -outputBase $output_base -rownum $rownum -state $newState";
+                        . " -outputBase $output_base -rownum $rownum -state $newState -options $option_mask";
         $command .= " -fault $fault" if $fault;
         $command .= " -exp_id $exp_id" if $exp_id;
@@ -542,7 +547,11 @@
                     run(command => $command, verbose => $verbose);
                 unless ($success) {
-                    print STDERR @$stderr_buf;
-                    my $rc = $error_code >> 8;
-                    my_die( "dvoImagesAtCoords failed: $rc", $PS_EXIT_UNKNOWN_ERROR);
+                    # don't fail if the program exited normally and exit status was PSTAMP_NO_OVERLAP
+                    # That just means that the coordinate didn't match any image/skycell
+                    if (!WIFEXITED($error_code) || (WEXITSTATUS($error_code) ne $PSTAMP_NO_OVERLAP)) {
+                        print STDERR @$stderr_buf;
+                        my $rc = WIFEXITED($error_code) ? WEXITSTATUS($error_code) : $PS_EXIT_SYS_ERROR;
+                        my_die( "dvoImagesAtCoords failed: $rc", $rc);
+                    }
                 }
                 # now we have a list of row numbers and components
