Index: /branches/eam_branch_00/ippTasks/phase2.pro
===================================================================
--- /branches/eam_branch_00/ippTasks/phase2.pro	(revision 11007)
+++ /branches/eam_branch_00/ippTasks/phase2.pro	(revision 11008)
@@ -30,5 +30,5 @@
 
 macro phase2.status
-  queueprint Phase2Imfiles
+  book listbook p2pending
   echo "Phase2ImfileFail: $Phase2ImfileFail"
 end
@@ -49,11 +49,14 @@
   task.exec
     # command p2tool -pendingimfile -simple -limit {$Phase2ImfileFail + 20}
-    command p2tool -pendingimfile
+    # XXX make sure we remove FAIL and TIMEOUT entries
+    command p2tool -pendingimfile -limit 20
   end
 
   # success
   task.exit    0
-    # convert output to book format
+    # 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
     if ($VERBOSE > 2)
@@ -83,5 +86,4 @@
 
   task.exec
-    # XXX make equiv book command:
     book npages p2pending -var N
     if ($N == 0) break
@@ -91,8 +93,8 @@
     # caution with these 'if' statements: syntax errors 
     # will make the task fail without given a good status
-    # XXX pop off the bottom or the top?
-    book getpage p2pending 0 -var pageName
-    book setword p2pending $pageName status RUN
+    book getpage p2pending 0 -var pageName -key state NULL
+    book setword p2pending $pageName state RUN
 
+    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
@@ -121,8 +123,7 @@
     # create the command line
     if ($VERBOSE > 1)
-      echo command phase2.pl --exp_tag $EXP_TAG --class_id $CLASS_ID --uri $URI
+      echo command phase2.pl --exp_tag $EXP_TAG --class_id $CLASS_ID --uri $URI --camera $CAMERA
     end
-    ## XXX this is annoying: phase2.pl now requires camera :: it should not need this, it has the file.
-    command phase2.pl --exp_tag $EXP_TAG --class_id $CLASS_ID --uri $URI --camera CTIO_MOSAIC2
+    command phase2.pl --exp_tag $EXP_TAG --class_id $CLASS_ID --uri $URI --camera $CAMERA
   end
 
@@ -130,5 +131,5 @@
   task.exit 0
     # phase2imfile.pl updates DB tables, here we just update the queue
-    book setword p2pending $options:0 status DONE
+    book setword p2pending $options:0 state DONE
     # queuepush Phase2Imfiles -replace -key 1:2 "DONE $options:0"
   end
@@ -137,6 +138,7 @@
   task.exit    default
     showcommand failure
-    book setword p2pending $options:0 status FAIL
+    book setword p2pending $options:0 state FAIL
     # queuepush Phase2Imfiles -replace -key 1:2 "FAIL $options:0"
+    # drop failed entries from the book lists?
     $Phase2ImfileFail ++
   end
@@ -145,5 +147,5 @@
   task.exit    timeout
     showcommand timeout
-    book setword p2pending $options:0 status TIMEOUT
+    book setword p2pending $options:0 state TIMEOUT
     # queuepush Phase2Imfiles -replace -key 1:2 "TIMEOUT $options:0"
     $Phase2ImfileFail ++
