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:
Charles Haley 2016-03-28 17:50:04 +02:00
parent f705a5311c
commit 5cd9a5bf9d
4 changed files with 12 additions and 5 deletions

View File

@ -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):
'''

View File

@ -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 # {{{

View File

@ -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()

View File

@ -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...'))