mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
When running calibre with the --with-library command line flag and calibre is already running, switch to the specified library in calibre. Fixes #1989631 [[Enhancement] do a library switch in calibre via the command line](https://bugs.launchpad.net/calibre/+bug/1989631)
This commit is contained in:
parent
4429815b6b
commit
315575aa56
@ -492,6 +492,9 @@ def communicate(opts, args, retry_communicate=False):
|
||||
else:
|
||||
if len(args) > 1:
|
||||
args[1:] = [os.path.abspath(x) if os.path.exists(x) else x for x in args[1:]]
|
||||
if opts.with_library and os.path.isdir(os.path.expanduser(opts.with_library)):
|
||||
library_id = os.path.basename(opts.with_library).replace(' ', '_').encode('utf-8').hex()
|
||||
args.insert(1, 'calibre://switch-library/_hex_-' + library_id)
|
||||
import json
|
||||
if not send_message(b'launched:'+as_bytes(json.dumps(args)), retry_communicate=retry_communicate):
|
||||
raise SystemExit(_('Failed to contact running instance of calibre'))
|
||||
|
Loading…
x
Reference in New Issue
Block a user