• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python eventloop.add_urgent_call函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: _movies_directory_gone_handler

def _movies_directory_gone_handler(callback):
    """Default _movies_directory_gone_handler.  The frontend should
    override this using the ``install_movies_directory_gone_handler``
    function.
    """
    logging.error("Movies directory is gone -- no handler installed!")
    eventloop.add_urgent_call(callback, "continuing startup")
开发者ID:cool-RR,项目名称:Miro,代码行数:7,代码来源:startup.py


示例2: check_movies_gone

def check_movies_gone():
    """Checks to see if the movies directory is gone.
    """
    callback = lambda: eventloop.add_urgent_call(fix_movies_gone,
                                               "fix movies gone")

    if is_movies_directory_gone():
        logging.info("Movies directory is gone -- calling handler.")
        _movies_directory_gone_handler(callback)
        return

    movies_dir = fileutil.expand_filename(app.config.get(prefs.MOVIES_DIRECTORY))
    # if the directory doesn't exist, create it.
    if not os.path.exists(movies_dir):
        try:
            os.makedirs(movies_dir)
        except OSError:
            logging.info("Movies directory can't be created -- calling handler")
            # FIXME - this isn't technically correct, but it's probably
            # close enough that a user can fix the issue and Miro can
            # run happily.
            _movies_directory_gone_handler(callback)
            return

    # make sure the directory is writeable
    if not os.access(movies_dir, os.W_OK):
        _movies_directory_gone_handler(callback)
        return
    eventloop.add_urgent_call(finish_backend_startup, "reconnect downloaders")
开发者ID:cool-RR,项目名称:Miro,代码行数:29,代码来源:startup.py


示例3: first_time_handler

    def first_time_handler(callback):
        """Default handler for first-time startup

        install_first_time_handler() replaces this method with the
        frontend-specific one.
        """
        logging.error("First time -- no handler installed.")
        eventloop.add_urgent_call(callback, "continuing startup")
开发者ID:ndim,项目名称:miro,代码行数:8,代码来源:startup.py


示例4: fix_movies_gone

def fix_movies_gone(new_movies_directory):
    """Called by the movies directory gone handler to fix the issue.

    :param new_movies_directory: new path for the movies directory, or None if
    we should continue with the current directory.
    """
    eventloop.add_urgent_call(_startup_checker.fix_movies_gone,
                              "fix movies gone",
                              args=(new_movies_directory,))
开发者ID:ndim,项目名称:miro,代码行数:9,代码来源:startup.py


示例5: check_firsttime

def check_firsttime():
    """Run the first time wizard if need be.
    """
    callback = lambda: eventloop.add_urgent_call(check_movies_gone, "check movies gone")
    if is_first_time():
        logging.info("First time -- calling handler.")
        _first_time_handler(callback)
        return

    eventloop.add_urgent_call(check_movies_gone, "check movies gone")
开发者ID:cool-RR,项目名称:Miro,代码行数:10,代码来源:startup.py


示例6: run_callback

 def run_callback(self, choice):
     """Run the callback for this dialog.  Choice should be the
     button that the user clicked, or None if the user closed the
     window without makeing a selection.
     """
     self.choice = choice
     self.event.set()
     if self.callback is not None:
         eventloop.add_urgent_call(self.callback,
                                 "%s callback" % self.__class__,
                                 args=(self,))
开发者ID:nxmirrors,项目名称:miro,代码行数:11,代码来源:dialogs.py


示例7: workspaceDidWake_

 def workspaceDidWake_(self, notification):
     def restartPausedDownloaders(self=self):
         dlCount = len(self.pausedDownloaders)
         if dlCount > 0:
             logging.info("System is awake from sleep, resuming %s download(s)." % dlCount)
             try:
                 for dl in self.pausedDownloaders:
                     dl.start()
             finally:
                 self.pausedDownloaders = list()
     eventloop.add_urgent_call(lambda:restartPausedDownloaders(), "Resuming downloaders after sleep")
开发者ID:nxmirrors,项目名称:miro,代码行数:11,代码来源:application.py


示例8: decorated

 def decorated(*args, **kwargs):
     return_hack = []
     event = threading.Event()
     def runThenSet():
         try:
             return_hack.append(func(*args, **kwargs))
         finally:
             event.set()
     eventloop.add_urgent_call(runThenSet, 'run in event loop')
     event.wait()
     if return_hack:
         return return_hack[0]
开发者ID:cool-RR,项目名称:Miro,代码行数:12,代码来源:interpreter.py


示例9: fix_movies_gone

def fix_movies_gone(new_movies_directory):
    """Called by the movies directory gone handler to fix the issue.

    :param new_movies_directory: new path for the movies directory, or None if
    we should continue with the current directory.
    """
    if new_movies_directory is not None:
        app.config.set(prefs.MOVIES_DIRECTORY, new_movies_directory)
    # do another check to make sure the selected directory works.  Here we
    # skip the unmounted check, since it's not exact and the user is giving us
    # a directory.
    eventloop.add_urgent_call(check_movies_gone, "check movies gone",
                              kwargs={'check_unmounted': False})
开发者ID:nicolasembleton,项目名称:miro,代码行数:13,代码来源:startup.py


示例10: _movies_directory_gone_handler

def _movies_directory_gone_handler(message, movies_dir, allow_continue=False):
    """Default _movies_directory_gone_handler.  The frontend should
    override this using the ``install_movies_directory_gone_handler``
    function.

    _movies_directory_gone_handler should display the message to the user, and
    present them with the following options:
        - quit
        - change movies directory
        - continue with current directory (if allow_continue is True)

    After the user picks, the frontend should call either
    app.controller.shutdown() or startup.fix_movies_gone()
    """
    logging.error("Movies directory is gone -- no handler installed!")
    eventloop.add_urgent_call(callback, "continuing startup")
开发者ID:nicolasembleton,项目名称:miro,代码行数:16,代码来源:startup.py


示例11: check_movies_gone

def check_movies_gone(check_unmounted=True):
    """Checks to see if the movies directory is gone.
    """

    movies_dir = fileutil.expand_filename(app.config.get(
        prefs.MOVIES_DIRECTORY))
    movies_dir = filename_to_unicode(movies_dir)

    # if the directory doesn't exist, create it.
    if (not os.path.exists(movies_dir) and
            should_create_movies_directory(movies_dir)):
        try:
            fileutil.makedirs(movies_dir)
        except OSError:
            logging.info("Movies directory can't be created -- calling handler")
            # FIXME - this isn't technically correct, but it's probably
            # close enough that a user can fix the issue and Miro can
            # run happily.
            msg = _("Permissions error: %(appname)s couldn't "
                    "create the folder.",
                    {"appname": app.config.get(prefs.SHORT_APP_NAME)})
            _movies_directory_gone_handler(msg, movies_dir)
            return

    # make sure the directory is writeable
    if not os.access(movies_dir, os.W_OK):
        logging.info("Can't write to movies directory -- calling handler")
        msg = _("Permissions error: %(appname)s can't "
                "write to the folder.",
                {"appname": app.config.get(prefs.SHORT_APP_NAME)})
        _movies_directory_gone_handler(msg, movies_dir)
        return

    # make sure that the directory is populated if we've downloaded stuff to
    # it
    if check_unmounted and check_movies_directory_unmounted():
        logging.info("Movies directory is gone -- calling handler.")
        msg = _("The folder contains no files: "
                "is it on a drive that's disconnected?")
        _movies_directory_gone_handler(msg, movies_dir, allow_continue=True)
        return

    eventloop.add_urgent_call(finish_backend_startup, "reconnect downloaders")
开发者ID:nicolasembleton,项目名称:miro,代码行数:43,代码来源:startup.py


示例12: workspaceWillSleep_

 def workspaceWillSleep_(self, notification):
     def pauseRunningDownloaders(self=self):
         self.pausedDownloaders = list()
         for dl in downloader.RemoteDownloader.make_view():
             if dl.get_state() == 'downloading':
                 self.pausedDownloaders.append(dl)
         dlCount = len(self.pausedDownloaders)
         if dlCount > 0:
             logging.info("System is going to sleep, suspending %d download(s)." % dlCount)
             for dl in self.pausedDownloaders:
                 dl.pause()
     dc = eventloop.add_urgent_call(lambda:pauseRunningDownloaders(), "Suspending downloaders for sleep")
     # Until we can get proper delayed call completion notification, we're
     # just going to wait a few seconds here :)
     time.sleep(3)
开发者ID:nxmirrors,项目名称:miro,代码行数:15,代码来源:application.py


示例13: fix_movies_gone

def fix_movies_gone():
    app.config.set(prefs.MOVIES_DIRECTORY, platformcfg.get(prefs.MOVIES_DIRECTORY))
    eventloop.add_urgent_call(finish_backend_startup, "reconnect downloaders")
开发者ID:cool-RR,项目名称:Miro,代码行数:3,代码来源:startup.py


示例14: _first_time_handler

def _first_time_handler(callback):
    """Default _first_time_handler.  The frontend should override this
    using the ``install_first_time_handler`` function.
    """
    logging.error("First time -- no handler installed.")
    eventloop.add_urgent_call(callback, "continuing startup")
开发者ID:cool-RR,项目名称:Miro,代码行数:6,代码来源:startup.py


示例15: setup_global_feeds

    conversions.conversion_manager.startup()
    app.device_manager = devices.DeviceManager()
    app.device_tracker = devicetracker.DeviceTracker()

    searchengines.create_engines()
    setup_global_feeds()
    # call fix_database_inconsistencies() ASAP after the manual feed is set up
    fix_database_inconsistencies()
    logging.info("setup tabs...")
    setup_tabs()
    logging.info("setup theme...")
    setup_theme()
    install_message_handler()
    downloader.init_controller()

    eventloop.add_urgent_call(check_firsttime, "check first time")

def fix_database_inconsistencies():
    item.fix_non_container_parents()
    item.move_orphaned_items()
    playlist.fix_missing_item_ids()
    folder.fix_playlist_missing_item_ids()

@startup_function
def check_firsttime():
    """Run the first time wizard if need be.
    """
    callback = lambda: eventloop.add_urgent_call(check_movies_gone, "check movies gone")
    if is_first_time():
        logging.info("First time -- calling handler.")
        _first_time_handler(callback)
开发者ID:cool-RR,项目名称:Miro,代码行数:31,代码来源:startup.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python fileutil.expand_filename函数代码示例发布时间:2022-05-27
下一篇:
Python eventloop.add_timeout函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap