示例#1
0
 def _translate_gio_error(self, err, path, extra=None):
     if 'gio' in debug.debug_flags:
         mutter("GIO Error: %s %s" % (str(err), path))
     if extra is None:
         extra = str(err)
     if err.code == gio.ERROR_NOT_FOUND:
         raise errors.NoSuchFile(path, extra=extra)
     elif err.code == gio.ERROR_EXISTS:
         raise errors.FileExists(path, extra=extra)
     elif err.code == gio.ERROR_NOT_DIRECTORY:
         raise errors.NotADirectory(path, extra=extra)
     elif err.code == gio.ERROR_NOT_EMPTY:
         raise errors.DirectoryNotEmpty(path, extra=extra)
     elif err.code == gio.ERROR_BUSY:
         raise errors.ResourceBusy(path, extra=extra)
     elif err.code == gio.ERROR_PERMISSION_DENIED:
         raise errors.PermissionDenied(path, extra=extra)
     elif err.code == gio.ERROR_HOST_NOT_FOUND:
         raise errors.PathError(path, extra=extra)
     elif err.code == gio.ERROR_IS_DIRECTORY:
         raise errors.PathError(path, extra=extra)
     else:
         mutter('unable to understand error for path: %s: %s', path, err)
         raise errors.PathError(path,
                                extra="Unhandled gio error: " + str(err))
示例#2
0
    def rename(self, rel_from, rel_to):
        """See Transport.rename().

        This variation on rename converts DirectoryNotEmpty and FileExists
        errors into ResourceBusy if the target is a directory.
        """
        try:
            self._decorated.rename(rel_from, rel_to)
        except (errors.DirectoryNotEmpty, errors.FileExists), e:
            # if this is a directory rename, raise
            # resourcebusy rather than DirectoryNotEmpty
            stat = self._decorated.stat(rel_to)
            if S_ISDIR(stat.st_mode):
                raise errors.ResourceBusy(rel_to)
            else:
                raise
示例#3
0
 def delete(self, relpath):
     if urlutils.basename(relpath).startswith('.nfs'):
         raise errors.ResourceBusy(self.abspath(relpath))
     return self._decorated.delete(relpath)