Ejemplo n.º 1
0
def jobcounter(request):
    # if request.method != 'POST':
    #     raise Http404()

    if job_lock.acquire(False):
        count = 0
        errors = 0
        try:
            if jobs.check_jobs_finished():
                jobs.clear_jobs()
            count = len(jobs.get_messages())

            errors = len(jobs.get_failed_messages())

        finally:
            job_lock.release()

        response = {'count': count}

        if errors:
            response.update({'errorcount': errors})

        return JsonResponse(response)

    else:
        return HttpResponse(status=503)
Ejemplo n.º 2
0
def jobstatus(request):
    # if request.method != 'POST':
    #     raise Http404()

    if job_lock.acquire(False):
        try:
            # set to "done" if queue is empty (enables "close" button for modal dialog on client-side)
            # set to "processing" otherwise
            status = "done" if jobs.check_jobs_finished() else "processing"
            if jobs.check_jobs_failed():
                status = "failed"

            # add your new messages here
            newmessages = jobs.get_messages()
            newmessages.extend([
                entry for entry in jobs.get_failed_messages()
                if entry['status'] == "error"
            ])

            for i in range(len(newmessages)):
                newmessages[i]['message'] = ugettext(newmessages[i]['message'])

        finally:
            job_lock.release()

        return JsonResponse({'status': status, 'message': newmessages})

    else:
        return HttpResponse(status=503)
Ejemplo n.º 3
0
def clear_jobstatus(request):
    if request.method != 'POST':
        raise Http404()

    if job_lock.acquire(False):
        try:
            if jobs.check_jobs_finished():
                jobs.clear_jobs()

        finally:
            job_lock.release()

        return JsonResponse({'status': 'ok'})

    else:
        return HttpResponse(status=503)
Ejemplo n.º 4
0
def clear_jobstatus(request):
    # if request.method != 'POST':
    #     raise Http404()

    if job_lock.acquire(False):
        try:
            if jobs.check_jobs_finished():
                jobs.clear_jobs()

        finally:
            job_lock.release()

        return JsonResponse({'status': 'ok'})

    else:
        return HttpResponse(status=503)
Ejemplo n.º 5
0
def jobstatus(request):
    if request.method != 'POST':
        raise Http404()

    if job_lock.acquire(False):
        try:
            # set to "done" if queue is empty (enables "close" button for modal dialog on client-side)
            # set to "processing" otherwise
            status = "done" if jobs.check_jobs_finished() else "processing"

             # add your new messages here
            newmessages = jobs.get_messages()


            for i in range(len(newmessages)):
                newmessages[i] = ugettext(newmessages[i])

        finally:
            job_lock.release()

        return JsonResponse({'status': status, 'message': newmessages})

    else:
        return HttpResponse(status=503)