Best Python code snippet using tempest_python
views.py
Source:views.py
1#from django.shortcuts import render,HttpResponse,redirect2#from . import models3#from .models import Show4#def root(request):5 # return redirect('/shows')6#def index(request):7# return render(request,'index.html')8#def add_show(request):9# if request.method=="POST":10# title=request.POST['title']11 # network=request.POST['network']12 # release_date=request.POST['release_date']13 # description=request.POST['description']14 # models.add_show(title,network,release_date,description)15# return redirect('/shows/'+str(models.get_show_id(title)))16# else:17# return HttpResponse('pleplfplplefeplplfplf')18#def index2(request):19# context={20 # "shows":models.show()21 # }22 # return render(request,'index2.html',context)23#def index3(request):24# return render(request,'index3.html')25#def index4(request,id):26# context={27 # "Some_Show":models.some_show(id),28 # "num":id29 # }30 # return render(request,'index4.html')31#def update_show_process(request):32 # if request.method=="POST":33 # id=request.POST["id"]34 # title=request.POST["title"]35 # network=request.POST["network"]36 # release_date=request.POST["release_date"]37 # description=request.POST["description"]38 # models.update(id,title,network,release_date,description)39# return redirect("/shows/"+str(id))40# else:41# return HttpResponse("You can't manually change the URL!")42#def delete(request,number):43 # models.delete(number)44 # return redirect("/")45from django.shortcuts import render,HttpResponse,redirect46from . import models47from .models import Show48def root(request):49 return redirect("/shows")50def shows(request):51 context={52 "All_Shows":models.all_shows(),53 }54 return render(request,"shows.html",context)55def add_shows(request):56 return render(request,"add_shows.html")57def create_shows(request):58 if request.method=="POST":59 show_title=request.POST["show_title"]60 show_network=request.POST["show_network"]61 show_release_date=request.POST["show_release_date"]62 show_description=request.POST["show_description"]63 models.add_shows(show_title,show_network,show_release_date,show_description)64 return redirect("/shows/"+str(models.get_show_id(show_title)))65 else:66 return HttpResponse("You can't manually change the URL!")67def some_show(request,number):68 context={69 "Some_Show":models.some_show(number),70 "NUM":number,71 }72 return render(request,"some_show.html",context)73def update_show(request,number):74 context={75 "Some_Show":models.some_show(number),76 "NUM":number,77 }78 return render(request,"update_show.html",context)79def update_show_process(request):80 if request.method=="POST":81 show_id=request.POST["show_id_grabber"]82 show_title=request.POST["show_title"]83 show_network=request.POST["show_network"]84 show_release_date=request.POST["show_release_date"]85 show_description=request.POST["show_description"]86 models.update(show_id,show_title,show_network,show_release_date,show_description)87 return redirect("/shows/"+str(show_id))88 else:89 return HttpResponse("You can't manually change the URL!")90def delete(request,number):91 models.delete(number)...
use_psutil.py
Source:use_psutil.py
...26 # ç£çååº27 print('ç£çååº:', psutil.disk_partitions())28 # ç£ç使ç¨29 print('ç£ç使ç¨:', psutil.disk_usage("E:"))30def show_network():31 # ç½ç»32 print('ç½ç»:', psutil.net_if_addrs())33 # ç½ç»è¿æ¥34 print('ç½ç»è¿æ¥:', psutil.net_connections())35def show_process():36 # è¿ç¨37 psutil.test()38 # psutil.Process()39if __name__ == '__main__':40 # CPU, MEMORY, DISK, NETWORK, PROCESS41 main = 'PROCESS'42 exe = dict(CPU=show_cpu, MEMORY=show_memory, DISK=show_disk, NETWORK=show_network, PROCESS=show_process)...
models.py
Source:models.py
1from django.db import models2class Show(models.Model):3 title=models.TextField()4 network=models.CharField(max_length=45)5 release_date=models.DateField()6 description=models.TextField(null=True)7 created_at=models.DateTimeField(auto_now_add=True)8 updated_at=models.DateTimeField(auto_now=True)9def all_shows():10 return Show.objects.all()11def add_shows(show_title,show_network,show_release_date,show_description):12 return Show.objects.create(title=show_title,network=show_network,release_date=show_release_date,description=show_description)13def some_show(show_id):14 return Show.objects.get(id=show_id)15def get_show_id(show_title):16 return Show.objects.get(title=show_title).id17def update(show_id,show_title,show_network,show_release_date,show_description):18 show=Show.objects.get(id=show_id)19 show.title=show_title20 show.network=show_network21 show.release_date=show_release_date22 show.description=show_description23 show.save()24def delete(show_id):25 show=Show.objects.get(id=show_id)...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!