Index: /branches/eam_branches/ipp-20110213/ippScripts/scripts/magic_destreak.pl
===================================================================
--- /branches/eam_branches/ipp-20110213/ippScripts/scripts/magic_destreak.pl	(revision 30699)
+++ /branches/eam_branches/ipp-20110213/ippScripts/scripts/magic_destreak.pl	(revision 30700)
@@ -152,4 +152,9 @@
 
 
+# We don't use recoveryroot for camera stage
+if ($stage eq 'camera') {
+    $recoveryroot = undef;
+}
+
 # default value is "NULL" do not use
 if (defined($recoveryroot) and ($recoveryroot eq "NULL")) {
Index: /branches/eam_branches/ipp-20110213/ippScripts/scripts/magic_destreak_revert.pl
===================================================================
--- /branches/eam_branches/ipp-20110213/ippScripts/scripts/magic_destreak_revert.pl	(revision 30699)
+++ /branches/eam_branches/ipp-20110213/ippScripts/scripts/magic_destreak_revert.pl	(revision 30700)
@@ -451,4 +451,5 @@
 {
     foreach my $file (@_) {
+        next if !$file;
         if ($ipprc->file_exists($file)) {
             if (!$ipprc->file_delete($file)) {
Index: /branches/eam_branches/ipp-20110213/ippScripts/scripts/nightly_science.pl
===================================================================
--- /branches/eam_branches/ipp-20110213/ippScripts/scripts/nightly_science.pl	(revision 30699)
+++ /branches/eam_branches/ipp-20110213/ippScripts/scripts/nightly_science.pl	(revision 30700)
@@ -1315,5 +1315,4 @@
     my $cam_ref  = $db->selectall_arrayref( $cam_sth );
     my $warp_ref = $db->selectall_arrayref( $warp_sth );
-
     return($#{ $chip_ref } + 1, $#{ $cam_ref } + $#{ $warp_ref } + 2);
 }
@@ -1439,6 +1438,6 @@
 #	$input_sth .= " ORDER BY dateobs ";
 	
-	my $input_sth = "select exp_id,warp_id,dateobs,rawExp.comment,warpRun.state AS warp_state FROM ";
-	$input_sth .=   " rawExp LEFT JOIN chipRun USING (exp_id) LEFT JOIN camRun USING (chip_id) LEFT JOIN fakeRun USING (cam_id) LEFT JOIN warpRun USING (fake_id) ";
+	my $input_sth = "select exp_id,warp_id,dateobs,rawExp.comment,warpRun.state AS warp_state,camProcessedExp.quality FROM ";
+	$input_sth .=   " rawExp LEFT JOIN chipRun USING (exp_id) LEFT JOIN camRun USING (chip_id) LEFT JOIN camProcessedExp USING(cam_id) LEFT JOIN fakeRun USING (cam_id) LEFT JOIN warpRun USING (fake_id) ";
 	$input_sth .=   " WHERE chipRun.label = '$label' AND chipRun.data_group = '$data_group' AND rawExp.filter = '$filter' AND rawExp.object = '$this_object' ";
 	$input_sth .=   " ORDER BY dateobs ";
@@ -1461,5 +1460,5 @@
 	    }
 	    else {
-		print STDERR ": I should declare an exposure to be faulty.\n";
+		print STDERR ": I should declare an exposure to be qualityy.\n";
 		my @keep_warps = ();
 #		print "@{ $warps }\n";
@@ -1494,10 +1493,17 @@
 	    my $input_warp_state = ${ $input_warp }[4];
 	    my $template_warp_state = ${ $template_warp }[4];
-	    
+
+	    my $input_warp_camQuality = ${ $input_warp }[5];
+	    my $template_warp_camQuality = ${ $template_warp }[5];
+
 	    $Npotential++;
 
 	    unless (defined($input_warp_id) && defined($template_warp_id) &&
 		    ($input_warp_state eq 'full')&&($template_warp_state eq 'full')) {
-		print STDERR "Diff for this $date $target $input_exp_id $template_exp_id not fully processed\n";
+		print STDERR "Diff for this $date $target $input_exp_id $template_exp_id not fully processed ($input_warp_state $template_warp_state) ($input_warp_camQuality $template_warp_camQuality)\n";
+		if (($input_warp_camQuality == 4007)||($template_warp_camQuality == 4007)) {
+		    print STDERR "  ...but this is due to a camera stage astrometry quality\n";
+		    $Npotential--;
+		}
 		next;
 	    }
Index: /branches/eam_branches/ipp-20110213/ippTools/src/magicdstool.c
===================================================================
--- /branches/eam_branches/ipp-20110213/ippTools/src/magicdstool.c	(revision 30699)
+++ /branches/eam_branches/ipp-20110213/ippTools/src/magicdstool.c	(revision 30700)
@@ -771,5 +771,4 @@
         break;
     case IPP_STAGE_CAMERA:
-        psFree(query);
         query = NULL;
         clearRunQuery = "UPDATE chipBackgroundRun SET magicked = 0 where chip_bg_id = %" PRId64;
Index: /branches/eam_branches/ipp-20110213/pstamp/scripts/psstatus
===================================================================
--- /branches/eam_branches/ipp-20110213/pstamp/scripts/psstatus	(revision 30699)
+++ /branches/eam_branches/ipp-20110213/pstamp/scripts/psstatus	(revision 30700)
@@ -44,7 +44,9 @@
 
 my $totals_query = "
-SELECT label, count(job_id) AS 'Unfinished Jobs', priority
+SELECT label,
+    count(job_id) AS 'Unfinished Jobs',
+    IFNULL(priority,10000) as priority
 FROM pstampRequest join pstampJob USING(req_id)
-JOIN Label USING(label)
+LEFT JOIN Label USING(label)
 WHERE pstampJob.state ='run' and pstampRequest.state ='run'
 GROUP by label";
@@ -75,7 +77,7 @@
         pstampRequest.fault,
         timestamp,
-        priority
-FROM pstampRequest
-JOIN Label USING(label)
+        IFNULL(priority,10000) AS priority
+FROM pstampRequest
+LEFT JOIN Label USING(label)
     WHERE pstampRequest.state = 'run' or pstampRequest.state ='new' 
    --     OR pstampRequest.state = 'run.wait'
Index: /branches/eam_branches/ipp-20110213/tools/regpeek.pl
===================================================================
--- /branches/eam_branches/ipp-20110213/tools/regpeek.pl	(revision 30699)
+++ /branches/eam_branches/ipp-20110213/tools/regpeek.pl	(revision 30700)
@@ -13,5 +13,5 @@
 my $date = shift(@ARGV);
 unless(defined($date)) {
-    my @time = localtime;
+    my @time = gmtime;
     $date = sprintf("%4d-%02d-%02d",$time[5] + 1900,$time[4] + 1,$time[3]);
 }
