Ejemplo n.º 1
0
    def __is_sync_active(self):
        """
        returns true when the sync is active
        """
  
        # get lock path
        path = self.__get_lockfile_path();
  
        # check if path exists        
        result = self.__file_system.path_exists(path)
        if result == False:
            return result
        
        
        # read pid from file
        old_pid = None 
        pid_file = open(path, "r")
        
        for line in pid_file.readlines():
            old_pid = line

        # close pid file
        pid_file.close()
        
        if old_pid is None or old_pid == "":
            # empty file remove
            self.__file_system.remove_file(path)
            return False
        
        # check if the pid still exists
        return PidHelper.pid_exists(old_pid)
Ejemplo n.º 2
0
 def create_sync_lock_file(self):
     """
     creates the sync lock file
     """
     
     if self.__is_sync_active():
         # sync is already active
         return False
     
     # get sync lock file
     path = self.__get_lockfile_path()
     
     # get current pid
     pid = PidHelper.get_current_pid()
     
     # write new pid file
     pid_file = open(path, "w")
     pid_file.write(str(pid))
     pid_file.close()
     
     # done
     return True