mirror of
git://github.com/kovidgoyal/calibre.git
synced 2026-05-05 17:33:39 +02:00
Allow device drivers to show feedback to users if their open() methods fail
This commit is contained in:
parent
240b371ad5
commit
65021a0f0e
3 changed files with 12 additions and 1 deletions
|
|
@ -36,6 +36,11 @@ def __init__(self, msg, details, level):
|
|||
self.details = details
|
||||
self.msg = msg
|
||||
|
||||
class OpenFeedback(DeviceError):
|
||||
def __init__(self, msg):
|
||||
self.feedback_msg = msg
|
||||
DeviceError.__init__(self, msg)
|
||||
|
||||
class DeviceBusy(ProtocolError):
|
||||
""" Raised when device is busy """
|
||||
def __init__(self, uerr=""):
|
||||
|
|
|
|||
|
|
@ -216,6 +216,9 @@ def open(self):
|
|||
an implementation of
|
||||
this function that should serve as a good example for USB Mass storage
|
||||
devices.
|
||||
|
||||
This method can raise an OpenFeedback exception to display a message to
|
||||
the user.
|
||||
'''
|
||||
raise NotImplementedError()
|
||||
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@
|
|||
from calibre.customize.ui import available_input_formats, available_output_formats, \
|
||||
device_plugins
|
||||
from calibre.devices.interface import DevicePlugin
|
||||
from calibre.devices.errors import UserFeedback
|
||||
from calibre.devices.errors import UserFeedback, OpenFeedback
|
||||
from calibre.gui2.dialogs.choose_format import ChooseFormatDialog
|
||||
from calibre.utils.ipc.job import BaseJob
|
||||
from calibre.devices.scanner import DeviceScanner
|
||||
|
|
@ -163,6 +163,9 @@ def do_connect(self, connected_devices, device_kind):
|
|||
dev.reset(detected_device=detected_device,
|
||||
report_progress=self.report_progress)
|
||||
dev.open()
|
||||
except OpenFeedback, e:
|
||||
self.open_feedback_slot(e.feedback_msg)
|
||||
continue
|
||||
except:
|
||||
tb = traceback.format_exc()
|
||||
if DEBUG or tb not in self.reported_errors:
|
||||
|
|
|
|||
Loading…
Reference in a new issue