Index: branches/pap/ippTasks/fake.pro
===================================================================
--- branches/pap/ippTasks/fake.pro	(revision 23948)
+++ branches/pap/ippTasks/fake.pro	(revision 25027)
@@ -7,14 +7,11 @@
 
 book init fakePendingImfile
-book init fakePendingCleanup
 
 macro fake.status
   book listbook fakePendingImfile
-  book listbook fakePendingCleanup
 end
 
 macro fake.reset
   book init fakePendingImfile
-  book init fakePendingCleanup
 end
 
@@ -43,24 +40,7 @@
 end
 
-macro fake.cleanup.on
-  task fake.cleanup.load
-    active true
-  end
-  task fake.cleanup.run
-    active true
-  end
-end
-
-macro fake.cleanup.off
-  task fake.cleanup.load
-    active false
-  end
-  task fake.cleanup.run
-    active false
-  end
-end
-
 # this variable will cycle through the known database names
 $fakeImfile_DB = 0
+$fake_revert_DB = 0
 
 # select images ready for fake analysis
@@ -79,4 +59,5 @@
 
   task.exec
+    if ($LABEL:n == 0) break
     $run = faketool -pendingimfile
     if ($DB:n == 0)
@@ -90,4 +71,5 @@
     end
     add_poll_args run
+    add_poll_labels run
     command $run
   end
@@ -123,6 +105,12 @@
 
   task.exec
+    # fake is fast, so generate a bunch of commands in a row
     book npages fakePendingImfile -var N
-    if ($N == 0) break
+    if ($N == 0)
+       periods -exec $RUNEXEC
+       break
+    end
+    periods -exec 0.05
+
     if ($NETWORK == 0) break
     
@@ -198,5 +186,6 @@
   periods      -poll $LOADPOLL
   periods      -exec $LOADEXEC
-  periods      -timeout 30
+  periods      -exec 30
+  periods      -timeout 60
   npending     1
 
@@ -205,4 +194,5 @@
 
   task.exec
+    if ($LABEL:n == 0) break
     $run = faketool -advanceexp -limit 10
     if ($DB:n == 0)
@@ -216,4 +206,5 @@
     end
     add_poll_args run
+    add_poll_labels run
     command $run
   end
@@ -238,35 +229,28 @@
 end
 
-# this variable will cycle through the known database names
-$fake_cleanup_DB = 0
-
-# select images ready for fake analysis
-# new entries are added to fakePendingImfile
-# skip already-present entries
-task	       fake.cleanup.load
+task fake.revert
   host         local
 
-  periods      -poll $LOADPOLL
-  periods      -exec $LOADEXEC
-  periods      -timeout 30
+  periods      -poll 5.0
+  periods      -exec 60.0
+  periods      -timeout 120.0
   npending     1
-  active       false
 
   stdout NULL
-  stderr $LOGDIR/fake.cleanup.log
-
-  task.exec
-    $run = faketool -pendingcleanuprun
+  stderr $LOGDIR/revert.log
+
+  task.exec
+    if ($LABEL:n == 0) break
+    $run = faketool -revertprocessedimfile
     if ($DB:n == 0)
       option DEFAULT
-      command 
     else
       # save the DB name for the exit tasks
-      option $DB:$fake_cleanup_DB
-      $run = $run -dbname $DB:$fake_cleanup_DB
-      $fake_cleanup_DB ++
-      if ($fake_cleanup_DB >= $DB:n) set fake_cleanup_DB = 0
-    end
-    add_poll_args run
+      option $DB:$fake_revert_DB
+      $run = $run -dbname $DB:$fake_revert_DB
+      $fake_revert_DB ++
+      if ($fake_revert_DB >= $DB:n) set fake_revert_DB = 0
+    end
+    add_poll_labels run
     command $run
   end
@@ -274,12 +258,4 @@
   # success
   task.exit    0
-    # convert 'stdout' to book format
-    ipptool2book stdout fakePendingCleanup -key fake_id -uniq -setword dbname $options:0 -setword pantaskState INIT
-    if ($VERBOSE > 2)
-      book listbook fakePendingCleanup
-    end
-
-    # delete existing entries in the appropriate pantaskStates
-    process_cleanup fakePendingCleanup
   end
 
@@ -298,61 +274,2 @@
   end
 end
-
-# run the ipp_cleanup.pl script on pending images
-task	       fake.cleanup.run
-  periods      -poll $RUNPOLL
-  periods      -exec $RUNEXEC
-  periods      -timeout 60
-  active       false
-
-  task.exec
-    book npages fakePendingCleanup -var N
-    if ($N == 0) break
-    if ($NETWORK == 0) break
-    
-    # look for new images in fakePendingCleanup (pantaskState == INIT)
-    book getpage fakePendingCleanup 0 -var pageName -key pantaskState INIT
-    if ("$pageName" == "NULL") break
-
-    book setword fakePendingCleanup $pageName pantaskState RUN
-    book getword fakePendingCleanup $pageName camera -var CAMERA
-    book getword fakePendingCleanup $pageName state -var CLEANUP_MODE
-    book getword fakePendingCleanup $pageName fake_id -var FAKE_ID
-    book getword fakePendingCleanup $pageName dbname -var DBNAME
-
-    # specify choice of local or remote host based on camera and fake (class_id)
-    set.host.for.camera $CAMERA FPA
-
-    stdout $LOGDIR/fake.cleanup.log
-    stderr $LOGDIR/fake.cleanup.log
-
-    # XXX is everything listed here needed?
-    $run = ipp_cleanup.pl --stage fake --stage_id $FAKE_ID --camera $CAMERA --mode $CLEANUP_MODE
-    add_standard_args run
-
-    # save the pageName for future reference below
-    options $pageName
-
-    # create the command line
-    if ($VERBOSE > 1)
-      echo command $run
-    end
-    command $run
-  end
-
-  # default exit status
-  task.exit    default
-    process_exit fakePendingCleanup $options:0 $JOB_STATUS
-  end
-
-  task.exit    crash
-    showcommand crash
-    book setword fakePendingCleanup $options:0 pantaskState CRASH
-  end
-
-  # operation timed out?
-  task.exit    timeout
-    showcommand timeout
-    book setword fakePendingCleanup $options:0 pantaskState TIMEOUT
-  end
-end
