Add the xmi file from umbrello documenting our basic pipeline usecase
[htsworkflow.git] / gaworkflow / spoolwatcher.py
index 33a69b1db73908a90d255a3e83b87cdd9e0dd064..ba566cbfa04957e69c813302aa9e701fa0952a9d 100644 (file)
@@ -23,9 +23,9 @@ class Handler(pyinotify.ProcessEvent):
         msg = "Create: %s" %  os.path.join(event.path, event.name)
         if event.name.lower() == "run.completed":
             try:
-                self.bot.runFinished(event.path)
+                self.bot.sequencingFinished(event.path)
             except IOError, e:
-                logging.error("Couldn't send runFinished")
+                logging.error("Couldn't send sequencingFinished")
         logging.debug(msg)
 
     def process_IN_DELETE(self, event):
@@ -130,6 +130,27 @@ class SpoolWatcher(rpc.XmlRpcBot):
                 self.startCopy()
                 self.handler.last_event_time = None
     
+    def _parser(self, msg, who):
+        """
+        Parse xmpp chat messages
+        """
+        help = u"I can send [copy] message, or squencer [finished]"
+        if re.match(u"help", msg):
+            reply = help
+        elif re.match("copy", msg):            
+            self.startCopy()
+            reply = u"sent copy message"
+        elif re.match(u"finished", msg):
+            words = msg.split()
+            if len(words) == 2:
+                self.sequencingFinished(words[1])
+                reply = u"sending sequencing finished for %s" % (words[1])
+            else:
+                reply = u"need runfolder name"
+        else:
+            reply = u"I didn't understand '%s'" %(msg)            
+        return reply
+        
     def start(self, daemonize):
         """
         Start application
@@ -151,7 +172,7 @@ class SpoolWatcher(rpc.XmlRpcBot):
             for r in self.notify_runner:
                 self.rpc_send(r, tuple(), 'startCopy')
         
-    def runFinished(self, run_dir):
+    def sequencingFinished(self, run_dir):
         # need to strip off self.watch_dir from rundir I suspect.
         logging.info("run.completed in " + str(run_dir))
         pattern = self.watch_dir
@@ -164,7 +185,7 @@ class SpoolWatcher(rpc.XmlRpcBot):
                 self.send(u, 'Sequencing run %s finished' % (stripped_run_dir))
         if self.notify_runner is not None:
             for r in self.notify_runner:
-                self.rpc_send(r, (stripped_run_dir,), 'runFinished')
+                self.rpc_send(r, (stripped_run_dir,), 'sequencingFinished')
         
 def main(args=None):
     bot = SpoolWatcher()