Beispiel #1
0
 def quarantine(file_name, data_dir, quarantine_dir):
     """
     Move specified file into the quarantine directory,
     If necessary timestamp the filename to prevent overwriting.
     """
     futils.ensureDirExists(quarantine_dir)
     file_path = TransferUtils.getPathInDir(file_name, data_dir)
     q_file_path = TransferUtils.getPathInDir(file_name, quarantine_dir)
     if os.path.exists(file_path):
         while os.path.exists(q_file_path):
             q_file_path += "." + TransferUtils.timeStamp()
             os.rename(file_path, q_file_path)
Beispiel #2
0
    def getStopFilePath(self, dconfig):
        """
        Get the stop file path for a given data_stream.
        This will be in either the incoming directory (if there is an
        arrival monitor) or the data_stream directory (if there is not).
        """
        iconfig = dconfig["incoming"]
        if iconfig["require_arrival_monitor"]:
            stop_file_dir = iconfig["directory"]
        else:
            stop_file_dir = dconfig["data_stream"]["directory"]

        # could conceivably need to create this, if for a new dataset 
        # this gets there before the TransferUnitController does
        futils.ensureDirExists(stop_file_dir)

        stop_file_path = os.path.join(stop_file_dir, 
                                      self.stop_file_name)
        return stop_file_path
    def monitor(self):
        """
        Ongoing monitoring of process unless told to stop.
        """
        
        futils.ensureDirExists(self.dataset_dir)
        futils.ensureDirExists(self.incoming_dir)

        while True:

            self.updateStatusAndConfig()
            if self.status == status.STOPPED:
                return self.status
            
            items = self.listIncomingDir(include_dotfiles = True)

            for item in items:
                if self.isControlFile(item):
                    self.respondToControlFile(item)
                elif self.isThankyouFile(item):
                    self.respondToThankyouFile(item)

            time.sleep(self.poll_interval)
 def doSetup(self):
     futils.ensureDirExists(self.dataset_dir)
     self.tidyDatasetDir()