Index: /trunk/ippTasks/summit.copy.pro
===================================================================
--- /trunk/ippTasks/summit.copy.pro	(revision 10415)
+++ /trunk/ippTasks/summit.copy.pro	(revision 10416)
@@ -1,3 +1,8 @@
 ## PanTasks scripts for Summit Copy
+
+$uri        = http://otis/ds/skyprobe/
+$camera     = skyprobe
+$telescope  = ps1
+$workdir    = /home/moanui/jhoblitt/workdir
 
 if ($?parallel == 0)
@@ -9,8 +14,10 @@
 # queue for summit imfiles that need to be downloaded
 queueinit pzPendingImfile
+# queue for downloaded files that need to registered with pztool -copydone
+queueinit pzCopyDone
 
 # run pzgetexp periodically to populate pzPendingExp
 task pzgetexp
-  command      pzgetexp -uri http://otis/ds/skyprobe/ -inst skyprobe -telescope ps1
+  command      pzgetexp -uri $uri -inst $camera -telescope $telescope
   host         local
 
@@ -47,13 +54,14 @@
         for i 0 $Nstdout
             queuepop stdout -var line
-            list word -split $line
-            $exp_id     = $word:0
-            $camera     = $word:1
-            $telescope  = $word:2
-            $dateobs    = $word:3
-            $exp_type   = $word:4
-            $uri        = $word:5
-            $imfiles    = $word:6
-            queuepush pzPendingExp -uniq -key 1:2:3 "NEW $uri $exp_id $camera $telescope $dateobs exp_type $uri $imfiles"
+#            list word -split $line
+#            $exp_id     = $word:0
+#            $camera     = $word:1
+#            $telescope  = $word:2
+#            $dateobs    = $word:3
+#            $exp_type   = $word:4
+#            $uri        = $word:5
+#            $imfiles    = $word:6
+#            queuepush pzPendingExp -uniq -key 1:2:3 "NEW $uri $exp_id $camera $telescope $dateobs $exp_type $uri $imfiles"
+            queuepush pzPendingExp -uniq -key 1:2:3 "NEW $line"
         end
 
@@ -71,7 +79,7 @@
 # run pzgetimfiles on pending exps
 task pzgetimfile 
-    periods      -exec     30
-    periods      -poll     10
-    periods      -timeout  30
+    periods      -exec     5
+    periods      -poll     5
+    periods      -timeout  15
 
     task.exec
@@ -99,15 +107,15 @@
 
         # specify choice of remote host:(need to choose based on chips)
-        if ($parallel)
-            host anyhost
-        else
-            host local
-        end
+#        if ($parallel)
+#            host anyhost
+#        else
+#            host local
+#        end
         
         # store the current line
         options "$line"
 
-        echo command ./pzgetimfiles -uri $uri -filesetid $exp_id -inst $camera -telescope $telescope
-        command ./pzgetimfiles -uri $uri -filesetid $exp_id -inst $camera -telescope $telescope
+        echo command pzgetimfiles -uri $uri -filesetid $exp_id -inst $camera -telescope $telescope
+        command pzgetimfiles -uri $uri -filesetid $exp_id -inst $camera -telescope $telescope
     end
 
@@ -151,5 +159,6 @@
             $class_id   = $word:6
             $uri        = $word:7
-            queuepush pzPendingImfile -uniq -key 1:2:3:6:7 "NEW $exp_id $camera $telescope $bytes $md5sum $class $class_id $uri"
+
+            queuepush pzPendingImfile -uniq -key 1:2:3:6:7 "NEW $line"
         end
 
@@ -165,2 +174,128 @@
     end
 end
+
+# get dsget to retreive an imfile and then call pztool -copydone
+task dsget
+    periods      -exec     5
+    periods      -poll     5
+    periods      -timeout  30
+
+    task.exec
+        queuesize pzPendingImfile -var N
+        if ($N == 0) break
+
+        # get a line out of the queue
+        queuepop pzPendingImfile -var line -key 0 NEW
+
+        # take the state out of the line
+        strpop line state
+
+        # put the line back into the queue with a stea of RUN
+        queuepush pzPendingImfile -replace -key 1:2:3:6:7 "RUN $line"
+
+        # the STATE has already been removed from the line
+        list word -split $line
+        $exp_id     = $word:0
+        $camera     = $word:1
+        $telescope  = $word:2
+        $bytes      = $word:3
+        $md5sum     = $word:4
+        $class      = $word:5
+        $class_id   = $word:6
+        $uri        = $word:7
+
+#        # specify choice of remote host:(need to choose based on chips)
+#        if ($parallel)
+#            host anyhost
+#        else
+#            host local
+#        end
+        
+        # store the current line without the state
+        options "$line"
+
+        echo "parsing line $line"
+        echo command dsget --uri $uri --filename $workdir/$exp_id.$class_id.fits --bytes $bytes --md5 $md5sum
+        command dsget --uri $uri --filename $workdir/$exp_id.$class_id.fits --bytes $bytes --md5 $md5sum
+    end
+
+    # success
+    task.exit 0
+        # could run copydone from here but how would the exit status be
+        # handled?
+
+        list word -split $line
+        $exp_id     = $word:0
+        $camera     = $word:1
+        $telescope  = $word:2
+        $bytes      = $word:3
+        $md5sum     = $word:4
+        $class      = $word:5
+        $class_id   = $word:6
+        $uri        = $word:7
+        queuepush pzCopyDone -key 1:2:3:6:7 "NEW $exp_id $camera $telescope $bytes $md5sum $class $class_id $workdir/$exp_id.$class_id.fits"
+        queuepush pzPendingExp -replace -key 1:2:3:6:7 "DONE $options:0"
+    end
+
+    task.exit default
+        queuepush pzPendingExp -replace -key 1:2:3:6:7 "FAIL $options:0"
+    end
+
+    task.exit timeout
+        queuepush pzPendingExp -replace -key 1:2:3:6:7 "TIMEOUT $options:0"
+    end
+end
+
+task pztool.copydone
+    periods      -exec     5
+    periods      -poll     5
+    periods      -timeout  15
+
+    host local
+
+    task.exec
+        queuesize pzCopyDone -var N
+        if ($N == 0) break
+
+        # get a line out of the queue
+        queuepop pzCopyDone -var line -key 0 NEW
+
+        # take the state out of the line
+        strpop line state
+
+        # put the line back into the queue with a stea of RUN
+        queuepush pzCopyDone -replace -key 1:2:3:6:7 "RUN $line"
+
+        # the STATE has already been removed from the line
+        list word -split $line
+        $exp_id     = $word:0
+        $camera     = $word:1
+        $telescope  = $word:2
+        $bytes      = $word:3
+        $md5sum     = $word:4
+        $class      = $word:5
+        $class_id   = $word:6
+        $uri        = $word:7
+
+        # store the current line without the state
+        options "$line"
+
+        local cmd
+        $cmd = pztool -copydone -exp_id $exp_id -inst $camera -telescope $telescope -class $class -class_id $class_id -uri $uri 
+        echo command $cmd
+        command $cmd
+    end
+
+    # success
+    task.exit 0
+        queuepush pzCopyDone -replace -key 1:2:3:6:7 "DONE $options:0"
+    end
+
+    task.exit default
+        queuepush pzCopyDone -replace -key 1:2:3:6:7 "FAIL $options:0"
+    end
+
+    task.exit timeout
+        queuepush pzCopyDone -replace -key 1:2:3:6:7 "TIMEOUT $options:0"
+    end
+end
