Index: trunk/ippTasks/Makefile.am
===================================================================
--- trunk/ippTasks/Makefile.am	(revision 15313)
+++ trunk/ippTasks/Makefile.am	(revision 15352)
@@ -12,4 +12,5 @@
 	camera.pro \
 	warp.pro \
+	magic.pro \
 	diff.pro \
 	stack.pro \
Index: trunk/ippTasks/magic.pro
===================================================================
--- trunk/ippTasks/magic.pro	(revision 15352)
+++ trunk/ippTasks/magic.pro	(revision 15352)
@@ -0,0 +1,229 @@
+
+### Setups
+if ($?network == 0)
+  $network = 1
+end
+if ($?parallel == 0)
+  $parallel = 0
+end
+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/magic
+exec mkdir -p $LOGSUBDIR
+
+### Initialise the books containing the tasks to do
+book init magicToProcess
+book init magicToMask
+book init magicToSkyfileMask
+
+### Database lists
+$magic_DB = 0
+
+### Check status of warping tasks
+#macro warp.status
+#  book listbook warpInputExp
+#  book listbook warpPendingSkyCell
+#end
+
+### Reset warping tasks
+#macro warp.reset
+#  book init warpInputExp
+#  book init warpPendingSkyCell
+#end
+
+### Turn warping tasks on
+# macro warp.on
+#   task warp.exp.load
+#     active true
+#   end
+#   task warp.exp.run
+#     active true
+#   end
+#   task warp.skycell.load
+#     active true
+#   end
+#   task warp.skycell.run
+#     active true
+#   end
+# end
+# 
+# ### Turn warping tasks off
+# macro warp.off
+#   task warp.exp.load
+#     active false
+#   end
+#   task warp.exp.run
+#     active false
+#   end
+#   task warp.skycell.load
+#     active false
+#   end
+#   task warp.skycell.run
+#     active false
+#   end
+# end
+
+# populate magicToProcess
+task	       magic.toprocess
+  host         local
+
+  periods      -poll $loadpoll
+  periods      -exec $loadexec
+  periods      -timeout 30
+  npending     1
+
+  stdout NULL
+  stderr $LOGSUBDIR/magic.toprocess.log
+
+  task.exec
+    if ($DB:n == 0)
+      option DEFAULT
+      run = command magictool -toprocess -limit 20
+      if ($VERBOSE > 1)
+        echo command $run
+      end
+      command $run
+    else
+      # save the DB name for the exit tasks
+      option $DB:$magic_DB
+      command magictool -toprocess -limit 20 -dbname $DB:$magic_DB
+      $magic_DB ++
+      if ($magic_DB >= $DB:n) set magic_DB = 0
+    end
+  end
+
+  # success
+  task.exit    0
+    # convert 'stdout' to book format
+    ipptool2book stdout magicToProcess -key magic_id:node -uniq -setword dbname $options:0 -setword pantaskState INIT
+    if ($VERBOSE > 2)
+      book listbook magicToProcess
+    end
+
+    # delete existing entries in the appropriate pantaskStates
+    process_cleanup magicToProcess
+  end
+
+  # locked list
+  task.exit    default
+    showcommand failure
+  end
+
+  # operation times out?
+  task.exit    timeout
+    showcommand timeout
+  end
+end
+
+
+# populate magicToMask
+task	       magic.tomask
+  host         local
+
+  periods      -poll $loadpoll
+  periods      -exec $loadexec
+  periods      -timeout 30
+  npending     1
+
+  stdout NULL
+  stderr $LOGSUBDIR/magic.tomask.log
+
+  task.exec
+    if ($DB:n == 0)
+      option DEFAULT
+      run = command magictool -tomask -limit 20
+      if ($VERBOSE > 1)
+        echo command $run
+      end
+      command $run
+    else
+      # save the DB name for the exit tasks
+      option $DB:$magic_DB
+      command magictool -tomask -limit 20 -dbname $DB:$magic_DB
+      $magic_DB ++
+      if ($magic_DB >= $DB:n) set magic_DB = 0
+    end
+  end
+
+  # success
+  task.exit    0
+    # convert 'stdout' to book format
+    ipptool2book stdout magicToMask -key magic_id -uniq -setword dbname $options:0 -setword pantaskState INIT
+    if ($VERBOSE > 2)
+      book listbook magicToProcess
+    end
+
+    # delete existing entries in the appropriate pantaskStates
+    process_cleanup magicToMask
+  end
+
+  # locked list
+  task.exit    default
+    showcommand failure
+  end
+
+  # operation times out?
+  task.exit    timeout
+    showcommand timeout
+  end
+end
+
+
+# populate magicToMask
+task	       magic.toskyfilemask
+  host         local
+
+  periods      -poll $loadpoll
+  periods      -exec $loadexec
+  periods      -timeout 30
+  npending     1
+
+  stdout NULL
+  stderr $LOGSUBDIR/magic.toskyfilemask.log
+
+  task.exec
+    if ($DB:n == 0)
+      option DEFAULT
+      run = command magictool -toskyfilemask -limit 20
+      if ($VERBOSE > 1)
+        echo command $run
+      end
+      command $run
+    else
+      # save the DB name for the exit tasks
+      option $DB:$magic_DB
+      command magictool -toskyfilemask-limit 20 -dbname $DB:$magic_DB
+      $magic_DB ++
+      if ($magic_DB >= $DB:n) set magic_DB = 0
+    end
+  end
+
+  # success
+  task.exit    0
+    # convert 'stdout' to book format
+    ipptool2book stdout magicToSkyfileMask -key magic_id -uniq -setword dbname $options:0 -setword pantaskState INIT
+    if ($VERBOSE > 2)
+      book listbook magicToProcess
+    end
+
+    # delete existing entries in the appropriate pantaskStates
+    process_cleanup magicToSkyfileMask
+  end
+
+  # locked list
+  task.exit    default
+    showcommand failure
+  end
+
+  # operation times out?
+  task.exit    timeout
+    showcommand timeout
+  end
+end
