mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
calibredb:Fix regression causing calibredb to not notify the main GUI of a change
This commit is contained in:
parent
b9806d254d
commit
09ab1df5bb
@ -20,6 +20,7 @@ from calibre.constants import __version__, __appname__, \
|
||||
from calibre.utils.filenames import ascii_filename
|
||||
from calibre.ptempfile import PersistentTemporaryFile
|
||||
from calibre.utils.config import prefs, dynamic
|
||||
from calibre.utils.ipc import ADDRESS, RC
|
||||
from calibre.utils.ipc.server import Server
|
||||
from calibre.gui2 import APP_UID, warning_dialog, choose_files, error_dialog, \
|
||||
initialize_file_icon_provider, question_dialog,\
|
||||
@ -50,9 +51,6 @@ from calibre.ebooks import BOOK_EXTENSIONS
|
||||
from calibre.library.database2 import LibraryDatabase2, CoverCache
|
||||
from calibre.gui2.dialogs.confirm_delete import confirm
|
||||
|
||||
ADDRESS = r'\\.\pipe\CalibreGUI' if iswindows else \
|
||||
os.path.expanduser('~/.calibre-gui.socket')
|
||||
|
||||
class SaveMenu(QMenu):
|
||||
|
||||
def __init__(self, parent):
|
||||
@ -1882,14 +1880,6 @@ def cant_start(msg=_('If you are sure it is not running')+', ',
|
||||
d.exec_()
|
||||
raise SystemExit(1)
|
||||
|
||||
class RC(Thread):
|
||||
|
||||
def run(self):
|
||||
from multiprocessing.connection import Client
|
||||
self.done = False
|
||||
self.conn = Client(ADDRESS)
|
||||
self.done = True
|
||||
|
||||
def communicate(args):
|
||||
t = RC()
|
||||
t.start()
|
||||
|
@ -13,11 +13,6 @@ from urllib import quote
|
||||
|
||||
from calibre import terminal_controller, preferred_encoding, prints
|
||||
from calibre.utils.config import OptionParser, prefs
|
||||
try:
|
||||
from calibre.utils.single_qt_application import send_message
|
||||
send_message
|
||||
except:
|
||||
send_message = None
|
||||
from calibre.ebooks.metadata.meta import get_metadata
|
||||
from calibre.library.database2 import LibraryDatabase2
|
||||
from calibre.ebooks.metadata.opf2 import OPFCreator, OPF
|
||||
@ -102,6 +97,19 @@ STANZA_TEMPLATE='''\
|
||||
</feed>
|
||||
'''
|
||||
|
||||
def send_message(msg=''):
|
||||
from calibre.utils.ipc import RC
|
||||
import time
|
||||
t = RC()
|
||||
t.start()
|
||||
time.sleep(3)
|
||||
if t.done:
|
||||
t.conn.send('refreshdb:'+msg)
|
||||
t.conn.close()
|
||||
|
||||
|
||||
|
||||
|
||||
def get_parser(usage):
|
||||
parser = OptionParser(usage)
|
||||
go = parser.add_option_group('GLOBAL OPTIONS')
|
||||
@ -314,8 +322,7 @@ def do_add(db, paths, one_book_per_directory, recurse, add_duplicates):
|
||||
print >>sys.stderr, '\t', title+':'
|
||||
print >>sys.stderr, '\t\t ', path
|
||||
|
||||
if send_message is not None:
|
||||
send_message('refreshdb:', 'calibre GUI')
|
||||
send_message()
|
||||
finally:
|
||||
sys.stdout = orig
|
||||
|
||||
@ -356,8 +363,7 @@ def do_remove(db, ids):
|
||||
for y in x:
|
||||
db.delete_book(y)
|
||||
|
||||
if send_message is not None:
|
||||
send_message('refreshdb:', 'calibre GUI')
|
||||
send_message()
|
||||
|
||||
def remove_option_parser():
|
||||
return get_parser(_(
|
||||
@ -484,8 +490,7 @@ def do_set_metadata(db, id, stream):
|
||||
mi = OPF(stream)
|
||||
db.set_metadata(id, mi)
|
||||
do_show_metadata(db, id, False)
|
||||
if send_message is not None:
|
||||
send_message('refreshdb:', 'calibre GUI')
|
||||
send_message()
|
||||
|
||||
def set_metadata_option_parser():
|
||||
return get_parser(_(
|
||||
|
@ -6,5 +6,20 @@ __license__ = 'GPL v3'
|
||||
__copyright__ = '2009, Kovid Goyal <kovid@kovidgoyal.net>'
|
||||
__docformat__ = 'restructuredtext en'
|
||||
|
||||
import os
|
||||
from threading import Thread
|
||||
|
||||
from calibre.constants import iswindows
|
||||
|
||||
ADDRESS = r'\\.\pipe\CalibreGUI' if iswindows else \
|
||||
os.path.expanduser('~/.calibre-gui.socket')
|
||||
|
||||
class RC(Thread):
|
||||
|
||||
def run(self):
|
||||
from multiprocessing.connection import Client
|
||||
self.done = False
|
||||
self.conn = Client(ADDRESS)
|
||||
self.done = True
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user