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')
|
type = _('Library Closed')
|
||||||
|
|
||||||
# minimum version 2 because it requires the new db
|
# minimum version 2.54 because that is when support was added
|
||||||
minimum_calibre_version = (2, 0, 0)
|
minimum_calibre_version = (2, 54, 0)
|
||||||
|
|
||||||
def run(self, db):
|
def run(self, db):
|
||||||
'''
|
'''
|
||||||
|
@ -255,6 +255,13 @@ def available_library_closed_plugins():
|
|||||||
if not is_disabled(plugin):
|
if not is_disabled(plugin):
|
||||||
plugin.site_customization = customization.get(plugin.name, '')
|
plugin.site_customization = customization.get(plugin.name, '')
|
||||||
yield plugin
|
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 # {{{
|
# Store Plugins # {{{
|
||||||
|
@ -2017,7 +2017,7 @@ class Cache(object):
|
|||||||
for plugin in available_library_closed_plugins():
|
for plugin in available_library_closed_plugins():
|
||||||
try:
|
try:
|
||||||
plugin.run(self)
|
plugin.run(self)
|
||||||
except:
|
except Exception:
|
||||||
import traceback
|
import traceback
|
||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
self.backend.close()
|
self.backend.close()
|
||||||
|
@ -880,8 +880,8 @@ class Main(MainWindow, MainWindowMixin, DeviceMixin, EmailMixin, # {{{
|
|||||||
def shutdown(self, write_settings=True):
|
def shutdown(self, write_settings=True):
|
||||||
get_gui().show_shutdown_message(_('Shutting down'))
|
get_gui().show_shutdown_message(_('Shutting down'))
|
||||||
|
|
||||||
from calibre.customize.ui import available_library_closed_plugins
|
from calibre.customize.ui import has_library_closed_plugins
|
||||||
if available_library_closed_plugins():
|
if has_library_closed_plugins():
|
||||||
get_gui().show_shutdown_message(
|
get_gui().show_shutdown_message(
|
||||||
_('Running database shutdown plugins. This could take a few seconds...'))
|
_('Running database shutdown plugins. This could take a few seconds...'))
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user