Beispiel #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))
Beispiel #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))
Beispiel #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))
Beispiel #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))
Beispiel #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")
Beispiel #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")
    def assertStatusForIs(self, status, res, traceback=None):
        uuid = gen_unique_id()
        default_backend.store_result(uuid, res, status, traceback=traceback)
        json = self.client.get(task_status(task_id=uuid))
        expect = dict(id=uuid, status=status, result=res)
        if status in default_backend.EXCEPTION_STATES:
            instore = default_backend.get_result(uuid)
            self.assertEqual(str(instore.args), str(res.args))
            expect["result"] = str(res.args[0])
            expect["exc"] = get_full_cls_name(res.__class__)
            expect["traceback"] = traceback

        self.assertJSONEqual(json, dict(task=expect))
Beispiel #8
0
    def assertStatusForIs(self, status, res, traceback=None):
        uuid = gen_unique_id()
        default_backend.store_result(uuid, res, status,
                                     traceback=traceback)
        json = self.client.get(task_status(task_id=uuid))
        expect = dict(id=uuid, status=status, result=res)
        if status in default_backend.EXCEPTION_STATES:
            instore = default_backend.get_result(uuid)
            self.assertEqual(str(instore.args), str(res.args))
            expect["result"] = repr(res)
            expect["exc"] = get_full_cls_name(res.__class__)
            expect["traceback"] = traceback

        self.assertJSONEqual(json, dict(task=expect))
Beispiel #9
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")
Beispiel #11
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))