Example #1
0
def get_task_status(request, task_id, bk_biz_id):
    try:
        task = TaskFlowInstance.objects.get(pk=task_id, business__cc_id=bk_biz_id)
        task_status = task.get_status()
        result = {
            'result': True,
            'data': task_status
        }
        return JsonResponse(result)
    # 请求子流程的状态,直接通过pipeline api查询
    except (ValueError, TaskFlowInstance.DoesNotExist):
        logger.info('task[id=%s] does not exist' % task_id)
    except Exception as e:
        message = 'task[id=%s] get status error: %s' % (task_id, e)
        logger.error(message)
        result = {'result': False, 'message': message}
        return JsonResponse(result)
    try:
        task_status = pipeline_api.get_status_tree(task_id, max_depth=99)
        TaskFlowInstance.format_pipeline_status(task_status)
    except Exception as e:
        message = 'task[id=%s] get status error: %s' % (task_id, e)
        logger.error(message)
        result = {'result': False, 'message': message}
        return JsonResponse(result)
    result = {
        'result': True,
        'data': task_status
    }
    return JsonResponse(result)
Example #2
0
def get_task_status(request, task_id, project_id):
    project = request.project
    try:
        task = TaskFlowInstance.objects.get(pk=task_id, project_id=project.id, is_deleted=False)
        task_status = task.get_status()
        result = {
            'result': True,
            'data': task_status
        }
        return JsonResponse(result)
    # 请求子流程的状态,直接通过pipeline api查询
    except (ValueError, TaskFlowInstance.DoesNotExist):
        logger.info('task[id=%s] does not exist' % task_id)
    except Exception as e:
        message = 'task[id={task_id}] get status error: {error}'.format(task_id=task_id, error=e)
        logger.error(message)
        result = {'result': False, 'message': message}
        return JsonResponse(result)

    try:
        task_status = pipeline_api.get_status_tree(task_id, max_depth=99)
        TaskFlowInstance.format_pipeline_status(task_status)
    except Exception as e:
        message = 'task[id={task_id}] get status error: {error}'.format(task_id=task_id, error=e)
        logger.error(message)
        result = {'result': False, 'message': message}
        return JsonResponse(result)
    result = {
        'result': True,
        'data': task_status
    }
    return JsonResponse(result)
Example #3
0
def status(request, biz_cc_id):
    instance_id = request.GET.get('instance_id')
    try:
        task = TaskFlowInstance.objects.get(pk=instance_id,
                                            business__cc_id=biz_cc_id)
        task_status = task.get_status()
        ctx = {'result': True, 'data': task_status}
        return JsonResponse(ctx)
    # 请求子流程的状态,直接通过pipeline api查询
    except (ValueError, TaskFlowInstance.DoesNotExist):
        logger.info('taskflow[id=%s] does not exist' % instance_id)
    except Exception as e:
        message = 'taskflow[id=%s] get status error: %s' % (instance_id, e)
        logger.error(message)
        ctx = {'result': False, 'message': message}
        return JsonResponse(ctx)
    try:
        task_status = pipeline_api.get_status_tree(instance_id, max_depth=99)
        TaskFlowInstance.format_pipeline_status(task_status)
        ctx = {'result': True, 'data': task_status}
    # subprocess pipeline has not executed
    except exceptions.InvalidOperationException:
        ctx = {'result': True, 'data': {'state': states.CREATED}}
    except Exception as e:
        message = 'taskflow[id=%s] get status error: %s' % (instance_id, e)
        logger.error(message)
        ctx = {'result': False, 'message': message}
    return JsonResponse(ctx)
Example #4
0
File: api.py Project: manlucas/atom
def status(request, project_id):
    instance_id = request.GET.get('instance_id')
    subprocess_id = request.GET.get('subprocess_id')

    if not subprocess_id:
        try:
            task = TaskFlowInstance.objects.get(pk=instance_id,
                                                project_id=project_id)
            task_status = task.get_status()
            ctx = {'result': True, 'data': task_status}
            return JsonResponse(ctx)
        except Exception as e:
            message = 'taskflow[id=%s] get status error: %s' % (instance_id, e)
            logger.error(message)
            ctx = {'result': False, 'message': message}
            return JsonResponse(ctx)

    # 请求子流程的状态,直接通过pipeline api查询
    try:
        task_status = pipeline_api.get_status_tree(subprocess_id, max_depth=99)
        TaskFlowInstance.format_pipeline_status(task_status)
        ctx = {'result': True, 'data': task_status}
    # subprocess pipeline has not executed
    except exceptions.InvalidOperationException:
        ctx = {'result': True, 'data': {'state': states.CREATED}}
    except Exception as e:
        message = 'taskflow[id=%s] get status error: %s' % (instance_id, e)
        logger.error(message)
        ctx = {'result': False, 'message': message}
    return JsonResponse(ctx)