Esempio n. 1
0
    def post(self, request):
        user = request.user
        body = ""
        for chunk in request.FILES["log"]:
            body += chunk
        print body
        log = prune_logs(body)
        log = "\x00".join(log)
        with open("/tmp/LULZ", "wb+") as dest:
            dest.write(log)

        domain = request.POST.get("domain", "www.mbl.is")
        cons = request.POST.get("parallel", 0)
        rate = request.POST.get("rate", 0)
        calls = request.POST.get("requests", 0)

        server = SERVERS[0]  # TODO: this.
        payload = {"file": open("/tmp/LULZ")}
        data = {"calls": calls, "conns": cons, "domain": domain}
        r = requests.post(server, data=data, files=payload, timeout=10000)
        stuff = json.loads(r.content)
        jsonString = r.content

        x = TestRun()
        x.json = stuff
        x.save()

        return render(request, "torpedo/results.html", locals())
Esempio n. 2
0
def run_test(request):
    server = SERVERS[0]  # TODO: this.
    payload = {"file": open("/tmp/test.txt", "rb")}
    data = {"calls": "1", "conns": "1", "domain": "www.mbl.is"}
    r = requests.post(server, data=data, files=payload, timeout=10000)
    stuff = json.loads(r.content)

    x = TestRun()
    x.json = stuff
    x.save()

    return HttpResponse(r.content)