mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Nicer error message when the user has set the default send to device action incorrectly
This commit is contained in:
parent
5f658bfc04
commit
8f076a4624
@ -104,3 +104,9 @@ class ControlError(ProtocolError):
|
|||||||
if self.desc:
|
if self.desc:
|
||||||
return self.desc
|
return self.desc
|
||||||
return "Unknown control error occurred"
|
return "Unknown control error occurred"
|
||||||
|
|
||||||
|
class WrongDestinationError(PathError):
|
||||||
|
''' The user chose the wrong destination to send books to, for example by
|
||||||
|
trying to send books to a non existant storage card.'''
|
||||||
|
pass
|
||||||
|
|
||||||
|
@ -15,7 +15,8 @@ import os, subprocess, time, re, sys, glob
|
|||||||
from itertools import repeat
|
from itertools import repeat
|
||||||
|
|
||||||
from calibre.devices.interface import DevicePlugin
|
from calibre.devices.interface import DevicePlugin
|
||||||
from calibre.devices.errors import DeviceError, FreeSpaceError
|
from calibre.devices.errors import (DeviceError, FreeSpaceError,
|
||||||
|
WrongDestinationError)
|
||||||
from calibre.devices.usbms.deviceconfig import DeviceConfig
|
from calibre.devices.usbms.deviceconfig import DeviceConfig
|
||||||
from calibre.constants import iswindows, islinux, isosx, isfreebsd, plugins
|
from calibre.constants import iswindows, islinux, isosx, isfreebsd, plugins
|
||||||
from calibre.utils.filenames import ascii_filename as sanitize, shorten_components_to
|
from calibre.utils.filenames import ascii_filename as sanitize, shorten_components_to
|
||||||
@ -976,9 +977,17 @@ class Device(DeviceConfig, DevicePlugin):
|
|||||||
|
|
||||||
def _sanity_check(self, on_card, files):
|
def _sanity_check(self, on_card, files):
|
||||||
if on_card == 'carda' and not self._card_a_prefix:
|
if on_card == 'carda' and not self._card_a_prefix:
|
||||||
raise ValueError(_('The reader has no storage card in this slot.'))
|
raise WrongDestinationError(_(
|
||||||
|
'The reader has no storage card %s. You may have changed '
|
||||||
|
'the default send to device action. Right click on the send '
|
||||||
|
'to device button and reset the default action to be '
|
||||||
|
'"Send to main memory".')%'A')
|
||||||
elif on_card == 'cardb' and not self._card_b_prefix:
|
elif on_card == 'cardb' and not self._card_b_prefix:
|
||||||
raise ValueError(_('The reader has no storage card in this slot.'))
|
raise WrongDestinationError(_(
|
||||||
|
'The reader has no storage card %s. You may have changed '
|
||||||
|
'the default send to device action. Right click on the send '
|
||||||
|
'to device button and reset the default action to be '
|
||||||
|
'"Send to main memory".')%'B')
|
||||||
elif on_card and on_card not in ('carda', 'cardb'):
|
elif on_card and on_card not in ('carda', 'cardb'):
|
||||||
raise DeviceError(_('Selected slot: %s is not supported.') % on_card)
|
raise DeviceError(_('Selected slot: %s is not supported.') % on_card)
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ from calibre.gui2 import (config, error_dialog, Dispatcher, dynamic,
|
|||||||
from calibre.ebooks.metadata import authors_to_string
|
from calibre.ebooks.metadata import authors_to_string
|
||||||
from calibre import preferred_encoding, prints, force_unicode, as_unicode
|
from calibre import preferred_encoding, prints, force_unicode, as_unicode
|
||||||
from calibre.utils.filenames import ascii_filename
|
from calibre.utils.filenames import ascii_filename
|
||||||
from calibre.devices.errors import FreeSpaceError
|
from calibre.devices.errors import FreeSpaceError, WrongDestinationError
|
||||||
from calibre.devices.apple.driver import ITUNES_ASYNC
|
from calibre.devices.apple.driver import ITUNES_ASYNC
|
||||||
from calibre.devices.folder_device.driver import FOLDER_DEVICE
|
from calibre.devices.folder_device.driver import FOLDER_DEVICE
|
||||||
from calibre.devices.bambook.driver import BAMBOOK, BAMBOOKWifi
|
from calibre.devices.bambook.driver import BAMBOOK, BAMBOOKWifi
|
||||||
@ -1450,6 +1450,9 @@ class DeviceMixin(object): # {{{
|
|||||||
'is no more free space available ')+where+
|
'is no more free space available ')+where+
|
||||||
'</p>\n<ul>%s</ul>'%(titles,))
|
'</p>\n<ul>%s</ul>'%(titles,))
|
||||||
d.exec_()
|
d.exec_()
|
||||||
|
elif isinstance(job.exception, WrongDestinationError):
|
||||||
|
error_dialog(self, _('Incorrect destination'),
|
||||||
|
unicode(job.exception), show=True)
|
||||||
else:
|
else:
|
||||||
self.device_job_exception(job)
|
self.device_job_exception(job)
|
||||||
return
|
return
|
||||||
|
Loading…
x
Reference in New Issue
Block a user