Index: /trunk/tools/runcameraexp.pl
===================================================================
--- /trunk/tools/runcameraexp.pl	(revision 29158)
+++ /trunk/tools/runcameraexp.pl	(revision 29159)
@@ -32,5 +32,5 @@
 my $dbh = getDBHandle();
 
-my $query = "SELECT rawExp.camera, rawExp.exp_tag, camProcessedExp.path_base, camRun.dvodb, camRun.reduction, camRun.state FROM camRun JOIN camProcessedExp USING(cam_id) JOIN chipRun USING(chip_id) JOIN rawExp USING(exp_id) WHERE cam_id = $cam_id";
+my $query = "SELECT rawExp.camera, rawExp.exp_tag, camProcessedExp.path_base, camProcessedExp.fault, camRun.dvodb, camRun.reduction, camRun.state FROM camRun JOIN camProcessedExp USING(cam_id) JOIN chipRun USING(chip_id) JOIN rawExp USING(exp_id) WHERE cam_id = $cam_id";
 
 my $stmt = $dbh->prepare($query);
@@ -44,4 +44,5 @@
 my $reduction = $results->{reduction};
 my $state = $results->{state};
+my $fault = $results->{fault};
 
 die "path_base not found\n" if !$path_base;
@@ -51,4 +52,6 @@
 die "state not found\n" if !$state;
 die "reduction not found\n" if !$reduction;
+
+die "Cannot update when run is not faulted\n" if $update and ! $fault;
 
 my  $run_state;
@@ -63,8 +66,9 @@
 $command .= " --reduction $reduction" if $reduction and ($reduction ne "NULL");
 $command .= " --dvodb $dvodb" if $dvodb and ($dvodb ne "NULL");
-$command .= " --redirect-output" if $redirect;
+$command .= " --redirect-output" if $redirect or $update;
 $command .= " --no-update" unless $update;
 $command .= " --verbose" unless $no_verbose;
 $command .= " --dbname $dbname" if $dbname;
+
 
 
@@ -109,2 +113,50 @@
 }
 
+__END__
+
+=pod
+
+=head1 NAME
+
+runcameraexp.pl - gather the parameters for and execute camera_exp.pl
+
+=head1 SYNOPSIS
+    
+    perl runcameraexp.pl --cam_id <cam_id> [--update] [--redirect-output] [--pretend] [--dbname <dbname>]
+
+Query the database for the results of a completed camera run and rerun the processing, optionally reverting a faulted
+run.
+
+=over 4
+
+=item * --cam_id <cam_id>
+
+The id of the camera run to process.
+
+=item * --update
+
+Revert a faulted run before processing. WARNING: insure that the standard science procesing either has camera stage turned off or the
+label of this camRun ommited from the label list otherwise it may attempt to processes this run at the same time.
+Optional.
+
+=item *  --redirect-output
+
+Send the output of the command to the logfile. (This is the default if --update is supplied);
+Optional.
+
+=item * --pretend
+
+Just print the commands that would be executed, but do not run them.
+Optional.
+
+
+=item * --dbname <dbname>
+
+Name of the IPP databse to query. Default is 'gpc1'.
+Optional.
+
+
+=head1 SEE ALSO
+L<runchipimfile.pl>, L<runwarpskyfile.pl>, L<rundiffskyfile.pl>
+
+=cut
Index: /trunk/tools/rundiffskycell.pl
===================================================================
--- /trunk/tools/rundiffskycell.pl	(revision 29158)
+++ /trunk/tools/rundiffskycell.pl	(revision 29159)
@@ -41,9 +41,12 @@
     if !$diff_id or !$skycell_id;
 
+# if we're asked to update redirect the output
+$redirect = 1 if $update;
+
 my $ipprc =  PS::IPP::Config->new();
 my $dbh = getDBHandle();
 
 # find warp warp diffs that have a cleaned magicDSRun
-my $query1 = "SELECT path_base, diff_skyfile_id,bothways,reduction,diff_mode FROM diffRun JOIN diffSkyfile USING(diff_id)  JOIN diffInputSkyfile USING(diff_id, skycell_id) WHERE diff_id = $diff_id AND skycell_id = '$skycell_id'";
+my $query1 = "SELECT path_base, diff_skyfile_id,bothways,reduction,diff_mode, diffSkyfile.fault FROM diffRun JOIN diffSkyfile USING(diff_id)  JOIN diffInputSkyfile USING(diff_id, skycell_id) WHERE diff_id = $diff_id AND skycell_id = '$skycell_id'";
 
 my $stmt1 = $dbh->prepare($query1);
@@ -54,4 +57,7 @@
 my $bothways = $results->{bothways};
 my $reduction = $results->{reduction};
+my $fault = $results->{fault};
+
+die "cannot update when skycell is not faulted\n" if $update and !$fault;
 
 die "path_base not found\n" if !$path_base;
@@ -105,2 +111,60 @@
 }
 
+__END__
+
+=pod
+
+=head1 NAME
+
+rundiffskyfile.pl - gather the parameters for and execute diff_skycell.pl
+
+=head1 SYNOPSIS
+    
+    perl rundiffskyfile.pl --diff_id <diff_id> --skycell_id <skycell_id> [--threads <num_threads>] [--update] [--redirect-output] [--pretend] [--dbname <dbname>]
+
+Query the database for the results of a diff skycell and rerun the processing, optionally reverting a faulted
+run.
+
+=over 4
+
+=item * --diff_id <diff_id>
+
+The id of the diffSkyfile run to process.
+
+=item * --skycell_id <skycell_id>
+
+The skycell_id of the diffSkyfile run to process.
+
+=item * --threads <num_threads>
+
+The number of threads to use. Default 1.
+Optional.
+
+
+=item * --update
+
+Revert a faulted skycell before processing. If the skycell is not faulted no processing is done.
+WARNING: insure that the standard science procesing either has diff stage turned off or the
+label of this diffRun ommited from the list of labels otherwise it may attempt to processes this run at the same time.
+Optional.
+
+=item *  --redirect-output
+
+Send the output of the command to the logfile. (This is the default if --update is supplied).
+Optional.
+
+=item * --pretend
+
+Just print the commands that would be executed, but do not run them.
+Optional.
+
+=item * --dbname <dbname>
+
+Name of the IPP databse to query. Default is 'gpc1'.
+Optional.
+
+
+=head1 SEE ALSO
+L<runchipimfile.pl>, L<runcameraexp.pl>, L<rundiffskyfile.pl>
+
+=cut
Index: /trunk/tools/runwarpskycell.pl
===================================================================
--- /trunk/tools/runwarpskycell.pl	(revision 29158)
+++ /trunk/tools/runwarpskycell.pl	(revision 29159)
@@ -36,5 +36,5 @@
 my $dbh = getDBHandle();
 
-my $query1 = "SELECT warpSkyfile.path_base, warp_skyfile_id, warpRun.tess_id, warpRun.reduction, chipRun.magicked, rawExp.camera, warpRun.state FROM warpRun JOIN warpSkyfile USING(warp_id) JOIN warpImfile USING(warp_id, skycell_id) JOIN fakeRun USING(fake_id) JOIN camRun USING(cam_id) JOIN chipRun USING(chip_id) JOIN rawExp USING(exp_id) WHERE warp_id = $warp_id AND skycell_id = '$skycell_id'";
+my $query1 = "SELECT warpSkyfile.path_base, warpSkyfile.fault, warp_skyfile_id, warpRun.tess_id, warpRun.reduction, chipRun.magicked, rawExp.camera, warpRun.state FROM warpRun JOIN warpSkyfile USING(warp_id) JOIN warpImfile USING(warp_id, skycell_id) JOIN fakeRun USING(fake_id) JOIN camRun USING(cam_id) JOIN chipRun USING(chip_id) JOIN rawExp USING(exp_id) WHERE warp_id = $warp_id AND skycell_id = '$skycell_id'";
 
 my $stmt1 = $dbh->prepare($query1);
@@ -49,5 +49,7 @@
 my $camera = $results->{camera};
 my $state = $results->{state};
+my $fault = $results->{fault};
 
+die "cannot update database for a skycell that is not faulted\n" if $update and !$fault;
 
 die "path_base not found\n" if !$path_base;
@@ -121,2 +123,60 @@
 }
 
+__END__
+
+=pod
+
+=head1 NAME
+
+runwarpskyfile.pl - gather the parameters for and execute warp_skycell.pl
+
+=head1 SYNOPSIS
+    
+    perl runwarpskyfile.pl --warp_id <warp_id> --skycell_id <skycell_id> [--threads <num_threads>] [--update] [--redirect-output] [--pretend] [--dbname <dbname>]
+
+Query the database for the results of a warp skycell and rerun the processing, optionally reverting a faulted
+run.
+
+=over 4
+
+=item * --warp_id <warp_id>
+
+The id of the warpSkyfile run to process.
+
+=item * --skycell_id <skycell_id>
+
+The skycell_id of the warpSkyfile run to process.
+
+=item * --threads <num_threads>
+
+The number of threads to use. Default 1.
+Optional.
+
+
+=item * --update
+
+Revert a faulted skycell before processing. If the skycell is not faulted no processing is done.
+WARNING: insure that the standard science procesing either has warp stage turned off or the
+label of this warpRun ommited from the list of labels otherwise it may attempt to processes this run at the same time.
+Optional.
+
+=item *  --redirect-output
+
+Send the output of the command to the logfile. (This is the default if --update is supplied).
+Optional.
+
+=item * --pretend
+
+Just print the commands that would be executed, but do not run them.
+Optional.
+
+=item * --dbname <dbname>
+
+Name of the IPP databse to query. Default is 'gpc1'.
+Optional.
+
+
+=head1 SEE ALSO
+L<runchipimfile.pl>, L<runcameraexp.pl>, L<rundiffskyfile.pl>
+
+=cut
