Exemplo n.º 1
0
    def _mount_config_destination(self):
        """Mounts the destination specified in configuration and modifies the target value
        in configuration accordingly.
        """
        error = None
        try:
            _dest = self.get_destination()
            _eff_path = self.__mount_uri(_dest)
            if _eff_path is None:
                self._eff_path = _dest
            else:
                self._eff_path = _eff_path

            if (self._eff_path is None) or (not self._eff_path.startswith(
                    local_file_utils.PATHSEP)):
                raise exceptions.FileAccessException("Unable to mount target")
            if not local_file_utils.path_exists(self._eff_path):
                raise exceptions.FileAccessException(
                    "Unable to mount target: Path does not exist")

        except SBException as error:
            self._logger.error(
                "Error in mount callback function. Overwriting previous errors."
            )
            if self._initialize_callback is None:
                raise

        if self._initialize_callback is not None:
            self._logger.debug(
                "Calling additional callback in fuse_fam._mount_cb: %s" %
                self._initialize_callback)
            self._initialize_callback(error)

        if error is None:
            self._is_initialized = True
Exemplo n.º 2
0
 def test_dir_access(cls, path):
     _gfileobj = Gio.File.new_for_uri(path)
     try:
         _gfileobj.enumerate_children('standard::name')
     except Gio.Error as error:
         raise exceptions.FileAccessException(
             get_gio_errmsg(error, "Unable to list directory content"))
Exemplo n.º 3
0
 def close_stream(cls, file_desc):
     try:
         file_desc.close()
     except Gio.Error as error:
         if error.code == Gio.IOError.CLOSED:
             raise exceptions.FileAlreadyClosedError(
                 _("Error while closing stream: %s") % error)
         else:
             raise exceptions.FileAccessException(
                 get_gio_errmsg(error, _("Error while closing stream")))
Exemplo n.º 4
0
def _get_eff_uri_scheme(uri_scheme):
    """
    :todo: can we construct the eff. scheme manually? aparently ssh is just hardlinked to sftp.
    """
    # following does not work as expected!
    #    _gfileobj = _GIOFILE(uri)
    #    _uri_scheme = _gfileobj.get_uri_scheme()
    #    _has = _gfileobj.has_uri_scheme(_uri_scheme)
    #    if _has != True:
    #        raise ValueError("URI scheme `%s` not supported by backend" % _uri_scheme)

    if uri_scheme not in VALID_URI_SCHEMES:
        raise exceptions.FileAccessException(
            "URI scheme `%s` not supported by Simple Backup" % uri_scheme)

    _eff_scheme = URI_SCHEME_TO_EFF_URI_SCHEME[uri_scheme]

    if _eff_scheme not in VALID_EFF_URI_SCHEMES:
        raise exceptions.FileAccessException("Eff. URI scheme `%s` not supported by Simple Backup"\
                                             % _eff_scheme)

    return _eff_scheme
Exemplo n.º 5
0
    def _mount_cb(self, error):
        """Callback method that gets called when mounting is finished.
        Takes errors occurred during the mount process as parameter.
        """
        self._in_progress = False  # release lock

        if self._initialize_callback is not None:
            self._logger.debug(
                "Calling additional callback in gio_fam._mount_cb: %s" %
                self._initialize_callback)
            self._initialize_callback(error)
        else:
            if error is not None:
                raise exceptions.FileAccessException("Unable to mount: %s" %
                                                     error)

        if error is None:
            self._is_initialized = True
 def test_dir_access(cls, path):
     try:
         local_file_utils.listdir(path)
     except Exception, error:
         raise exceptions.FileAccessException(\
                 "Unable to list directory content: %s" % error)