always trigger a copy when we receive the sequencingFinshed message
[htsworkflow.git] / gaworkflow / copier.py
index 9420208e4a285e6cbf2e21e1603f899c4fd5efaa..2e0d3ae32ca947c3637cd5f67c012db4a3dd0843 100644 (file)
@@ -32,13 +32,19 @@ class rsync(object):
 
   def list(self):
     """Get a directory listing"""
-    dirs_to_copy = []
     args = copy.copy(self.cmd)
     args.append(self.source_base)
 
     logging.debug("Rsync cmd:" + " ".join(args))
     short_process = subprocess.Popen(args, stdout=subprocess.PIPE)
-    direntries = [ x.split() for x in short_process.stdout ]
+    return self.list_filter(short_process.stdout)
+
+  def list_filter(self, lines):
+    """
+    parse rsync directory listing
+    """
+    dirs_to_copy = []
+    direntries = [ x[0:42].split() + [x[43:-1]] for x in lines ]
     for permissions, size, filedate, filetime, filename in direntries:
       if permissions[0] == 'd':
         # hey its a directory, the first step to being something we want to 
@@ -178,16 +184,10 @@ class CopierBot(rpc.XmlRpcBot):
         
         # see if we're still copying
         if runfolder_validate(runDir):
-            if runDir in self.rsync.keys():
-                # still copying
-                self.pending.append(runDir)
-                logging.info("finished sequencing, but still copying" % (runDir))
-                return "PENDING"
-            else:
-                # we're done
-                self.reportSequencingFinished(runDir)
-                logging.info("finished sequencing %s" % (runDir))
-                return "DONE"
+            logging.info("recevied sequencing finshed for %s" % (runDir))
+            self.pending.append(runDir)
+            self.startCopy()
+            return "PENDING"
         else:
             errmsg = "received bad runfolder name (%s)" % (runDir)
             logging.warning(errmsg)