Lepší vyrábění dočasných adresářů
Chceme je po sobě nejspíš mazat i když to spadne. Možná to zesložití vývoj, ale je to odolnější proti náhodnému pádu čehokoliv.
This commit is contained in:
		
							parent
							
								
									4ecd2a7a61
								
							
						
					
					
						commit
						213d3cc7b2
					
				
					 1 changed files with 7 additions and 8 deletions
				
			
		|  | @ -575,15 +575,14 @@ def obalkyView(request, resitele): | |||
| 
 | ||||
| 	tex = render(request,'seminar/archiv/obalky.tex', {'resitele': resitele}).content | ||||
| 
 | ||||
| 	tempdir = tempfile.mkdtemp() | ||||
| 	with open(tempdir+"/obalky.tex","w") as texfile: | ||||
| 		texfile.write(tex.decode()) | ||||
| 	shutil.copy(find('seminar/lisak.pdf'), tempdir) | ||||
| 	subprocess.call(["pdflatex","obalky.tex"], cwd = tempdir) | ||||
| 	with tempfile.TemporaryDirectory() as tempdir: | ||||
| 		with open(tempdir+"/obalky.tex","w") as texfile: | ||||
| 			texfile.write(tex.decode()) | ||||
| 		shutil.copy(find('seminar/lisak.pdf'), tempdir) | ||||
| 		subprocess.call(["pdflatex","obalky.tex"], cwd = tempdir) | ||||
| 
 | ||||
| 	with open(tempdir+"/obalky.pdf","rb") as pdffile: | ||||
| 		response = HttpResponse(pdffile.read(), content_type='application/pdf') | ||||
| 	shutil.rmtree(tempdir) | ||||
| 		with open(tempdir+"/obalky.pdf","rb") as pdffile: | ||||
| 			response = HttpResponse(pdffile.read(), content_type='application/pdf') | ||||
| 	return response | ||||
| 
 | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
		Reference in a new issue
	
	 Pavel "LEdoian" Turinsky
						Pavel "LEdoian" Turinsky