mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
calibredb: Add an option to not notify the GUI
This commit is contained in:
parent
321e4148e7
commit
db71dde384
@ -23,13 +23,16 @@ FIELDS = set(['title', 'authors', 'author_sort', 'publisher', 'rating',
|
||||
'formats', 'isbn', 'uuid', 'pubdate', 'cover', 'last_modified',
|
||||
'identifiers'])
|
||||
|
||||
do_notify = True
|
||||
def send_message(msg=''):
|
||||
global do_notify
|
||||
if not do_notify:
|
||||
return
|
||||
prints('Notifying calibre of the change')
|
||||
from calibre.utils.ipc import RC
|
||||
import time
|
||||
t = RC(print_error=False)
|
||||
t.start()
|
||||
time.sleep(3)
|
||||
t.join(3)
|
||||
if t.done:
|
||||
t.conn.send('refreshdb:'+msg)
|
||||
t.conn.close()
|
||||
@ -42,16 +45,22 @@ def get_parser(usage):
|
||||
parser = OptionParser(usage)
|
||||
go = parser.add_option_group(_('GLOBAL OPTIONS'))
|
||||
go.add_option('--library-path', '--with-library', default=None, help=_('Path to the calibre library. Default is to use the path stored in the settings.'))
|
||||
go.add_option('--dont-notify-gui', default=False, action='store_true',
|
||||
help=_('Do not notify the running calibre GUI (if any) that the database has'
|
||||
' changed. Use with care, as it can lead to database corruption!'))
|
||||
|
||||
return parser
|
||||
|
||||
def get_db(dbpath, options):
|
||||
global do_notify
|
||||
if options.library_path is not None:
|
||||
dbpath = options.library_path
|
||||
if dbpath is None:
|
||||
raise ValueError('No saved library path, either run the GUI or use the'
|
||||
' --with-library option')
|
||||
dbpath = os.path.abspath(dbpath)
|
||||
if options.dont_notify_gui:
|
||||
do_notify = False
|
||||
return LibraryDatabase2(dbpath)
|
||||
|
||||
def do_list(db, fields, afields, sort_by, ascending, search_text, line_width, separator,
|
||||
|
Loading…
x
Reference in New Issue
Block a user