本文整理汇总了Python中nailgun.task.helpers.TaskHelper.update_action_log方法的典型用法代码示例。如果您正苦于以下问题:Python TaskHelper.update_action_log方法的具体用法?Python TaskHelper.update_action_log怎么用?Python TaskHelper.update_action_log使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nailgun.task.helpers.TaskHelper
的用法示例。
在下文中一共展示了TaskHelper.update_action_log方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _update_parent_instance
# 需要导入模块: from nailgun.task.helpers import TaskHelper [as 别名]
# 或者: from nailgun.task.helpers.TaskHelper import update_action_log [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
示例2: simulate_running_deployment
# 需要导入模块: from nailgun.task.helpers import TaskHelper [as 别名]
# 或者: from nailgun.task.helpers.TaskHelper import update_action_log [as 别名]
def simulate_running_deployment(self, deploy_task, progress=42):
"""To exclude race condition errors in the tests we simulate deployment
:param deploy_task: deploy task object
:param progress: task progress value
"""
# Updating deploy task
TaskHelper.update_action_log(deploy_task)
deploy_task.status = consts.TASK_STATUSES.running
deploy_task.progress = progress
# Updating action log
action_log = objects.ActionLog.get_by_kwargs(task_uuid=deploy_task.uuid, action_name=deploy_task.name)
action_log.end_timestamp = None
self.db.commit()
示例3: _update_parent_instance
# 需要导入模块: from nailgun.task.helpers import TaskHelper [as 别名]
# 或者: from nailgun.task.helpers.TaskHelper import update_action_log [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