Index: /trunk/pstamp/scripts/Makefile.am
===================================================================
--- /trunk/pstamp/scripts/Makefile.am	(revision 29329)
+++ /trunk/pstamp/scripts/Makefile.am	(revision 29330)
@@ -20,4 +20,5 @@
         pstamp_get_image_job.pl \
 	psmkreq \
+	pstampstopfaulted \
 	pstamp_checkdependent.pl \
 	request_finish.pl \
Index: /trunk/pstamp/scripts/pstamp_finish.pl
===================================================================
--- /trunk/pstamp/scripts/pstamp_finish.pl	(revision 29329)
+++ /trunk/pstamp/scripts/pstamp_finish.pl	(revision 29330)
@@ -191,5 +191,7 @@
             my $filter = $job_params->{filter};
             $filter = "0" if !$filter;
-            $exp_info = "0|0|0|$filter|0|0";
+            my $mjd_obs = $job_params->{mjd_obs};
+            $mjd_obs = "0" if !$mjd_obs;
+            $exp_info = "$mjd_obs|0|0|$filter|0|0";
         }
 
@@ -477,4 +479,12 @@
     my $ticks = timegm($sec, $min, $hr, $day, $mon-1, $year-1900);
 
+    # dateobs is UTC convert to TAI
+    # XXX: Do this properly
+    if ($year >= 2009) {
+        $ticks += 34;
+    } else {
+        $ticks += 33;
+    }
+
     return 40587.0 + ($ticks/86400.);
 }
Index: /trunk/pstamp/scripts/pstamp_webrequest.pl
===================================================================
--- /trunk/pstamp/scripts/pstamp_webrequest.pl	(revision 29329)
+++ /trunk/pstamp/scripts/pstamp_webrequest.pl	(revision 29330)
@@ -33,5 +33,5 @@
     'dbname=s'      =>  \$dbname,
     'dbserver=s'    =>  \$dbserver,
-    'project=s'     => \$project,
+#    'project=s'     => \$project,
     'verbose'       => \$verbose,
 );
Index: /trunk/pstamp/scripts/pstampparse.pl
===================================================================
--- /trunk/pstamp/scripts/pstampparse.pl	(revision 29329)
+++ /trunk/pstamp/scripts/pstampparse.pl	(revision 29330)
@@ -806,8 +806,15 @@
     my ($r_jobState, $r_fault, $r_dep_id, $imagedb, $state, $stage, $stage_id, $component, $need_magic) = @_;
 
-    # XXX: The update process for warp and subsequent stages requires # destreaking to be performed
-    # because the -pending queries require the inputs to have magicked >= 0
-    # The case of stack-stack diffs not needing to be destreaked is taken care of in pstamp_checkdependent
-    $need_magic = 1 if $imagedb eq 'gpc1';
+    if (($stage ne 'chip') and ($stage ne 'raw')) {
+        # XXX: The update process for warp and subsequent stages requires that destreaking to be performed
+        # because the -pending queries require the inputs to have magicked >= 0
+        # This is too conservative. For example stage is warp and the warp has never been destreaked we don't
+        # need magic either
+        # The case of stack-stack diffs not needing to be destreaked is taken care of in pstamp_checkdependent
+        # maybe we should put all of the smarts there and interpret the need_magic flag in the dependent as
+        # "The client needs to have magic performed" and let
+        # XXX: note the very nasty hard coding of gpc1
+        $need_magic = 1 if $imagedb eq 'gpc1';
+    }
 
     # chipRun's can be in full state if destreaking is necessary
@@ -900,5 +907,5 @@
                     $$r_newState = 'stop';
                     $$r_fault = $PSTAMP_NOT_AVAILABLE;
-                } elsif (!$image->{magicked}) {
+                } elsif ($need_magic and !$image->{magicked}) {
                     $$r_newState = 'stop';
                     $$r_fault = $PSTAMP_NOT_DESTREAKED;
Index: /trunk/pstamp/scripts/pstampstopfaulted
===================================================================
--- /trunk/pstamp/scripts/pstampstopfaulted	(revision 29330)
+++ /trunk/pstamp/scripts/pstampstopfaulted	(revision 29330)
@@ -0,0 +1,15 @@
+
+# script executed by the task pstamp.stopfaulted to stop proceessing of jobs
+# and dependents that have faulted 5 or more times
+# all arguments to this script are passed to pstamptool
+
+# 25 is PSTAMP_NOT_AVAILABLE
+fault_code=25
+fault_count=5
+
+date
+echo stopping faulted dependent jobs
+pstamptool -stopdependentjob -set_fault $fault_code -fault_count $fault_count $*
+
+echo stopping faulted jobs
+pstamptool -updatejob -state run -set_state stop -set_fault $fault_code -fault_count $fault_count $*
