Esempio n. 1
0
def load_netkar(request):

    form = None
    if (request.method == "POST"):
        form = LoadForm(request.POST, request.FILES)
        if (form.is_valid()):

            pilot = form.cleaned_data["pilot"]
            vehicle = form.cleaned_data["vehicle"]
            raceway = form.cleaned_data["raceway"]
            motec = NetKarLoader(pilot, vehicle, raceway)

            ftemp = request.FILES["csv"]
            fname = "/tmp/racestat-%s.tmp" % str(int(time()))
            fwrite = open(fname, "wb+")
            for chunk in ftemp.chunks():
                fwrite.write(chunk)
            fwrite.flush()

            fread = open(fname, "rb")
            sid = motec.load(fread)
            os.remove(fname)

            return redirect("/session/%s/" % sid)
    else:
        form = LoadForm()

    return render_to_response("racestat/load/netkar.html", {"form": form},
                              context_instance=RequestContext(request))
Esempio n. 2
0
def load_netkar(request):

	form = None
	if (request.method == "POST"):
		form = LoadForm(request.POST, request.FILES)
		if (form.is_valid()):
			
			pilot = form.cleaned_data["pilot"]
			vehicle = form.cleaned_data["vehicle"]
			raceway = form.cleaned_data["raceway"]
			motec = NetKarLoader(
				pilot,
				vehicle,
				raceway)
			
			ftemp = request.FILES["csv"]
			fname = "/tmp/racestat-%s.tmp" % str(int(time()))
			fwrite = open(fname, "wb+")
			for chunk in ftemp.chunks():
				fwrite.write(chunk)
			fwrite.flush()
			
			fread = open(fname, "rb")
			sid = motec.load(fread)
			os.remove(fname)

			return redirect("/session/%s/" % sid)
	else:
		form = LoadForm()
	
	return render_to_response("racestat/load/netkar.html", 
		{"form": form}, 
		context_instance=RequestContext(request))
Esempio n. 3
0
    def test_load(self):

        motec = NetKarLoader(self.test_pilot, self.test_vehicle,
                             self.test_raceway)

        fname = "data/motec.csv.gz"
        fcsv = gzip.open(fname)
        motec.load(fcsv)
        fcsv.close()
Esempio n. 4
0
	def test_load(self):

		motec = NetKarLoader(
			self.test_pilot,
			self.test_vehicle,
			self.test_raceway)
			
		fname = "data/motec.csv.gz"
		fcsv = gzip.open(fname)
		motec.load(fcsv)
		fcsv.close()