本文整理汇总了Python中calibre.utils.ipc.RC.join方法的典型用法代码示例。如果您正苦于以下问题:Python RC.join方法的具体用法?Python RC.join怎么用?Python RC.join使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类calibre.utils.ipc.RC
的用法示例。
在下文中一共展示了RC.join方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ensure_single_instance
# 需要导入模块: from calibre.utils.ipc import RC [as 别名]
# 或者: from calibre.utils.ipc.RC import join [as 别名]
def ensure_single_instance(args, open_at):
try:
from calibre.utils.lock import singleinstance
si = singleinstance(singleinstance_name)
except Exception:
import traceback
error_dialog(None, _('Cannot start viewer'), _(
'Failed to start viewer, could not insure only a single instance of the viewer is running. Click "Show Details" for more information'),
det_msg=traceback.format_exc(), show=True)
raise SystemExit(1)
if not si:
if len(args) > 1:
t = RC(print_error=True, socket_address=viewer_socket_address())
t.start()
t.join(3.0)
if t.is_alive() or t.conn is None:
error_dialog(None, _('Connect to viewer failed'), _(
'Unable to connect to existing viewer window, try restarting the viewer.'), show=True)
raise SystemExit(1)
t.conn.send((os.path.abspath(args[1]), open_at))
t.conn.close()
prints('Opened book in existing viewer instance')
raise SystemExit(0)
listener = create_listener()
return listener
示例2: build_pipe
# 需要导入模块: from calibre.utils.ipc import RC [as 别名]
# 或者: from calibre.utils.ipc.RC import join [as 别名]
def build_pipe(print_error=True):
t = RC(print_error=print_error)
t.start()
t.join(3.0)
if t.is_alive():
cant_start()
raise SystemExit(1)
return t
示例3: send_message
# 需要导入模块: from calibre.utils.ipc import RC [as 别名]
# 或者: from calibre.utils.ipc.RC import join [as 别名]
def send_message(msg=''):
if msg:
t = RC(print_error=False)
t.start()
t.join(3)
if t.done:
t.conn.send('bookedited:'+msg)
t.conn.close()
示例4: send_message
# 需要导入模块: from calibre.utils.ipc import RC [as 别名]
# 或者: from calibre.utils.ipc.RC import join [as 别名]
def send_message(msg=''):
prints('Notifying calibre of the change')
from calibre.utils.ipc import RC
t = RC(print_error=False)
t.start()
t.join(3)
if t.done:
t.conn.send('refreshdb:' + msg)
t.conn.close()
示例5: build_pipe
# 需要导入模块: from calibre.utils.ipc import RC [as 别名]
# 或者: from calibre.utils.ipc.RC import join [as 别名]
def build_pipe(print_error=True):
t = RC(print_error=print_error)
t.start()
t.join(3.0)
if t.is_alive():
if iswindows:
cant_start()
else:
f = os.path.expanduser('~/.calibre_calibre GUI.lock')
cant_start(what=_('try deleting the file')+': '+f)
raise SystemExit(1)
return t
示例6: _postimport
# 需要导入模块: from calibre.utils.ipc import RC [as 别名]
# 或者: from calibre.utils.ipc.RC import join [as 别名]
#.........这里部分代码省略.........
fork_job = False # DEBUG UNCOMMENT
rpc_refresh = True # use the calibre RPC to signal a GUI refresh
if db is None:
from calibre.library import db # TODO: probably legacy db import, change for new_api
db = db() # initialize calibre library database
if book_format == None:
if not db.has_format(book_id, 'PDF', index_is_id=True):
raise Exception('Book with id #{} has not a PDF format.'.format(book_id))
else:
book_format='pdf'
if db.has_format(book_id, 'DJVU', index_is_id=True):
prints("already have 'DJVU' format document for book ID #{}".format(book_id))
return None # don't auto convert, we already have a DJVU for this document
path_to_ebook = db.format_abspath(book_id, book_format, index_is_id=True)
if book_format == 'pdf':
is_rasterbook_val, pages, images = is_rasterbook(path_to_ebook, basic_return=False)
if is_rasterbook_val:
pass # TODO: should add a 'scanned' or 'djvumaker' tag
else:
# this is a marked-up/vector-based pdf,
# no advantages to having another copy in DJVU format
prints(("{} document from book ID #{} determined to be a markup-based ebook,"
" not converting to DJVU").format(book_format, book_id))
return None #no-error in job panel
# TODO: test the DPI to determine if a document is from a broad-sheeted book.
# if so, queue up k2pdfopt to try and chunk the content appropriately to letter size
prints(("scheduling new {} document from book ID #{} for post-import DJVU"
" conversion: {}").format(book_format, book_id, path_to_ebook))
if fork_job:
#useful for not blocking calibre GUI when large PDFs
# are dropped into the automatic-import-folder
try:
# https://github.com/kovidgoyal/calibre/blob/master/src/calibre/utils/ipc/simple_worker.py
# dispatch API for Worker()
# src/calibre/utils/ipc/launch.py
# Worker() uses sbp.Popen to
# run a second Python to a logfile
# note that Calibre bungs the python loader to check the plugin directory when
# modules with calibre_plugin. prefixed are passed
# https://github.com/kovidgoyal/calibre/blob/master/src/calibre/customize/zipplugin.py#L192
func_name = self.plugin_prefs['use_backend']
args = [path_to_ebook, log, abort, notifications, pages, images]
jobret = worker_fork_job('calibre_plugins.{}'.format(PLUGINNAME), func_name,
args= args,
kwargs={'preferences' : self.plugin_prefs},
env={'PATH': os.environ['PATH'] + ':/usr/local/bin'},
# djvu and poppler-utils on osx
timeout=600)
# TODO: determine a resonable timeout= based on filesize or
# make a heartbeat= check
# TODO: doesn't work for pdf2djvu, why?
except WorkerError as e:
prints('djvudigital background conversion failed: \n{}'.format(force_unicode(e.orig_tb)))
raise # ConversionError
except:
prints(traceback.format_exc())
raise
# dump djvudigital output logged in file by the Worker to
# calibre proc's (gui or console) log/stdout
with open(jobret['stdout_stderr'], 'rb') as f:
raw = f.read().strip()
prints(raw)
if jobret['result']:
djvu = jobret['result']
else:
WorkerError("djvu conversion error: %s" % jobret['result'])
# elif hasattr(self, gui): #if we have the calibre gui running,
# we can give it a threadedjob and not use fork_job
else: #!fork_job & !gui
prints("Starts backend")
djvu = self.run_backend(path_to_ebook, log, abort, notifications, pages,
images)
if djvu:
db.new_api.add_format(book_id, 'DJVU', djvu, run_hooks=True)
prints("added new 'DJVU' document to book ID #{}".format(book_id))
if sys.__stdin__.isatty():
# update calibre gui Out-Of-Band. Like if we were run as a command-line scripted import
# this resets current gui views/selections, no cleaner way to do it :-(
from calibre.utils.ipc import RC
t = RC(print_error=False)
t.start()
t.join(3)
if t.done: # GUI is running
t.conn.send('refreshdb:')
t.conn.close()
prints("signalled Calibre GUI refresh")
else:
# TODO: normal Exception propagation instead of passing errors as return values
raise Exception(('ConversionError, djvu: {}. Did you install any backend according to the'
' documentation?').format(djvu))