Exemplo n.º 1
0
    def _query(self, flag, arg, parse=True):
        """Query an xrootd server."""
        status, res = self._client.query(flag, arg)

        if not status.ok:
            if status.errno == 3013:
                raise UnsupportedError(opname="calcualte checksum",
                                       details=status)
            raise FSError(details=status)
        return parse_qs(res) if parse else res
Exemplo n.º 2
0
 def _raise_status(self, path, status):
     """Raise error based on status."""
     if status.errno == 3006:
         raise DestinationExistsError(path=path, details=status)
     elif status.errno == 3005:
         raise DirectoryNotEmptyError(path=path, details=status)
     elif status.errno == 3011:
         raise ResourceInvalidError(path=path, details=status)
     else:
         raise FSError(details=status)
Exemplo n.º 3
0
 def _msg_get(self, msg):
     resp_q = Queue()
     self.msg_q.put((msg, resp_q))
     response = resp_q.get()
     if isinstance(response, protocol.Error):
         pass  # TODO: raise appropriate exception
         if response.code == protocol.Error.Codes.DOES_NOT_EXIST:
             logger.debug("ResourceNotFoundError")
             raise ResourceNotFoundError()
         else:
             logger.debug("FSError")
             raise FSError()
     else:
         return response
Exemplo n.º 4
0
def spliturl(fs_url):
    """Split XRootD URL in a host and path part."""
    if not is_valid_url(fs_url):
        raise FSError("Invalid XRootD URL: %s" % fs_url)

    scheme, netloc, path, params, query, fragment = urlparse(fs_url)

    if query:
        pattern = "{scheme}://{netloc}/?{query}"
    else:
        pattern = "{scheme}://{netloc}/"

    root_url = pattern.format(scheme=scheme, netloc=netloc, query=query)

    if path == "/":
        path = ""

    return root_url, path
Exemplo n.º 5
0
    def removedir(self, path, recursive=False, force=False):
        """Remove a directory from the filesystem.

        :param path: path of the directory to remove
        :type path: string
        :param recursive: if True, empty parent directories will be removed
        :type recursive: bool
        :param force: if True, any directory contents will be removed
        :type force: bool

        :raises `fs.errors.DirectoryNotEmptyError`: if the directory is not
            empty and force is False
        :raises `fs.errors.ParentDirectoryMissingError`: if an intermediate
            directory is missing
        :raises `fs.errors.ResourceInvalidError`: if the path is not a
            directory
        :raises `fs.errors.ResourceNotFoundError`: if the path does not exist
        """
        status, res = self.client.rmdir(self._p(path))
        if not status.ok:
            raise FSError(details=status)
        return True
Exemplo n.º 6
0
 def _get_file(self, FileHandle):
     """Get the information associated with the given file handle."""
     try:
         return self._files_by_handle[FileHandle]
     except KeyError:
         raise FSError("invalid file handle")
Exemplo n.º 7
0
 def broken_scandir(path, namespaces=None):
     if path == '/foo2':
         raise FSError("can't read dir")
     return original_scandir(path, namespaces=namespaces)