mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Allow device drivers to show feedback to users if their open() methods fail
This commit is contained in:
parent
240b371ad5
commit
65021a0f0e
@ -36,6 +36,11 @@ class UserFeedback(DeviceError):
|
||||
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 @@ class DevicePlugin(Plugin):
|
||||
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 PyQt4.Qt import QMenu, QAction, QActionGroup, QIcon, SIGNAL, \
|
||||
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 @@ class DeviceManager(Thread): # {{{
|
||||
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…
x
Reference in New Issue
Block a user