Index: trunk/ippTasks/Makefile.am
===================================================================
--- trunk/ippTasks/Makefile.am	(revision 26329)
+++ trunk/ippTasks/Makefile.am	(revision 26378)
@@ -29,4 +29,5 @@
 	receive.pro \
 	publish.pro \
+	dqstats.pro \
 	science.cleanup.pro
 
Index: trunk/ippTasks/dqstats.pro
===================================================================
--- trunk/ippTasks/dqstats.pro	(revision 26378)
+++ trunk/ippTasks/dqstats.pro	(revision 26378)
@@ -0,0 +1,239 @@
+## dqstats.pro : globals and support macros : -*- sh -*-
+## this file contains the tasks for running the dqstats analysis stage
+## these tasks use the book dqstatsPendingExp
+
+# test for required global variables
+check.globals
+
+book init dqstatsPendingExp
+
+macro dqstats.status
+  book listbook dqstatsPendingExp
+end
+
+macro dqstats.reset
+  book init dqstatsPendingExp
+end
+
+macro dqstats.on
+  task dqstats.load
+    active true
+  end
+  task dqstats.run
+    active true
+  end
+  task dqstats.revert
+    active true
+  end
+end
+
+macro dqstats.off
+  task dqstats.load
+    active false
+  end
+  task dqstats.run
+    active false
+  end
+  task dqstats.revert
+    active false
+  end
+end
+
+# this variable will cycle through the known database names
+$dqstats_DB = 0
+$dqstats_revert_DB = 0
+
+# select images ready for dqstats analysis
+# new entries are added to dqstatsPendingExp
+# skip already-present entries
+task	       dqstats.load
+  host         local
+
+  periods      -poll $LOADPOLL
+  periods      -exec $LOADEXEC
+  periods      -timeout 30
+  npending     1
+
+  stdout NULL
+  stderr $LOGDIR/dqstats.log
+
+  task.exec
+    if ($LABEL:n == 0) break
+    $run = dqstatstool -pendingbundle
+    if ($DB:n == 0)
+      option DEFAULT
+    else
+      # save the DB name for the exit tasks
+      option $DB:$dqstats_DB
+      $run = $run -dbname $DB:$dqstats_DB
+      $dqstats_DB ++
+      if ($dqstats_DB >= $DB:n) set dqstats_DB = 0
+    end
+    add_poll_args run
+    add_poll_labels run
+    command $run
+  end
+
+  # success
+  task.exit    0
+    # convert 'stdout' to book format
+    ipptool2book stdout dqstatsPendingExp -key dqstats_id -uniq -setword dbname $options:0 -setword pantaskState INIT
+    if ($VERBOSE > 2)
+      book listbook dqstatsPendingExp
+    end
+
+    # delete existing entries in the appropriate pantaskStates
+    process_cleanup dqstatsPendingExp
+  end
+
+  # default exit status
+  task.exit    default
+    showcommand failure
+  end
+
+  task.exit    crash
+    showcommand crash
+  end
+
+  # operation times out?
+  task.exit    timeout
+    showcommand timeout
+  end
+end
+
+# run the dqstats script on pending exposures
+task	       dqstats.run
+  periods      -poll $RUNPOLL
+  periods      -exec $RUNEXEC
+  periods      -timeout 10
+
+  ## we want only a single outstanding dqstats job.  
+  host         local
+  npending     1
+
+  task.exec
+    book npages dqstatsPendingExp -var N
+    if ($N == 0) break
+    if ($NETWORK == 0) break
+    
+    # look for new images in dqstatsPendingExp (pantaskState == INIT)
+    book getpage dqstatsPendingExp 0 -var pageName -key pantaskState INIT
+    if ("$pageName" == "NULL") break
+
+    book setword dqstatsPendingExp $pageName pantaskState RUN
+    book getword dqstatsPendingExp $pageName camera -var CAMERA
+    book getword dqstatsPendingExp $pageName exp_tag -var EXP_TAG
+    book getword dqstatsPendingExp $pageName dqstats_id -var DQSTATS_ID
+#    book getword dqstatsPendingExp $pageName camroot -var CAMROOT
+#    book getword dqstatsPendingExp $pageName workdir -var WORKDIR_TEMPLATE
+#    book getword dqstatsPendingExp $pageName reduction -var REDUCTION
+#    book getword dqstatsPendingExp $pageName dvodb  -var DVODB
+#    book getword dqstatsPendingExp $pageName image_only -var IMAGE_ONLY
+    book getword dqstatsPendingExp $pageName dbname -var DBNAME
+
+    # specify choice of remote host based on camera and chip (class_id)
+    # set.host.for.camera $CAMERA FPA
+
+    # set the WORKDIR variable
+#    set.workdir.by.camera $CAMERA FPA $WORKDIR_TEMPLATE $default_host WORKDIR
+
+    # notes on how this works:
+    # -- raw workdir examples:
+    # file://data/@HOST@.0/gpc1/20080130
+    # neb:///@HOST@-vol0/gpc1/20080130 (need to supply volname?, or are we re-defining this each time?)
+    # -- out workdir examples:
+    # file://data/ipp004.0/gpc1/20080130
+    # neb:///ipp004-vol0/gpc1/20080130
+
+    ## generate outroot specific to this exposure (& chip)
+    # Uri's need to be standardized when the run is created.
+#    sprintf outroot "%s/%s/%s.dqstats.%s" $WORKDIR $EXP_TAG $EXP_TAG $DQSTATS_ID
+
+    stdout $LOGDIR/dqstats.log
+    stderr $LOGDIR/dqstats.log
+
+    $run = dqstats_bundle.pl --exp_tag $EXP_TAG --dqstats_id $DQSTATS_ID --camera GPC1 --redirect-output
+#     if ("$REDUCTION" != "NULL")
+#       $run = $run --reduction $REDUCTION
+#     end
+#     if ("$IMAGE_ONLY" == "T")
+#       $run = $run --image-only
+#     end
+
+        
+    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
+
+  # success
+  task.exit default
+    process_exit dqstatsPendingExp $options:0 $JOB_STATUS
+  end
+
+  # locked list
+  task.exit    crash
+    showcommand crash
+    echo "hostname: $JOB_HOSTNAME"
+    book setword dqstatsPendingExp $options:0 pantaskState CRASH
+  end
+
+  # operation times out?
+  task.exit    timeout
+    showcommand timeout
+    book setword dqstatsPendingExp $options:0 pantaskState TIMEOUT
+  end
+end
+
+task dqstats.revert
+  host         local
+
+  periods      -poll 5.0
+  periods      -exec 60.0
+  periods      -timeout 120.0
+  npending     1
+
+  stdout NULL
+  stderr $LOGDIR/revert.log
+
+  task.exec
+    if ($LABEL:n == 0) break
+    $run = dqstatstool -revertrun
+    if ($DB:n == 0)
+      option DEFAULT
+    else
+      # save the DB name for the exit tasks
+      option $DB:$dqstats_revert_DB
+      $run = $run -dbname $DB:$dqstats_revert_DB
+      $dqstats_revert_DB ++
+      if ($dqstats_revert_DB >= $DB:n) set dqstats_revert_DB = 0
+    end
+    add_poll_labels run
+    command $run
+  end
+
+  # success
+  task.exit    0
+  end
+
+  # locked list
+  task.exit    default
+    showcommand failure
+  end
+
+  task.exit    crash
+    showcommand crash
+  end
+
+  # operation times out?
+  task.exit    timeout
+    showcommand timeout
+  end
+end
Index: trunk/ippTasks/summit.copy.pro
===================================================================
--- trunk/ippTasks/summit.copy.pro	(revision 26329)
+++ trunk/ippTasks/summit.copy.pro	(revision 26378)
@@ -147,5 +147,5 @@
 # run pzgetexp periodically to populate pzPendingExp in the database (no I/O)
 # this task is querying the data store for a list of exposures ("filesets")
-# and inserting these into a db table on the local cluster (pzPendingExp)
+# and inserting these into a db table on the local cluster (pzDownloadExp)
 task pzgetexp
   periods      -exec     30
@@ -446,14 +446,15 @@
 	stderr $LOGDIR/summit.copy.log
 
+	book getpage pzDataStore 0 -var PZDSPAGE -key dbname $DBNAME 
+	book getword pzDataStore $PZDSPAGE use_compress  -var USECOMPRESS
+
         $run = summit_copy.pl --uri $URI --filename $FILENAME --exp_name $EXP_NAME --inst $CAMERA --telescope $TELESCOPE --class $CLASS --class_id $CLASS_ID --bytes $BYTES --md5 $MD5SUM --dbname $DBNAME --timeout 120 --verbose --copies 2
-	if ($COMPRESS) 
+	if ($USECOMPRESS == 1) 
             $run = $run --compress
-        else
-            $run = $run --bytes $BYTES 
-        end
-        if (("$MD5SUM" != "NULL") && ("$MD5SUM" != "0") && (not($COMPRESS)))
+        end
+#        if (("$MD5SUM" != "NULL") && ("$MD5SUM" != "0") && (not($COMPRESS)))
 # && (($YEAR > 2008) || (("$YEAR" = "2007") && ($MONTH > 8))))
-            $run = $run --md5 $MD5SUM
-        end
+#            $run = $run --md5 $MD5SUM
+#        end
 	if ($NEBULOUS) 
             $run = $run --nebulous
@@ -463,5 +464,5 @@
         # store the pageName for future reference below
         options $pageName
-
+	
         # create the command line
         if ($VERBOSE > 1)
