Index: branches/eam_branch_00/ippTasks/phase2.pro
===================================================================
--- branches/eam_branch_00/ippTasks/phase2.pro	(revision 11059)
+++ branches/eam_branch_00/ippTasks/phase2.pro	(revision 11109)
@@ -1,4 +1,4 @@
 ## this file contains the tasks for running the phase 0 stage
-## these tasks use the book Phase2Imfiles
+## these tasks use the book p2PendingImfile
 
 if ($?network == 0)
@@ -20,12 +20,12 @@
 exec mkdir -p $LOGSUBDIR
 
-book init Phase2Imfiles
+book init p2PendingImfile
 
 macro phase2.status
-  book listbook Phase2Imfiles
+  book listbook p2PendingImfile
 end
 
 # select images ready for phase2 analysis
-# new entries are added to Phase2Imfiles
+# new entries are added to p2PendingImfile
 # skip already-present entries
 task	       phase2.imfile.load
@@ -36,5 +36,5 @@
   periods      -timeout 30
 
-  stdout $LOGSUBDIR/phase2.imfile.log
+  stdout NULL
   stderr $LOGSUBDIR/phase2.imfile.log
 
@@ -46,11 +46,11 @@
   task.exit    0
     # convert 'stdout' to book format
-    ipptool2book stdout Phase2Imfiles -key exp_tag:class_id -uniq
+    ipptool2book stdout p2PendingImfile -key exp_tag:class_id -uniq
     if ($VERBOSE > 2)
-      book listbook Phase2Imfiles
+      book listbook p2PendingImfile
     end
 
     # delete existing entries which are DONE
-    book delpage Phase2Imfiles -key state DONE
+    book delpage p2PendingImfile -key state DONE
   end
 
@@ -73,17 +73,18 @@
 
   task.exec
-    book npages Phase2Imfiles -var N
+    book npages p2PendingImfile -var N
     if ($N == 0) break
     if ($network == 0) break
     
-    # look for new images in Phase2Imfiles (state == NULL)
-    book getpage Phase2Imfiles 0 -var pageName -key state NULL
+    # look for new images in p2PendingImfile (state == NULL)
+    book getpage p2PendingImfile 0 -var pageName -key state NULL
     if ($pageName == NULL) break
 
-    book setword Phase2Imfiles $pageName state RUN
-    book getword Phase2Imfiles $pageName camera -var CAMERA
-    book getword Phase2Imfiles $pageName exp_tag -var EXP_TAG
-    book getword Phase2Imfiles $pageName class_id -var CLASS_ID
-    book getword Phase2Imfiles $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 outpath -var OUTPATH
+    book getword p2PendingImfile $pageName class_id -var CLASS_ID
+    book getword p2PendingImfile $pageName uri -var URI
 
     # specify choice of remote host
@@ -95,13 +96,10 @@
     end
 
-    ## add 'p2' to the log files?
-    # XXX this is still a lame rule
-    # make 'basename' an opihi function?
-    $word = `basename $EXP_TAG | tr '.' ' '`
-    list word -split $word
-    $base = $word:0
-    stdout $LOGSUBDIR/$base/$EXP_TAG.$CLASS_ID.log
-    stderr $LOGSUBDIR/$base/$EXP_TAG.$CLASS_ID.log
-    exec mkdir -p $LOGSUBDIR/$base
+    ## generate output log based on filerule
+    $outroot = $OUTPATH/$EXP_TAG
+    $logfile = `ipp_filename.pl PHASE2.LOG $outroot $CLASS_ID`
+    stdout $logfile
+    stderr $logfile
+    exec mkdir -p $OUTPATH
 
     # save the pageName for future reference below
@@ -112,17 +110,10 @@
       echo command phase2.pl --exp_tag $EXP_TAG --class_id $CLASS_ID --uri $URI --camera $CAMERA
     end
-    command phase2.pl --exp_tag $EXP_TAG --class_id $CLASS_ID --uri $URI --camera $CAMERA
-  end
-
-  # success
-  task.exit 0
-    # phase2.pl updates DB tables, here we just update the page
-    book setword Phase2Imfiles $options:0 state DONE
+    command phase2.pl --exp_tag $EXP_TAG --class_id $CLASS_ID --uri $URI --camera $CAMERA --outpath $OUTPATH
   end
 
   # default exit status
   task.exit    default
-    showcommand failure
-    book setword Phase2Imfiles $options:0 state FAIL
+    process_exit p2PendingImfile $options:0 $JOB_STATUS
   end
 
@@ -130,5 +121,5 @@
   task.exit    timeout
     showcommand timeout
-    book setword Phase2Imfiles $options:0 state TIMEOUT
+    book setword p2PendingImfile $options:0 state TIMEOUT
   end
 end
