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


Python TaskHelper.calculate_parent_task_progress方法代码示例

本文整理汇总了Python中nailgun.task.helpers.TaskHelper.calculate_parent_task_progress方法的典型用法代码示例。如果您正苦于以下问题:Python TaskHelper.calculate_parent_task_progress方法的具体用法?Python TaskHelper.calculate_parent_task_progress怎么用?Python TaskHelper.calculate_parent_task_progress使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在nailgun.task.helpers.TaskHelper的用法示例。


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

示例1: _update_parent_instance

# 需要导入模块: from nailgun.task.helpers import TaskHelper [as 别名]
# 或者: from nailgun.task.helpers.TaskHelper import calculate_parent_task_progress [as 别名]
    def _update_parent_instance(cls, instance):
        subtasks = instance.subtasks
        if len(subtasks):
            data = dict()

            if all(map(lambda s: s.status == consts.TASK_STATUSES.ready,
                       subtasks)):

                data['status'] = consts.TASK_STATUSES.ready
                data['progress'] = 100
                data['message'] = u'\n'.join(map(
                    lambda s: s.message, filter(
                        lambda s: s.message is not None, subtasks)))

                cls.update(instance, data)
                TaskHelper.update_action_log(instance)

            elif any(map(lambda s: s.status == consts.TASK_STATUSES.error,
                         subtasks)):
                for subtask in subtasks:
                    if subtask.status not in (consts.TASK_STATUSES.error,
                                              consts.TASK_STATUSES.ready):
                        subtask.status = consts.TASK_STATUSES.error
                        subtask.progress = 100
                        subtask.message = "Task aborted"

                data['status'] = consts.TASK_STATUSES.error
                data['progress'] = 100
                data['message'] = u'\n'.join(list(set(map(
                    lambda s: (s.message or ""), filter(
                        lambda s: (
                            s.status == consts.TASK_STATUSES.error and not
                            # TODO(aroma): make this check less ugly
                            s.message == "Task aborted"
                        ), subtasks)))))

                cls.update(instance, data)
                TaskHelper.update_action_log(instance)

            elif instance.status == consts.TASK_STATUSES.pending and any(
                    map(lambda s: s.status in (consts.TASK_STATUSES.running,
                                               consts.TASK_STATUSES.ready),
                        subtasks)):
                instance.status = consts.TASK_STATUSES.running

            else:
                subtasks_with_progress = filter(
                    lambda s: s.progress is not None,
                    subtasks
                )
                if subtasks_with_progress:
                    instance.progress = \
                        TaskHelper.calculate_parent_task_progress(
                            subtasks_with_progress
                        )
                else:
                    instance.progress = 0
开发者ID:ekorekin,项目名称:fuel-web,代码行数:59,代码来源:task.py

示例2: _update_parent_instance

# 需要导入模块: from nailgun.task.helpers import TaskHelper [as 别名]
# 或者: from nailgun.task.helpers.TaskHelper import calculate_parent_task_progress [as 别名]
    def _update_parent_instance(cls, instance):
        subtasks = instance.subtasks
        if len(subtasks):
            data = dict()

            if all(map(lambda s: s.status == "ready", subtasks)):

                data["status"] = "ready"
                data["progress"] = 100
                data["message"] = u"\n".join(
                    map(lambda s: s.message, filter(lambda s: s.message is not None, subtasks))
                )

                cls.update(instance, data)

            elif any(map(lambda s: s.status in ("error",), subtasks)):
                for subtask in subtasks:
                    if not subtask.status in ("error", "ready"):
                        subtask.status = "error"
                        subtask.progress = 100
                        subtask.message = "Task aborted"

                data["status"] = "error"
                data["progress"] = 100
                data["message"] = u"\n".join(
                    list(
                        set(
                            map(
                                lambda s: (s.message or ""),
                                filter(
                                    lambda s: (
                                        s.status == "error"
                                        and not
                                        # TODO: make this check less ugly
                                        s.message == "Task aborted"
                                    ),
                                    subtasks,
                                ),
                            )
                        )
                    )
                )

                cls.update(instance, data)
            else:
                subtasks_with_progress = filter(lambda s: s.progress is not None, subtasks)
                if subtasks_with_progress:
                    instance.progress = TaskHelper.calculate_parent_task_progress(subtasks_with_progress)
                else:
                    instance.progress = 0
开发者ID:koder-ua,项目名称:nailgun-fcert,代码行数:52,代码来源:task.py

示例3: _update_parent_instance

# 需要导入模块: from nailgun.task.helpers import TaskHelper [as 别名]
# 或者: from nailgun.task.helpers.TaskHelper import calculate_parent_task_progress [as 别名]
    def _update_parent_instance(cls, instance):
        subtasks = instance.subtasks
        if len(subtasks):
            data = dict()

            if all(map(lambda s: s.status == 'ready', subtasks)):

                data['status'] = 'ready'
                data['progress'] = 100
                data['message'] = u'\n'.join(map(
                    lambda s: s.message, filter(
                        lambda s: s.message is not None, subtasks)))

                cls.update(instance, data)
                TaskHelper.update_action_log(instance)

            elif any(map(lambda s: s.status in ('error',), subtasks)):
                for subtask in subtasks:
                    if not subtask.status in ('error', 'ready'):
                        subtask.status = 'error'
                        subtask.progress = 100
                        subtask.message = 'Task aborted'

                data['status'] = 'error'
                data['progress'] = 100
                data['message'] = u'\n'.join(list(set(map(
                    lambda s: (s.message or ""), filter(
                        lambda s: (
                            s.status == 'error' and not
                            # TODO: make this check less ugly
                            s.message == 'Task aborted'
                        ), subtasks)))))

                cls.update(instance, data)
                TaskHelper.update_action_log(instance)

            else:
                subtasks_with_progress = filter(
                    lambda s: s.progress is not None,
                    subtasks
                )
                if subtasks_with_progress:
                    instance.progress = \
                        TaskHelper.calculate_parent_task_progress(
                            subtasks_with_progress
                        )
                else:
                    instance.progress = 0
开发者ID:SmartInfrastructures,项目名称:fuel-web-dev,代码行数:50,代码来源:task.py


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