Ejemplo n.º 1
0
 def readlink(self, path):
     print('*** readlink', path)
     file_hash, action, rest = parse_path(path)
     file_descr = get_file_descr(file_hash)
     
     file_ids = get_referenced_file_ids(file_descr)      
     tree = file_ids_as_tree(file_ids, os.path.dirname(file_descr.file.filename))
     
     path_to = find_path_for_file_id(tree, file_descr.file)
     
     return path_to
Ejemplo n.º 2
0
    def readlink(self, path):
        LOG.debug("*** readlink: %s", path)
        file_hash, action, rest = parse_path(path)
        file_descr = get_file_descr(file_hash)

        file_ids = get_referenced_file_ids(file_descr)
        tree = file_ids_as_tree(file_ids,
                                os.path.dirname(file_descr.file.filename))

        path_to = find_path_for_file_id(tree, file_descr.file)

        return path_to
Ejemplo n.º 3
0
    def getattr(self, path):
        file_hash, action, rest = parse_path(path)
        if file_hash is None:
            return MyStat(True, 0)
        else:
            if action is None:
                return MyStat(True, 0)
            elif action == 'mount':
                return self.getattr_mount(path, file_hash, action, rest)
            elif action == 'assets':
                return MyStat(True, 0)
                #return self.getattr_assets(path, file_hash, action, rest)

        LOG.debug('oops:\n\t%s\n\t%s\n\t%s' % (path, file_hash, action))
Ejemplo n.º 4
0
 def getattr(self, path):
     #print '*** getattr', path
     file_hash, action, rest = parse_path(path)
     if file_hash is None:
         return MyStat(True, 0)
     else:
         if action is None:
             return MyStat(True, 0)
         elif action == 'mount':
             return self.getattr_mount(path, file_hash, action, rest)
         elif action == 'assets':
             return MyStat(True, 0)
             #return self.getattr_assets(path, file_hash, action, rest)
             
     print('oops', path, file_hash, action)
Ejemplo n.º 5
0
        def __init__(self, path, flags, *mode):
            file_hash, action, rest = parse_path(path)
        
            file_descr = get_file_descr(file_hash)

            if not rest:
                rest = ''
                
            file_ids = get_referenced_file_ids(file_descr)     
            tree = file_ids_as_tree(file_ids, os.path.dirname(file_descr.file.filename))
            files = get_files_for_path(tree, rest)
            if not isinstance(files, dict):
                abs_path = abspath(files[1].filename, file_descr)
                
                self.file = os.fdopen(os.open(abs_path, flags, *mode), flag2mode(flags))
                self.fd = self.file.fileno()       
Ejemplo n.º 6
0
    def readdir(self, path, offset):
        file_hash, action, rest = parse_path(path)

        if file_hash is None:
            path = os.path.join('/tmp/damn', '')
            for e in os.listdir(path):
                yield fuse.Direntry(e)
        else:
            if action is None:
                for action in ['mount', 'assets']:
                    yield fuse.Direntry(action)
            elif action == 'mount':

                for entry in self.readdir_mount(path, offset, file_hash, action, rest):
                    yield entry
            elif action == 'assets':
                for entry in self.readdir_assets(path, offset, file_hash, action, rest):
                    yield entry
Ejemplo n.º 7
0
        def __init__(self, path, flags, *mode):
            file_hash, action, rest = parse_path(path)

            file_descr = get_file_descr(file_hash)

            if not rest:
                rest = ''

            file_ids = get_referenced_file_ids(file_descr)
            tree = file_ids_as_tree(file_ids,
                                    os.path.dirname(file_descr.file.filename))
            files = get_files_for_path(tree, rest)
            if not isinstance(files, dict):
                abs_path = abspath(files[1].filename, file_descr)

                self.file = os.fdopen(os.open(abs_path, flags, *mode),
                                      flag2mode(flags))
                self.fd = self.file.fileno()
Ejemplo n.º 8
0
    def test_parse_path(self):
        """Test parse_path"""
        assert (None, None, None) == parse_path('/')

        assert ('file_hash', 'action', 'path') == parse_path('/file_hash/action/path')

        assert ('file_hash', 'action', None) == parse_path('/file_hash/action/')

        assert ('file_hash', 'action', None) == parse_path('/file_hash/action')

        assert ('file_hash', None, None) == parse_path('/file_hash/')

        assert ('file_hash', None, None) == parse_path('/file_hash')
Ejemplo n.º 9
0
    def test_parse_path(self):
        """Test parse_path"""
        assert (None, None, None) == parse_path("/")

        assert ("file_hash", "action", "path") == parse_path("/file_hash/action/path")

        assert ("file_hash", "action", None) == parse_path("/file_hash/action/")

        assert ("file_hash", "action", None) == parse_path("/file_hash/action")

        assert ("file_hash", None, None) == parse_path("/file_hash/")

        assert ("file_hash", None, None) == parse_path("/file_hash")