Index: trunk/ippTasks/phase2.pro
===================================================================
--- trunk/ippTasks/phase2.pro	(revision 9506)
+++ trunk/ippTasks/phase2.pro	(revision 10746)
@@ -14,9 +14,26 @@
 end
 
+$Phase2ImfileFail = 0
+
+if ($?VERBOSE == 0)
+  echo "VERBOSE not defined: load pantasks.pro first"
+  break
+end
+if ($?LOGDIR == 0)
+  echo "LOGDIR not defined: load pantasks.pro first"
+  break
+end
+$LOGSUBDIR = $LOGDIR/phase2
+exec mkdir -p $LOGSUBDIR
+
+macro phase2.status
+  queueprint Phase2Imfiles
+  echo "Phase2ImfileFail: $Phase2ImfileFail"
+end
+
 # select images ready for phase2 analysis
 # new entries are added to queue Phase2Imfiles
 # compare the new list with the ones already selected
 task	       phase2.imfile.load
-  command      p2tool -pendingimfile -simple
   host         local
 
@@ -25,6 +42,10 @@
   periods      -timeout 30
 
-  stdout phase2.imfile.log
-  stderr phase2.imfile.log
+  stdout $LOGSUBDIR/phase2.imfile.log
+  stderr $LOGSUBDIR/phase2.imfile.log
+
+  task.exec
+    command p2tool -pendingimfile -simple -limit {$Phase2ImfileFail + 20}
+  end
 
   # success
@@ -39,4 +60,7 @@
     for i 0 $Nqueue
       queuepop stdout -var line
+      if ($VERBOSE > 2)
+        echo $line
+      end
       list word -split $line
       $EXP_TAG  = $word:0
@@ -52,10 +76,10 @@
   # locked list
   task.exit    default
-    echo "phase2 pending imfiles: failure"
+    showcommand failure
   end
 
   # operation times out?
   task.exit    timeout
-    echo "phase2 pending imfiles: timeout"
+    showcommand timeout
   end
 end
@@ -96,11 +120,17 @@
 
     ## add 'p2' to the log files?
-    $LOG_DIR = `dirname $URI`
-    stdout $WORKDIR/$LOG_DIR/$EXP_TAG.$CLASS_ID.log
-    stderr $WORKDIR/$LOG_DIR/$EXP_TAG.$CLASS_ID.log
+    # XXX this is still a lame rule
+    $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
 
     # create the command line
     options "$line"
-    echo command phase2.pl --exp_tag $EXP_TAG --class_id $CLASS_ID --uri $URI
+    if ($VERBOSE > 1)
+      echo command phase2.pl --exp_tag $EXP_TAG --class_id $CLASS_ID --uri $URI
+    end
     command phase2.pl --exp_tag $EXP_TAG --class_id $CLASS_ID --uri $URI
   end
@@ -114,12 +144,14 @@
   # default exit status
   task.exit    default
-    echo "failure for phase2imfile.pl: $options:0"
+    showcommand failure
     queuepush Phase2Imfiles -replace -key 1:2 "FAIL $options:0"
+    $Phase2ImfileFail ++
   end
 
   # operation times out?
   task.exit    timeout
-    echo "timeout for phase2imfile.pl: $options:0"
+    showcommand timeout
     queuepush Phase2Imfiles -replace -key 1:2 "TIMEOUT $options:0"
+    $Phase2ImfileFail ++
   end
 end
