Index: branches/eam_branch_00/ippTasks/phase2.pro
===================================================================
--- branches/eam_branch_00/ippTasks/phase2.pro	(revision 11008)
+++ branches/eam_branch_00/ippTasks/phase2.pro	(revision 11011)
@@ -1,12 +1,5 @@
 ## this file contains the tasks for running the phase 0 stage
+## these tasks use the book p2PendingImfile
 
-## these tasks use the queue Phase2Imfiles
-## the Phase2Imfiles queue contains:
-## STATE EXP_TAG CLASS CLASS_ID URI-FITS
-## queue keys are counted from 0
-
-# XXX change book names to match ippTool values?
-# XXX replace with book init p2pending
-queueinit Phase2Imfiles
 if ($?network == 0)
   $network = 1
@@ -15,7 +8,4 @@
   $parallel = 0
 end
-
-$Phase2ImfileFail = 0
-
 if ($?VERBOSE == 0)
   echo "VERBOSE not defined: load pantasks.pro first"
@@ -26,15 +16,17 @@
   break
 end
+
 $LOGSUBDIR = $LOGDIR/phase2
 exec mkdir -p $LOGSUBDIR
 
+book init p2PendingImfile
+
 macro phase2.status
-  book listbook p2pending
-  echo "Phase2ImfileFail: $Phase2ImfileFail"
+  book listbook p2PendingImfile
 end
 
 # select images ready for phase2 analysis
-# new entries are added to queue Phase2Imfiles
-# compare the new list with the ones already selected
+# new entries are added to p2PendingImfile
+# skip already-present entries
 task	       phase2.imfile.load
   host         local
@@ -48,6 +40,4 @@
 
   task.exec
-    # command p2tool -pendingimfile -simple -limit {$Phase2ImfileFail + 20}
-    # XXX make sure we remove FAIL and TIMEOUT entries
     command p2tool -pendingimfile -limit 20
   end
@@ -55,15 +45,12 @@
   # success
   task.exit    0
-    # stdout from the task is stored on queue 'stdout'
     # convert 'stdout' to book format
-    # only add entries which don't exist in the book
-    # 'state' has value of NULL
-    ipptool2book stdout p2pending -key exp_tag:class_id -uniq
+    ipptool2book stdout p2PendingImfile -key exp_tag:class_id -uniq
     if ($VERBOSE > 2)
-      book listbook p2pending
+      book listbook p2PendingImfile
     end
 
     # delete existing entries which are DONE
-    book delpage p2pending -key state DONE
+    book delpage p2PendingImfile -key state DONE
   end
 
@@ -79,5 +66,5 @@
 end
 
-# run the phase2imfile script on pending images
+# run the phase2.pl script on pending images
 task	       phase2.imfile.run
   periods      -poll $runpoll
@@ -86,20 +73,20 @@
 
   task.exec
-    book npages p2pending -var N
+    book npages p2PendingImfile -var N
     if ($N == 0) break
     if ($network == 0) break
     
-    # look for new images on the internal p2pending book
-    # caution with these 'if' statements: syntax errors 
-    # will make the task fail without given a good status
-    book getpage p2pending 0 -var pageName -key state NULL
-    book setword p2pending $pageName state RUN
+    # look for new images in p2PendingImfile (state == NULL)
+    book getpage p2PendingImfile 0 -var pageName -key state NULL
+    if ($pageName == NULL) break
 
-    book getword p2pending $pageName camera -var CAMERA
-    book getword p2pending $pageName exp_tag -var EXP_TAG
-    book getword p2pending $pageName class_id -var CLASS_ID
-    book getword p2pending $pageName uri -var URI
+    book setword p2PendingImfile $pageName state RUN
+    book getword p2PendingImfile $pageName camera -var CAMERA
+    book getword p2PendingImfile $pageName exp_tag -var EXP_TAG
+    book getword p2PendingImfile $pageName class_id -var CLASS_ID
+    book getword p2PendingImfile $pageName uri -var URI
 
-    # specify choice of remote host:(need to choose based on chips)
+    # specify choice of remote host
+    # XXX need to choose based on chips
     if ($parallel)
       host anyhost
@@ -118,5 +105,5 @@
     exec mkdir -p $LOGSUBDIR/$base
 
-    # save the p2pending book pageName for future reference below
+    # save the pageName for future reference below
     options $pageName
 
@@ -130,7 +117,6 @@
   # success
   task.exit 0
-    # phase2imfile.pl updates DB tables, here we just update the queue
-    book setword p2pending $options:0 state DONE
-    # queuepush Phase2Imfiles -replace -key 1:2 "DONE $options:0"
+    # phase2.pl updates DB tables, here we just update the queue
+    book setword p2PendingImfile $options:0 state DONE
   end
 
@@ -138,16 +124,11 @@
   task.exit    default
     showcommand failure
-    book setword p2pending $options:0 state FAIL
-    # queuepush Phase2Imfiles -replace -key 1:2 "FAIL $options:0"
-    # drop failed entries from the book lists?
-    $Phase2ImfileFail ++
+    book setword p2PendingImfile $options:0 state FAIL
   end
 
-  # operation times out?
+  # operation timed out?
   task.exit    timeout
     showcommand timeout
-    book setword p2pending $options:0 state TIMEOUT
-    # queuepush Phase2Imfiles -replace -key 1:2 "TIMEOUT $options:0"
-    $Phase2ImfileFail ++
+    book setword p2PendingImfile $options:0 state TIMEOUT
   end
 end
