Example #1
0
def test_status(request, taskid):
    "Gets the task status"
    status = default_backend.get_status(taskid)
    results = default_backend.get_result(taskid)
    if status in ['SUCCESS', 'FAILURE']:
        if status == 'SUCCESS':
            if results['smtp']:
                msg = _('The server is contactable and accepting messages')
            else:
                if results['ping']:
                    msg = (
                        _('The server is contactable via ICMP but'
                          ' is not accepting messages from me, Errors: %s') %
                        results['errors']['smtp'])
                else:
                    msg = (
                        _('The server is not accepting messages, Errors: %s') %
                        str(results['errors']))
        else:
            msg = _('The tests failed to run try again later')
        if request.is_ajax():
            response = anyjson.dumps(dict(html=msg, completed=True))
            return HttpResponse(
                response, content_type='application/javascript; charset=utf-8')
        djmessages.info(request, msg)
        return HttpResponseRedirect(
            reverse('view-domain', args=[results['host']]))
    else:
        if request.is_ajax():
            response = anyjson.dumps(dict(html='', completed=False))
            return HttpResponse(
                response, content_type='application/javascript; charset=utf-8')
    return render_to_response('mail/config/task_status.html',
                              {'status': status},
                              context_instance=RequestContext(request))
Example #2
0
def test_status(request, taskid):
    "Gets the task status"
    status = default_backend.get_status(taskid)
    results = default_backend.get_result(taskid)
    if status in ['SUCCESS', 'FAILURE']:
        if status == 'SUCCESS':
            if results['smtp']:
                msg = _('The server is contactable and accepting messages')
            else:
                if results['ping']:
                    msg = (_('The server is contactable via ICMP but'
                    ' is not accepting messages from me, Errors: %s') %
                    results['errors']['smtp'])
                else:
                    msg = (_('The server is not accepting messages, Errors: %s')
                    % str(results['errors']))
        else:
            msg = _('The tests failed to run try again later')
        if request.is_ajax():
            response = anyjson.dumps(dict(html=msg, completed=True))
            return HttpResponse(response,
                content_type='application/javascript; charset=utf-8')
        djmessages.info(request, msg)
        return HttpResponseRedirect(reverse('view-domain',
            args=[results['host']]))
    else:
        if request.is_ajax():
            response = anyjson.dumps(dict(html='', completed=False))
            return HttpResponse(response,
                content_type='application/javascript; charset=utf-8')
    return render_to_response('config/task_status.html', {'status': status},
    context_instance=RequestContext(request))
Example #3
0
def test_status(request, taskid):
    "Gets the task status"
    status = default_backend.get_status(taskid)
    results = default_backend.get_result(taskid)
    if status in ["SUCCESS", "FAILURE"]:
        if status == "SUCCESS":
            if results["smtp"]:
                msg = _("The server is contactable and accepting messages")
            else:
                if results["ping"]:
                    msg = (
                        _("The server is contactable via ICMP but" " is not accepting messages from me, Errors: %s")
                        % results["errors"]["smtp"]
                    )
                else:
                    msg = _("The server is not accepting messages, Errors: %s") % str(results["errors"])
        else:
            msg = _("The tests failed to run try again later")
        if request.is_ajax():
            response = anyjson.dumps(dict(html=msg, completed=True))
            return HttpResponse(response, content_type="application/javascript; charset=utf-8")
        djmessages.info(request, msg)
        return HttpResponseRedirect(reverse("view-domain", args=[results["host"]]))
    else:
        if request.is_ajax():
            response = anyjson.dumps(dict(html="", completed=False))
            return HttpResponse(response, content_type="application/javascript; charset=utf-8")
    return render_to_response("config/task_status.html", {"status": status}, context_instance=RequestContext(request))
Example #4
0
def test_status(request, taskid):
    "Gets the task status"
    status = default_backend.get_status(taskid)
    results = default_backend.get_result(taskid)
    if status in ['SUCCESS', 'FAILURE']:
        if status == 'SUCCESS':
            if results['smtp']:
                msg = _('The server is contactable and accepting messages')
            else:
                if results['ping']:
                    msg = (
                        _('The server is contactable via ICMP but'
                          ' is not accepting messages from me, Errors: %s') %
                        results['errors']['smtp'])
                else:
                    msg = (
                        _('The server is not accepting messages, Errors: %s') %
                        str(results['errors']))
        else:
            msg = _('The tests failed to run try again later')
        djmessages.info(request, msg)
        return HttpResponseRedirect(
            reverse('view-domain', args=[results['host']]))
    return render_to_response('config/task_status.html', {'status': status},
                              context_instance=RequestContext(request))
Example #5
0
def suspend_task_get(request, task_id):
    '''Returns status and result formattet in JSON.'''
    status = default_backend.get_status(task_id)
    res = default_backend.get_result(task_id)
    response_data = dict(task_id=task_id, status=status, result=res)
    if status in default_backend.EXCEPTION_STATES:
        traceback = default_backend.get_traceback(task_id)
        response_data.update({
            'traceback': traceback,
            'result': str(res.args[0])
        })
    return HttpResponse(JSON_dump(response_data), mimetype="application/json")
Example #6
0
def task_status(request, task_id):
    """Returns task status and result in JSON format."""
    status = default_backend.get_status(task_id)
    res = default_backend.get_result(task_id)
    response_data = dict(id=task_id, status=status, result=res)
    if status in default_backend.EXCEPTION_STATES:
        traceback = default_backend.get_traceback(task_id)
        response_data.update(
            {"result": str(res.args[0]), "exc": get_full_cls_name(res.__class__), "traceback": traceback}
        )

    return HttpResponse(JSON_dump({"task": response_data}), mimetype="application/json")
Example #7
0
def task_status(request, task_id):
    response = json_response(status=200, text='ok')
    status = default_backend.get_status(task_id)
    res = default_backend.get_result(task_id)
    response['data'] = {
        'id':     task_id,
        'status': status,
        'result': res
    }
    if status in default_backend.EXCEPTION_STATES:
        traceback = default_backend.get_traceback(task_id)
        response['data'].update({'result':    str(res.args[0]),
                                 'exc':       get_full_cls_name(res.__class__),
                                 'traceback': traceback})
    return response
def task_status(request, task_id):
    """Returns task status and result in JSON format."""
    status = default_backend.get_status(task_id)
    res = default_backend.get_result(task_id)
    response_data = dict(id=task_id, status=status, result=res)
    if status in default_backend.EXCEPTION_STATES:
        traceback = default_backend.get_traceback(task_id)
        response_data.update({
            "result": repr(res),
            "exc": get_full_cls_name(res.__class__),
            "traceback": traceback
        })

    return HttpResponse(JSON_dump({"task": response_data}),
                        mimetype="application/json")
Example #9
0
def test_status(request, taskid):
    "Gets the task status"
    status = default_backend.get_status(taskid)
    results = default_backend.get_result(taskid)
    if status in ['SUCCESS', 'FAILURE']:
        if status == 'SUCCESS':
            if results['smtp']:
                msg = _('The server is contactable and accepting messages')
            else:
                if results['ping']:
                    msg = (_('The server is contactable via ICMP but'
                    ' is not accepting messages from me, Errors: %s') %
                    results['errors']['smtp'])
                else:
                    msg = (_('The server is not accepting messages, Errors: %s') 
                    % str(results['errors']))
        else:
            msg = _('The tests failed to run try again later')
        djmessages.info(request, msg)
        return HttpResponseRedirect(reverse('view-domain', 
            args=[results['host']]))
    return render_to_response('config/task_status.html', {'status': status},
    context_instance=RequestContext(request))
Example #10
0
def suspend_task_get_block(request, task_id):
    '''A function which invokes a blocking status update for a given task.'''
    res = default_backend.wait_for(task_id)
    status = default_backend.get_status(task_id)
    data = dict(task_id=task_id, status=status)
    return HttpResponse(JSON_dump(data), mimetype="application/json")