Ejemplo n.º 1
0
    def __init__(self, db_file, drive, db_dirPath=None):
        BaseFS.__init__(self, db_file, db_dirPath)
        base.FS.__init__(self)

        for receiver, response in send("FS.__init__", self,
                                       db_file=db_file, drive_file=drive):
            recv_name = receiver.im_self.__class__.__name__
            if recv_name == 'DirPlugin':
                self.dir_class = response
            elif recv_name == 'FilePlugin':
                self.file_class = response

        self._delegate_methods(self.dir_class, self._dir_class_map)
        self._delegate_methods(self.file_class, self._file_class_map)
Ejemplo n.º 2
0
    def __init__(self, db_file, drive, db_dirPath=None, *args, **kw):
        fuse.Fuse.__init__(self, *args, **kw)

        # This thing that is like a ugly hack it seems that is the correct way
        # to pass parameters to the FUSE core as it's explained at
        # https://techknowhow.library.emory.edu/blogs/rsutton/2009/01/16/python-fuse-command-line-arguments
        # and at the Xmp.py example code. You have to set the default values
        # to object attributes that will be overwritten later by the parser.
        # Really too little pythonic...
        self.db_file = db_file
        self.db_dirPath = db_dirPath

        self.drive = drive

        self.parser.add_option(mountopt="db_file", metavar="DB_FILE",
                               default=self.db_file,
                               help="filesystem metadata database")
        self.parser.add_option(mountopt="db_dirPath", metavar="DB_DIRPATH",
                               default=self.db_dirPath,
                               help="filesystem database SQL queries directory")
        self.parser.add_option(mountopt="drive", metavar="DRIVE",
                               default=self.drive,
                               help="filesystem drive")

        self.parse(values=self, errex=1)

#        self.db = DB.DB(self.db)

        # http://sourceforge.net/apps/mediawiki/fuse/index.php?title=FUSE_Python_Reference#File_Class_Methods
        # http://old.nabble.com/Python:-Pass-parameters-to-file_class-td18301066.html

        class wrapped_dir_class(Dir):
            def __init__(self2, *a, **kw):
                Dir.Dir.__init__(self2, self, *a, **kw)

        class wrapped_file_class(File):
            def __init__(self2, *a, **kw):
                File.File.__init__(self2, self, *a, **kw)

        self.dir_class = wrapped_dir_class
        self.file_class = wrapped_file_class

        BaseFS.__init__(self, self.db_file, self.db_dirPath, self.drive)