mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
catalog cmd needs LegacyDatabase interface
This commit is contained in:
parent
2e4100e8dd
commit
7f61ff7b9c
@ -12,6 +12,7 @@ from calibre.db.cli import integers_from_string
|
|||||||
readonly = True
|
readonly = True
|
||||||
version = 0 # change this if you change signature of implementation()
|
version = 0 # change this if you change signature of implementation()
|
||||||
needs_srv_ctx = True
|
needs_srv_ctx = True
|
||||||
|
no_remote = True
|
||||||
|
|
||||||
|
|
||||||
def implementation(db, notify_changes, ctx):
|
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):
|
def main(opts, args, dbctx):
|
||||||
if len(args) < 1:
|
if len(args) < 1:
|
||||||
raise SystemExit(_('You must specify a catalog output file'))
|
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:
|
if opts.ids:
|
||||||
opts.ids = list(integers_from_string(opts.ids))
|
opts.ids = list(integers_from_string(opts.ids))
|
||||||
fmt = args[0].rpartition('.')[-1]
|
fmt = args[0].rpartition('.')[-1]
|
||||||
|
@ -48,6 +48,8 @@ def send_message(msg=''):
|
|||||||
|
|
||||||
def run_cmd(cmd, opts, args, dbctx):
|
def run_cmd(cmd, opts, args, dbctx):
|
||||||
m = module_for_cmd(cmd)
|
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)
|
ret = m.main(opts, args, dbctx)
|
||||||
if not dbctx.is_remote and not opts.dont_notify_gui and not getattr(m, 'readonly', False):
|
if not dbctx.is_remote and not opts.dont_notify_gui and not getattr(m, 'readonly', False):
|
||||||
send_message()
|
send_message()
|
||||||
@ -167,7 +169,7 @@ class DBCtx(object):
|
|||||||
@property
|
@property
|
||||||
def db(self):
|
def db(self):
|
||||||
if self._db is None:
|
if self._db is None:
|
||||||
self._db = LibraryDatabase(self.library_path).new_api
|
self._db = LibraryDatabase(self.library_path)
|
||||||
return self._db
|
return self._db
|
||||||
|
|
||||||
def path(self, path):
|
def path(self, path):
|
||||||
@ -180,7 +182,7 @@ class DBCtx(object):
|
|||||||
m = module_for_cmd(name)
|
m = module_for_cmd(name)
|
||||||
if self.is_remote:
|
if self.is_remote:
|
||||||
return self.remote_run(name, m, *args)
|
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):
|
def interpret_http_error(self, err):
|
||||||
if err.code == httplib.UNAUTHORIZED:
|
if err.code == httplib.UNAUTHORIZED:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user