mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Changes requested: use Exception in db.close(), change minimum version, add a method to test for existence of LibraryClosed plugins.
Note that the plugins cannot actually be tested with this commit because calibre's version is 2.53.
This commit is contained in:
parent
f705a5311c
commit
5cd9a5bf9d
@ -789,8 +789,8 @@ class LibraryClosedPlugin(Plugin): # {{{
|
||||
'''
|
||||
type = _('Library Closed')
|
||||
|
||||
# minimum version 2 because it requires the new db
|
||||
minimum_calibre_version = (2, 0, 0)
|
||||
# minimum version 2.54 because that is when support was added
|
||||
minimum_calibre_version = (2, 54, 0)
|
||||
|
||||
def run(self, db):
|
||||
'''
|
||||
|
@ -255,6 +255,13 @@ def available_library_closed_plugins():
|
||||
if not is_disabled(plugin):
|
||||
plugin.site_customization = customization.get(plugin.name, '')
|
||||
yield plugin
|
||||
|
||||
def has_library_closed_plugins():
|
||||
for plugin in _initialized_plugins:
|
||||
if isinstance(plugin, LibraryClosedPlugin):
|
||||
if not is_disabled(plugin):
|
||||
return True
|
||||
return False
|
||||
# }}}
|
||||
|
||||
# Store Plugins # {{{
|
||||
|
@ -2017,7 +2017,7 @@ class Cache(object):
|
||||
for plugin in available_library_closed_plugins():
|
||||
try:
|
||||
plugin.run(self)
|
||||
except:
|
||||
except Exception:
|
||||
import traceback
|
||||
traceback.print_exc()
|
||||
self.backend.close()
|
||||
|
@ -880,8 +880,8 @@ class Main(MainWindow, MainWindowMixin, DeviceMixin, EmailMixin, # {{{
|
||||
def shutdown(self, write_settings=True):
|
||||
get_gui().show_shutdown_message(_('Shutting down'))
|
||||
|
||||
from calibre.customize.ui import available_library_closed_plugins
|
||||
if available_library_closed_plugins():
|
||||
from calibre.customize.ui import has_library_closed_plugins
|
||||
if has_library_closed_plugins():
|
||||
get_gui().show_shutdown_message(
|
||||
_('Running database shutdown plugins. This could take a few seconds...'))
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user