示例#1
0
    def start(self):
        """Starts a pyfuse3 filesystem with different options.

        Raises
        ------
        FUSEError
            If a FUSEError occurs it will close the pyfuse3 filesystem
        """

        fuse_log = _logging.create_logger("pyfuse3", self.fs.debug)
        fuse_options = set(pyfuse3.default_options)
        fuse_options.add('fsname=' + self.fs.__class__.__name__)
        if self.fs.debug:
            fuse_options.add('debug')
        pyfuse3.init(self.fs, self.fs.mount_point, fuse_options)
        try:
            trio.run(pyfuse3.main)
        except FUSEError:
            fuse_log.warning("FUSEError occured")
            pyfuse3.close(unmount=False)
        except Exception as e:
            fuse_log.error("[%s]: %s", type(e).__name__, e)
            pyfuse3.close(unmount=False)
        except BaseException as be:
            fuse_log.error(be.__name__)
            fuse_log.error(be.args)
            fuse_log.error("BaseException occured")
            pyfuse3.close(unmount=False)
        finally:
            pyfuse3.close()
示例#2
0
    def __init__(self, fs):
        """
        Parameters
        ----------
        fs : iotfs.filesystem.fs.FileSystem
            a filesystem object inheriting from FileSystem
        """

        self.log = _logging.create_logger(self.__class__.__name__)
        if not isinstance(fs, FileSystem):
            raise Exception("Parameter is no Filesystem.")
        self.fs = fs
示例#3
0
 def __init__(self, queue=None, interval=0):
     """
     Parameters
     ----------
     queue : queue.Queue
         a message queue from the file system
     interval : int, optional
         defines the time until a new processing takes place.
     """
     self.log = _logging.create_logger("Listener")
     self.queue = queue
     self.interval = interval
示例#4
0
    def __init__(self, logger=None):
        """
        Parameters
        ----------
        logger : logging.logger
            an already initialized logger instance
        """

        super().__init__()
        if logger is not None:
            self.log = logger
        else:
            self.log = _logging.create_logger("EntryDict", debug=True)
示例#5
0
    def __init__(self, mount_point, queue=None, debug=False):
        """
        Parameters
        ----------
        mount_point : str
            a mounting point for the filesystem.
        queue : queue.Queue
            message queue for listening module
        debug : bool, optional
            this defines whether the logging output should include the debug level
        """

        self.logger = _logging.create_logger("producer")
        super().__init__(mount_point, debug)
        self.queue = queue
示例#6
0
    def __init__(self, logger=None):
        """
        Parameters
        ----------
        logger : logging.logger
            an already initialized logger instance
        """

        super().__init__()
        if logger is not None:
            self.log = logger
        else:
            self.log = _logging.create_logger("Data", debug=True)
        self.entries = EntryDict(logger=self.log)
        self.nodes = dict()
        self.inode_entries_map = dict()
        self.inode_unique_count = 0
示例#7
0
    def __init__(self, mount_point, debug=False):
        """
        Parameters
        ----------
        mount_point : str
            a mounting point for the filesystem.
        debug : bool, optional
            this defines whether the logging output should include the debug level
        """
        super(_FileSystem, self).__init__()

        self.log = _logging.create_logger(self.__class__.__name__, debug)
        self.log.info("Init %s", self.__class__.__name__)

        # fuse debug log ("unique ...") starts with 2 for operations and increments each operation with 2
        self.unique = 2

        self.data = Data(logger=self.log)
        self.data.add_root_entry(mount_point)
示例#8
0
文件: main.py 项目: bigsoftcms/IoTFS
    def __init__(self, fs, listeners=[], debug=False):
        """
        Parameters
        ----------
        fs : iotfs.filesystem.fs.FileSystem
            a filesystem object inheriting from FileSystem
        adapters : list
            input adapters inheriting iotfs.input._adapter.Adapter that define the way data flows into the filesystem
        listeners : list
            listeners inheriting iotfs.input._listener.Listener that define listening processes
        debug : bool, optional
            this defines whether the logging output should include the debug level
        """

        log = _logging.create_logger(debug=debug)
        log.info("Starting application.")
        os.environ["MOUNT_POINT"] = os.path.abspath(fs.mount_point)
        if fs is None or not isinstance(fs, FileSystem):
            raise ValueError("No valid filesystem provided.")
        if len(listeners) > 0 and isinstance(fs, ProducerFileSystem):
            queue = Queue(0)
            fs.setQueue(queue)
            for listener in listeners:
                listener.setQueue(queue)
        try:
            if not os.path.isdir(fs.mount_point):
                log.warning("Creating mountpoint: %s", fs.mount_point)
                os.mkdir(fs.mount_point)
            with concurrent.futures.ThreadPoolExecutor(
                    max_workers=len(listeners) + 1) as executor:
                executor.submit(FileSystemStarter(fs).start)
                for listener in listeners:
                    executor.submit(listener.start)

        except (BaseException, Exception) as e:
            log.error(e)