当前位置: 首页>>代码示例>>Python>>正文


Python ipc.RC类代码示例

本文整理汇总了Python中calibre.utils.ipc.RC的典型用法代码示例。如果您正苦于以下问题:Python RC类的具体用法?Python RC怎么用?Python RC使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了RC类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: send_message

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()
开发者ID:Cykooz,项目名称:calibre,代码行数:8,代码来源:save.py

示例2: send_message

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()
开发者ID:MarioJC,项目名称:calibre,代码行数:9,代码来源:main.py

示例3: updateCalibreGUIView

def updateCalibreGUIView():
    """
    Refresh the GUI view
    """
    t = RC(print_error=False)
    t.start()
    sleep(0.5)
    while True:
        if t.done:
            t.conn.send("refreshdb:")
            t.conn.close()
            break
        sleep(0.5)
开发者ID:kbw1,项目名称:calibre-marvin-manager,代码行数:13,代码来源:common_utils.py

示例4: ensure_single_instance

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
开发者ID:Solertis,项目名称:calibre,代码行数:25,代码来源:main.py

示例5: build_pipe

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
开发者ID:artbycrunk,项目名称:calibre,代码行数:8,代码来源:main.py

示例6: build_pipe

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
开发者ID:Pipeliner,项目名称:calibre,代码行数:12,代码来源:main.py

示例7: _postimport


#.........这里部分代码省略.........
            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))
开发者ID:kfix,项目名称:calibre_plugin_djvumaker,代码行数:101,代码来源:__init__.py


注:本文中的calibre.utils.ipc.RC类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。