How to use the send2trash.exceptions.TrashPermissionError function in Send2Trash

To help you get started, we’ve selected a few Send2Trash examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github hsoft / send2trash / send2trash / plat_other.py View on Github external
def find_ext_volume_fallback_trash(volume_root):
    # from [2] Trash directories (1) create a .Trash-$uid dir.
    trash_dir = op.join(volume_root, TOPDIR_FALLBACK)
    # Try to make the directory, if we lack permission, raise TrashPermissionError
    try:
        check_create(trash_dir)
    except OSError as e:
        if e.errno == errno.EACCES:
            raise TrashPermissionError(e.filename)
        raise
    return trash_dir
github snuq / Snu-Photo-Manager / send2trash / plat_gio.py View on Github external
def send2trash(path):
    try:
        f = Gio.File.new_for_path(path)
        f.trash(cancellable=None)
    except GObject.GError as e:
        if e.code == Gio.IOErrorEnum.NOT_SUPPORTED:
            # We get here if we can't create a trash directory on the same
            # device. I don't know if other errors can result in NOT_SUPPORTED.
            raise TrashPermissionError('')
        raise OSError(e.message)
github hsoft / send2trash / send2trash / plat_gio.py View on Github external
def send2trash(path):
    try:
        f = Gio.File.new_for_path(path)
        f.trash(cancellable=None)
    except GObject.GError as e:
        if e.code == Gio.IOErrorEnum.NOT_SUPPORTED:
            # We get here if we can't create a trash directory on the same
            # device. I don't know if other errors can result in NOT_SUPPORTED.
            raise TrashPermissionError('')
        raise OSError(e.message)