Exemplo n.º 1
0
    def __init__(self, base_dir):
        """
        Initialize a new storage backend instance that will work within 'base_dir'.

        :param base_dir: The base directory within which should be worked.
        """
        if not os.path.exists(base_dir):
            raise DirectoryNotFoundError("Base directory does not exist.")

        self.base_dir = base_dir
Exemplo n.º 2
0
    def get_full_dir_path(self, dir_name, **kwargs):
        """
        :inherit.
        """
        if not self.dir_exists(dir_name):
            raise DirectoryNotFoundError("Directory does not exist.")

        try:
            return self._fs.get_full_path(dir_name)
        except Exception as ex:
            raise StorageBackendError(ex)
Exemplo n.º 3
0
    def set_dir_uid(self, dir_name, uid, **kwargs):
        """
        :inherit.
        """
        if not self.dir_exists(dir_name):
            raise DirectoryNotFoundError("Directory does not exist.")

        try:
            self._fs.set_uid(uid, dir_name)
        except Exception as ex:
            raise StorageBackendError(ex)
Exemplo n.º 4
0
    def rm_dir(self, dir_name, **kwargs):
        """
        :inherit.

        :param recursive: If true, recursively remove the dir.
                          If false and the directory is not empty, an error is raised.
        """
        if not self.dir_exists(dir_name):
            raise DirectoryNotFoundError("Directory does not exist.")

        recursive = kwargs.get('recursive')
        try:
            if recursive is True:
                self._fs.rrm_dir(dir_name)
            else:
                self._fs.rm_dir(dir_name)
        except Exception as ex:
            raise StorageBackendError(ex)