Index: /branches/eam_branches/20091201/ippTasks/Makefile.am
===================================================================
--- /branches/eam_branches/20091201/ippTasks/Makefile.am	(revision 26866)
+++ /branches/eam_branches/20091201/ippTasks/Makefile.am	(revision 26867)
@@ -29,5 +29,7 @@
 	receive.pro \
 	publish.pro \
-	science.cleanup.pro
+	dqstats.pro \
+	science.cleanup.pro \
+	nightly_stacks.pro
 
 other_files = \
Index: /branches/eam_branches/20091201/ippTasks/chip.pro
===================================================================
--- /branches/eam_branches/20091201/ippTasks/chip.pro	(revision 26866)
+++ /branches/eam_branches/20091201/ippTasks/chip.pro	(revision 26867)
@@ -138,6 +138,6 @@
     book getword chipPendingImfile $pageName state -var RUN_STATE
 
-    if ("$RAW_MAGICKED" == "T")
-        $MAGICKED_ARG = "--magicked"
+    if ($RAW_MAGICKED > 0)
+        $MAGICKED_ARG = "--magicked $RAW_MAGICKED"
     else 
         $MAGICKED_ARG = ""
Index: /branches/eam_branches/20091201/ippTasks/destreak.pro
===================================================================
--- /branches/eam_branches/20091201/ippTasks/destreak.pro	(revision 26866)
+++ /branches/eam_branches/20091201/ippTasks/destreak.pro	(revision 26867)
@@ -226,5 +226,5 @@
     # TODO: do not add recoveryroot or replace if they are null or zero
 
-    $run = magic_destreak.pl --magic_ds_id $MAGIC_DS_ID --camera $CAMERA --streaks $STREAKS --inv_streaks $INV_STREAKS --stage $STAGE --stage_id $STAGE_ID --component $COMPONENT --uri $URI --path_base $PATH_BASE --cam_path_base $CAM_PATH_BASE --outroot $OUTROOT --logfile $logfile --recoveryroot $RECROOT --replace $REPLACE
+    $run = magic_destreak.pl --magic_ds_id $MAGIC_DS_ID --camera $CAMERA --exp_id $EXP_ID --streaks $STREAKS --inv_streaks $INV_STREAKS --stage $STAGE --stage_id $STAGE_ID --component $COMPONENT --uri $URI --path_base $PATH_BASE --cam_path_base $CAM_PATH_BASE --outroot $OUTROOT --logfile $logfile --recoveryroot $RECROOT --replace $REPLACE
 
     add_standard_args run
Index: /branches/eam_branches/20091201/ippTasks/diff.pro
===================================================================
--- /branches/eam_branches/20091201/ippTasks/diff.pro	(revision 26866)
+++ /branches/eam_branches/20091201/ippTasks/diff.pro	(revision 26867)
@@ -155,4 +155,5 @@
     book getword diffSkyfile $pageName bothways -var BOTHWAYS
     book getword diffSkyfile $pageName workdir -var WORKDIR_TEMPLATE
+    book getword diffSkyfile $pageName state -var RUN_STATE
     book getword diffSkyfile $pageName dbname -var DBNAME
     book getword diffSkyfile $pageName reduction -var REDUCTION
@@ -172,5 +173,5 @@
     stderr $LOGDIR/diff.skycell.log
 
-    $run = diff_skycell.pl --threads @MAX_THREADS@ --diff_id $DIFF_ID --skycell_id $SKYCELL_ID --diff_skyfile_id $DIFF_SKYFILE_ID --outroot $outroot --redirect-output
+    $run = diff_skycell.pl --threads @MAX_THREADS@ --diff_id $DIFF_ID --skycell_id $SKYCELL_ID --diff_skyfile_id $DIFF_SKYFILE_ID --outroot $outroot --redirect-output --run-state $RUN_STATE
     if ("$BOTHWAYS" == "T")
        $run = $run --inverse
Index: /branches/eam_branches/20091201/ippTasks/dist.cleanup.pro
===================================================================
--- /branches/eam_branches/20091201/ippTasks/dist.cleanup.pro	(revision 26866)
+++ /branches/eam_branches/20091201/ippTasks/dist.cleanup.pro	(revision 26867)
@@ -48,9 +48,9 @@
 
   stdout NULL
-  stderr $LOGDIR/dist.cleanup.log
+  stderr $LOGDIR/dist.cleanup.load.log
 
   task.exec
     if ($LABEL:n == 0) break
-    $run = disttool -pendingcleanup
+    $run = disttool -pendingcleanup -all
     if ($DB:n == 0)
       option DEFAULT
@@ -98,5 +98,5 @@
   periods      -poll $RUNPOLL
   periods      -exec $RUNEXEC
-  periods      -timeout 60
+  periods      -timeout 600
   active       false
 
Index: /branches/eam_branches/20091201/ippTasks/magic.pro
===================================================================
--- /branches/eam_branches/20091201/ippTasks/magic.pro	(revision 26866)
+++ /branches/eam_branches/20091201/ippTasks/magic.pro	(revision 26867)
@@ -14,4 +14,6 @@
 $magicToTree_DB = 0
 $magicToProcess_DB = 0
+$magicRevertTree_DB = 0
+$magicRevertNode_DB = 0
 
 ### Check status of tasks
@@ -28,4 +30,13 @@
 
 ### Turn tasks on
+macro magic.revert.on
+  task magic.revert.node
+    active true
+  end
+  task magic.revert.tree
+    active true
+  end
+end
+
 macro magic.on
   task magic.tree.load
@@ -40,4 +51,14 @@
   task magic.process.run
     active true
+  end
+  magic.revert.on
+end
+
+macro magic.revert.off
+  task magic.revert.node
+    active false
+  end
+  task magic.revert.tree
+    active false
   end
 end
@@ -57,4 +78,5 @@
     active false
   end
+  magic.revert.off
 end
 
@@ -325,2 +347,93 @@
   end
 end
+
+task magic.revert.node
+  host         local
+
+  periods      -poll 5.0
+  periods      -exec 60.0
+  periods      -timeout 120.0
+  npending     1
+
+  stdout NULL
+  stderr $LOGSUBDIR/revertnode.log
+
+  task.exec
+    if ($LABEL:n == 0) break
+    $run = magictool -revertnode
+    if ($DB:n == 0)
+      option DEFAULT
+    else
+      # save the DB name for the exit tasks
+      option $DB:$magicRevertNode_DB
+      $run = $run -dbname $DB:$magicRevertNode_DB
+      $magicRevertNode_DB ++
+      if ($magicRevertNode_DB >= $DB:n) set magicRevertNode_DB = 0
+    end
+    add_poll_labels run
+    command $run
+  end
+
+  # success
+  task.exit    0
+  end
+
+  # locked list
+  task.exit    default
+    showcommand failure
+  end
+
+  task.exit    crash
+    showcommand crash
+  end
+
+  # operation times out?
+  task.exit    timeout
+    showcommand timeout
+  end
+end
+task magic.revert.tree
+  host         local
+
+  periods      -poll 5.0
+  periods      -exec 60.0
+  periods      -timeout 120.0
+  npending     1
+
+  stdout NULL
+  stderr $LOGSUBDIR/reverttree.log
+
+  task.exec
+    if ($LABEL:n == 0) break
+    $run = magictool -reverttree
+    if ($DB:n == 0)
+      option DEFAULT
+    else
+      # save the DB name for the exit tasks
+      option $DB:$magicRevertTree_DB
+      $run = $run -dbname $DB:$magicRevertTree_DB
+      $magicRevertTree_DB ++
+      if ($magicRevertTree_DB >= $DB:n) set magicRevertTree_DB = 0
+    end
+    add_poll_labels run
+    command $run
+  end
+
+  # success
+  task.exit    0
+  end
+
+  # locked list
+  task.exit    default
+    showcommand failure
+  end
+
+  task.exit    crash
+    showcommand crash
+  end
+
+  # operation times out?
+  task.exit    timeout
+    showcommand timeout
+  end
+end
Index: /branches/eam_branches/20091201/ippTasks/summit.copy.pro
===================================================================
--- /branches/eam_branches/20091201/ippTasks/summit.copy.pro	(revision 26866)
+++ /branches/eam_branches/20091201/ippTasks/summit.copy.pro	(revision 26867)
@@ -111,4 +111,5 @@
 
     task.exec
+#      echo "DB_DEBUG: PRE" $pztoolDatastore_DB $DB:$pztoolDatastore_DB
       if ($DB:n == 0)
         option DEFAULT
@@ -121,4 +122,7 @@
         if ($pztoolDatastore_DB >= $DB:n) set pztoolDatastore_DB = 0
       end
+
+      # More debug
+#      echo "DB_DEBUG: POST" $pztoolDatastore_DB $DB:$pztoolDatastore_DB
       periods -exec 120
     end
@@ -127,5 +131,5 @@
     task.exit 0
         # flush pzDataStore book
-        book init pzDataStore
+#        book init pzDataStore
         # convert 'stdout' to book format
         ipptool2book stdout pzDataStore -key camera:telescope -uniq -setword dbname $options:0
@@ -147,5 +151,5 @@
 # run pzgetexp periodically to populate pzPendingExp in the database (no I/O)
 # this task is querying the data store for a list of exposures ("filesets")
-# and inserting these into a db table on the local cluster (pzPendingExp)
+# and inserting these into a db table on the local cluster (pzDownloadExp)
 task pzgetexp
   periods      -exec     30
@@ -379,5 +383,5 @@
     periods      -exec     5
     periods      -poll     0.05
-    periods      -timeout  650
+    periods      -timeout  1150
     trange        -reset
     # only active in the night (18:00 to 06:00 HST, times are UT):
@@ -446,14 +450,25 @@
 	stderr $LOGDIR/summit.copy.log
 
-        $run = summit_copy.pl --uri $URI --filename $FILENAME --exp_name $EXP_NAME --inst $CAMERA --telescope $TELESCOPE --class $CLASS --class_id $CLASS_ID --bytes $BYTES --md5 $MD5SUM --dbname $DBNAME --timeout 120 --verbose --copies 2
-	if ($COMPRESS) 
+	book getpage pzDataStore 0 -var PZDSPAGE -key dbname $DBNAME 
+	book getword pzDataStore $PZDSPAGE use_compress  -var USECOMPRESS
+
+	# Debug line
+#	echo "DEBUG: " $DBNAME $EXP_NAME $CAMERA $PZDSPAGE $USECOMPRESS
+
+        # unconditionally turn on requesting compression until we figuure
+        # out why the above doesn't work
+	if ($USECOMPRESS == "NULL") 
+#	if ("$CAMERA" == "gpc1") 
+	    $USECOMPRESS = 1
+	end
+
+        $run = summit_copy.pl --uri $URI --filename $FILENAME --exp_name $EXP_NAME --inst $CAMERA --telescope $TELESCOPE --class $CLASS --class_id $CLASS_ID --bytes $BYTES --md5 $MD5SUM --dbname $DBNAME --timeout 600 --verbose --copies 2
+	if ($USECOMPRESS == 1) 
             $run = $run --compress
-        else
-            $run = $run --bytes $BYTES 
-        end
-        if (("$MD5SUM" != "NULL") && ("$MD5SUM" != "0") && (not($COMPRESS)))
+        end
+#        if (("$MD5SUM" != "NULL") && ("$MD5SUM" != "0") && (not($COMPRESS)))
 # && (($YEAR > 2008) || (("$YEAR" = "2007") && ($MONTH > 8))))
-            $run = $run --md5 $MD5SUM
-        end
+#            $run = $run --md5 $MD5SUM
+#        end
 	if ($NEBULOUS) 
             $run = $run --nebulous
@@ -463,9 +478,11 @@
         # store the pageName for future reference below
         options $pageName
-
+	
         # create the command line
         if ($VERBOSE > 1)
           echo command $run
         end
+	# More debug:
+#	echo "DEBUG2: " $run
         command $run
     end
@@ -506,5 +523,5 @@
         if ($pztoolClearFault_DB >= $DB:n) set pztoolClearFault_DB = 0
       end
-      periods -exec 600
+      periods -exec 1800
     end
 
Index: /branches/eam_branches/20091201/ippTasks/warp.pro
===================================================================
--- /branches/eam_branches/20091201/ippTasks/warp.pro	(revision 26866)
+++ /branches/eam_branches/20091201/ippTasks/warp.pro	(revision 26867)
@@ -295,6 +295,6 @@
     book getword warpPendingSkyCell $pageName state -var RUN_STATE
     book getword warpPendingSkyCell $pageName magicked -var CHIP_MAGICKED
-    if ("$CHIP_MAGICKED" == "T")
-        $MAGICKED_ARG = "--magicked"
+    if ($CHIP_MAGICKED > 0)
+        $MAGICKED_ARG = "--magicked $CHIP_MAGICKED"
     else
         $MAGICKED_ARG = ""
