Index: /branches/czw_branch/20110406/ippScripts/scripts/lap_science.pl
===================================================================
--- /branches/czw_branch/20110406/ippScripts/scripts/lap_science.pl	(revision 31429)
+++ /branches/czw_branch/20110406/ippScripts/scripts/lap_science.pl	(revision 31430)
@@ -25,5 +25,5 @@
 my $laptool  = can_run('laptool') or (warn "Can't find laptool" and $missing_tools = 1);
 
-my ( $help, $verbose, $debug);
+my ( $help, $verbose, $debug, $do_nothing);
 my ( $camera, $dbname);
 my ( $lap_id );
@@ -34,4 +34,5 @@
     'verbose'      => \$verbose,
     'debug'        => \$debug,
+    'do_nothing'   => \$do_nothing,
 
     'camera=s'     => \$camera,
@@ -106,5 +107,5 @@
 	unless ($success) {
 	    $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
-	    &my_die("Unable to perform laptool: $error_code", $lap_id);
+	    &my_die("Unable to perform laptool -updaterun: $error_code", $lap_id);
 	}
     }
@@ -126,8 +127,8 @@
     unless ($success) {
 	$error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
-	&my_die("Unable to perform chiptool: $error_code", $exp_id, $data_group);
+	&my_die("Unable to perform chiptool -listrun: $error_code", $exp_id, $data_group);
     }
     my $chips = $mdcParser->parse_list(join "", @$stdout_buf) or
-	&my_die("Unable to parse metadata from chiptool", $exp_id, $data_group);
+	&my_die("Unable to parse metadata from chiptool -listrun", $exp_id, $data_group);
     # There should be only one.
     my $chip = ${ $chips }[0];
@@ -148,8 +149,8 @@
     unless ($success) {
 	$error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
-	&my_die("Unable to perform laptool: $error_code", $lap_id);
+	&my_die("Unable to perform laptool -pendingrun: $error_code", $lap_id);
     }
     my $Runs = $mdcParser->parse_list(join "", @$stdout_buf) or
-	&my_die("Unable to parse metadata from laptool", $lap_id);
+	&my_die("Unable to parse metadata from laptool -pendingrun", $lap_id);
     # There should be only one.
     my $Run = ${ $Runs }[0];
@@ -186,5 +187,5 @@
     unless ($success) {
 	$error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
-	&my_die("Unable to perform chiptool: $error_code", $exposure->{lap_id}, $exposure->{proj_cell});
+	&my_die("Unable to perform chiptool -definebyquery: $error_code", $exposure->{lap_id}, $exposure->{proj_cell});
     }
     
@@ -205,5 +206,5 @@
     unless ($success) {
 	$error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
-	&my_die("Unable to perform laptool: $error_code", $lap_id);
+	&my_die("Unable to perform laptool -pendingexp: $error_code", $lap_id);
     }
     
@@ -214,5 +215,5 @@
     
     my $exposures = $mdcParser->parse_list(join "", @$stdout_buf) or
-	&my_die("Unable to parse metadata from laptool", $lap_id);
+	&my_die("Unable to parse metadata from laptool -pendingexp", $lap_id);
 
     my $counter = 0;
@@ -324,5 +325,5 @@
     unless($success) {
 	$error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
-	&my_die("Unable to perform laptool: $error_code", $lap_id, "");
+	&my_die("Unable to perform laptool -stacks: $error_code", $lap_id, "");
     }
 
@@ -334,5 +335,5 @@
 
     my $stacks = $mdcParser->parse_list(join "", @$stdout_buf) or
-	&my_die("Unable to parse metadata from laptool", $lap_id, "");
+	&my_die("Unable to parse metadata from laptool -stacks", $lap_id, "");
 
     my $total_qstacks = 0;
@@ -396,5 +397,5 @@
     unless ($success) {
 	$error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
-	&my_die("Unable to perform laptool: $error_code", $lap_id);
+	&my_die("Unable to perform laptool -exposures: $error_code", $lap_id);
     }
     
@@ -405,5 +406,5 @@
     
     my $exposures = $mdcParser->parse_list(join "", @$stdout_buf) or
-	&my_die("Unable to parse metadata from laptool", $lap_id);
+	&my_die("Unable to parse metadata from laptool -exposures", $lap_id);
 
     # Need to prescan to see who matches whom.
@@ -466,13 +467,19 @@
 # 	    }
 # 	}
-	if ((($exposure->{warpRun_state})&&  # This exposure has a warp
-	    ($exposure->{warpRun_state} eq 'full'))|| # This exposure's warp is either done or impossible.
-	     ($exposure->{data_state} eq 'drop')) {
+	if  ($exposure->{data_state} eq 'drop') { # This exposure is impossible, so fudge the counts so we get through.
 	    $can_qstack ++;
 	    $can_diff ++;
+	    $have_diff ++;
+	    $can_fstack ++;	    
+	    next;
+	}
+
+	if (($exposure->{warpRun_state})&&  # This exposure has a warp
+	    ($exposure->{warpRun_state} eq 'full')) { # This exposure's warp is done.
+	    $can_qstack ++;
+	    $can_diff ++;
 	}
 	if (($exposure->{magicked}&&
-	     &S64_IS_NOT_NULL($exposure->{magicked}))||  # This exposure has been magicked, so it is through with diff.
-	    ($exposure->{data_state} eq 'drop')) {
+	     &S64_IS_NOT_NULL($exposure->{magicked}))) {  # This exposure has been magicked, so it is through with diff.
 	    $can_fstack ++;
 	}
@@ -497,5 +504,7 @@
 
     print "STATUS: TOTAL_EXPOSURES: $total_exposures\n";
-
+    if ($do_nothing) {
+	exit(0);
+    }
     if (($needs_qstack == 1)&&              # Do we need the quick stack?
 	($defined_qstack == 0)&&            # Have we not made it already?
@@ -533,5 +542,5 @@
 	unless ($success) {
 	    $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
-	    &my_die("Unable to perform laptool: $error_code", $lap_id);
+	    &my_die("Unable to perform laptool -updaterun: $error_code", $lap_id);
 	}
     }
@@ -564,5 +573,5 @@
     $command .= " -dbname $dbname " if defined $dbname;
     $command .= " -definebyquery -select_label $label -select_skycell_id ${proj_cell}.% -select_filter $filter ";
-    $command .= " -set_label ${label}.quick -set_data_group ${proj_cell}.quick.${date} ";
+    $command .= " -set_label ${label} -set_data_group ${proj_cell}.quick.${date} ";
     $command .= "  -set_workdir $workdir  -set_dist_group NODIST ";
     $command .= " -min_num 2 -set_reduction QUICKSTACK ";
@@ -572,5 +581,5 @@
     unless ($success) {
 	$error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
-	&my_die("Unable to perform chiptool: $error_code", $lap_id);
+	&my_die("Unable to perform stacktool -definebyquery: $error_code", $lap_id);
     }
 
@@ -584,9 +593,9 @@
     unless ($success) {
 	$error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
-	&my_die("Unable to perform chiptool: $error_code", $lap_id);
+	&my_die("Unable to perform stacktool -sassskyfile: $error_code", $lap_id);
     }
     
     my $stacks = $mdcParser->parse_list(join "", @$stdout_buf) or
-	&my_die("Unable to parse metadata from laptool", $lap_id, "");
+	&my_die("Unable to parse metadata from stacktool -sassskyfile", $lap_id, "");
     
     my $stack = ${ $stacks }[0];
@@ -604,5 +613,5 @@
     unless ($success) {
 	$error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
-	&my_die("Unable to perform chiptool: $error_code", $lap_id);
+	&my_die("Unable to perform laptool -updaterun: $error_code", $lap_id);
     }
     
@@ -634,5 +643,5 @@
     $command .= " -dbname $dbname " if defined $dbname;
     $command .= " -definebyquery -select_label $label -select_skycell_id ${proj_cell}.% -select_filter $filter ";
-    $command .= " -set_label ${label}.final -set_workdir $workdir -set_data_group ${proj_cell}.final.${date} ";
+    $command .= " -set_label ${label} -set_workdir $workdir -set_data_group ${proj_cell}.final.${date} ";
     $command .= " -min_num 2 -set_reduction THREEPI_STACK ";
 
@@ -641,5 +650,5 @@
     unless ($success) {
 	$error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
-	&my_die("Unable to perform chiptool: $error_code", $lap_id);
+	&my_die("Unable to perform stacktool -definebyquery: $error_code", $lap_id);
     }
     
@@ -654,9 +663,9 @@
     unless ($success) {
 	$error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
-	&my_die("Unable to perform chiptool: $error_code", $lap_id);
+	&my_die("Unable to perform stacktool -sassskyfile: $error_code", $lap_id);
     }
 
     my $stacks = $mdcParser->parse_list(join "", @$stdout_buf) or
-	&my_die("Unable to parse metadata from laptool", $lap_id, "");
+	&my_die("Unable to parse metadata from stacktool -sassskyfile", $lap_id, "");
 
     my $stack = ${ $stacks }[0];
@@ -673,5 +682,5 @@
     unless ($success) {
 	$error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
-	&my_die("Unable to perform chiptool: $error_code", $lap_id);
+	&my_die("Unable to perform laptool -updaterun: $error_code", $lap_id);
     }
 
@@ -742,9 +751,9 @@
 	unless ($success) {
 	    $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
-	    &my_die("unable to perform difftool: $error_code", $exposure->{lap_id}, $exposure->{proj_cell});
+	    &my_die("unable to perform difftool -definewarp(warp|stack): $error_code", $exposure->{lap_id}, $exposure->{proj_cell});
 	}
 	
 	my $diffs = $mdcParser->parse_list(join "", @$stdout_buf) or
-	    &my_die("Unable to parse metadata from laptool", $lap_id, "");
+	    &my_die("Unable to parse metadata from difftool -definewarp(warp|stack)", $lap_id, "");
 	
 	my $diff = ${ $diffs }[0];
@@ -781,5 +790,5 @@
     unless ($success) {
 	$error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
-	&my_die("Unable to perform laptool: $error_code", "none", "none");
+	&my_die("Unable to perform laptool -inactiveexp: $error_code", "none", "none");
     }
     if (@$stdout_buf == 0) {
@@ -789,5 +798,5 @@
     
     my $exposures = $mdcParser->parse_list(join "", @$stdout_buf) or
-	&my_die("Unable to parse metadata from laptool", $lap_id);
+	&my_die("Unable to parse metadata from laptool -inactiveexp", $lap_id);
 
     my @clean_modes = (
@@ -814,5 +823,5 @@
 	    unless ($success) {
 		$error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
-		&my_die("Unable to perform laptool: $error_code", "none", "none");
+		&my_die("Unable to perform cleantool: $command : $error_code", "none", "none");
 	    }
  	}
@@ -893,5 +902,5 @@
     unless ($success) {
 	$error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
-	&my_die("Unable to perform laptool: $error_code", $exposure->{lap_id}, $exposure->{proj_cell});
+	&my_die("Unable to perform laptool -updateexp: $error_code", $exposure->{lap_id}, $exposure->{proj_cell});
     }
 }    
Index: /branches/czw_branch/20110406/ippTools/src/laptool.c
===================================================================
--- /branches/czw_branch/20110406/ippTools/src/laptool.c	(revision 31429)
+++ /branches/czw_branch/20110406/ippTools/src/laptool.c	(revision 31430)
@@ -460,15 +460,17 @@
   if (rows) {
     // We're done with these exposures now, so mark them as inactive.
-    if ((strcmp(state,"drop") == 0)||
-	(strcmp(state,"full") == 0)) {
-      values = psMetadataAlloc();
-      psMetadataAddBool(values, PS_LIST_TAIL, "active", 0, "", false);
-      long exps = psDBUpdateRows(config->dbh, "lapExp", where, values);
-
-      if (exps) {
-	return(true);
-      }
-      else {
-	return(true); // We shouldn't really fail if we didn't change anything. Maybe there's nothing to change.
+    if (state) {
+      if ((strcmp(state,"drop") == 0)||
+	  (strcmp(state,"full") == 0)) {
+	values = psMetadataAlloc();
+	psMetadataAddBool(values, PS_LIST_TAIL, "active", 0, "", false);
+	long exps = psDBUpdateRows(config->dbh, "lapExp", where, values);
+	
+	if (exps) {
+	  return(true);
+	}
+	else {
+	  return(true); // We shouldn't really fail if we didn't change anything. Maybe there's nothing to change.
+	}
       }
     }
