catalog cmd needs LegacyDatabase interface

This commit is contained in:
Kovid Goyal 2017-05-01 23:45:59 +05:30
parent 2e4100e8dd
commit 7f61ff7b9c
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 5 additions and 4 deletions

View File

@ -12,6 +12,7 @@ from calibre.db.cli import integers_from_string
readonly = True
version = 0 # change this if you change signature of implementation()
needs_srv_ctx = True
no_remote = True
def implementation(db, notify_changes, ctx):
@ -103,8 +104,6 @@ Options control how entries are displayed in the generated catalog output.
def main(opts, args, dbctx):
if len(args) < 1:
raise SystemExit(_('You must specify a catalog output file'))
if dbctx.is_remote:
raise SystemExit(_('Generating catalogs from server libraries is not supported'))
if opts.ids:
opts.ids = list(integers_from_string(opts.ids))
fmt = args[0].rpartition('.')[-1]

View File

@ -48,6 +48,8 @@ def send_message(msg=''):
def run_cmd(cmd, opts, args, dbctx):
m = module_for_cmd(cmd)
if dbctx.is_remote and getattr(m, 'no_remote', False):
raise SystemExit(_('The {} command is not supported with remote (server based) libraries').format(cmd))
ret = m.main(opts, args, dbctx)
if not dbctx.is_remote and not opts.dont_notify_gui and not getattr(m, 'readonly', False):
send_message()
@ -167,7 +169,7 @@ class DBCtx(object):
@property
def db(self):
if self._db is None:
self._db = LibraryDatabase(self.library_path).new_api
self._db = LibraryDatabase(self.library_path)
return self._db
def path(self, path):
@ -180,7 +182,7 @@ class DBCtx(object):
m = module_for_cmd(name)
if self.is_remote:
return self.remote_run(name, m, *args)
return m.implementation(self.db, None, *args)
return m.implementation(self.db.new_api, None, *args)
def interpret_http_error(self, err):
if err.code == httplib.UNAUTHORIZED: