workflow.py 文件源码

python
阅读 21 收藏 0 点赞 0 评论 0

项目:Gank-Alfred-Workflow 作者: hujiaweibujidao 项目源码 文件源码
def check_update(self, force=False):
        """Call update script if it's time to check for a new release

        .. versionadded:: 1.9

        The update script will be run in the background, so it won't
        interfere in the execution of your workflow.

        See :ref:`manual-updates` in the :ref:`user-manual` for detailed
        information on how to enable your workflow to update itself.

        :param force: Force update check
        :type force: ``Boolean``

        """

        frequency = self._update_settings.get('frequency',
                                              DEFAULT_UPDATE_FREQUENCY)

        if not force and not self.settings.get('__workflow_autoupdate', True):
            self.logger.debug('Auto update turned off by user')
            return

        # Check for new version if it's time
        if (force or not self.cached_data_fresh(
                '__workflow_update_status', frequency * 86400)):

            github_slug = self._update_settings['github_slug']
            # version = self._update_settings['version']
            version = str(self.version)

            from background import run_in_background

            # update.py is adjacent to this file
            update_script = os.path.join(os.path.dirname(__file__),
                                         b'update.py')

            cmd = ['/usr/bin/python', update_script, 'check', github_slug,
                   version]

            if self.prereleases:
                cmd.append('--prereleases')

            self.logger.info('Checking for update ...')

            run_in_background('__workflow_update_check', cmd)

        else:
            self.logger.debug('Update check not due')
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号