Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def maoyan_test(request):
username = request.session.get('user', '')
tasks = Webcasestep.objects.all()
if request.method == "POST":
upperlevel_id = request.POST.get("casename_id")
write_to_txt(upperlevel_id)
time.sleep(1)
readwebcaseSQL(upperlevel_id)
return render(request, "webcasestep_manage.html",{"user": username, "tasks": tasks})
def add_task_webcase_test(request):
username = request.session.get('user', '')
tasks = webtest_task.objects.all()
if request.method == "POST":
objs = request.POST.get("objstring")
obj = json.loads(objs)
for i in range(0, len(obj)):
id=int(obj[i]['id'])
webcase_models = obj[i]['webcase_models']
webcasename = obj[i]['webcasename']
webcasedesc = obj[i]['webcasedesc']
webtest_task.objects.create(case_id=id,task_modelname=webcase_models,task_casename=webcasename,task_stepdesc=webcasedesc)
return render(request, "webcase_periodic_task.html",{"user": username, "tasks": tasks})
def run_in_terminal(upperlevel_id):
robotcasename = "test00" + str(upperlevel_id) + ".txt"
k = PyKeyboard()
sub = os.popen("where python")
pathone = sub.read()
regx = re.split('python.exe',pathone)
runpath = '"' + regx[0] + 'Scripts\pybot.bat' + '"' + ' -d results '+ robotcasename
pyautogui.keyDown('alt')
pyautogui.press('f12')
pyautogui.keyUp('alt')
time.sleep(3)
switch_langrage()
k.type_string('cd robotframework')
time.sleep(1)
pyautogui.press('enter')
time.sleep(1)
k.type_string(runpath)
time.sleep(1)
pyautogui.press('enter')
def add_email_sender(request):
username = request.session.get('user', '')
emails = Email.objects.all()
if request.method == "POST":
sender_site = request.POST.get("sender_site")
sender_email_password = request.POST.get("sender_email_password")
smtpserver = request.POST.get("smtpserver")
Email.objects.create(username=sender_site,passwd=sender_email_password,email_server=smtpserver)
return render(request,"email_add_page.html",{"user": username,"emails": emails})
def delete_recevier_message(request):
username = request.session.get('user', '')
emails = Email.objects.all()
if request.method =="POST":
email_id = request.POST.get("id")
Email.objects.filter(email_id=email_id).delete()
return render(request, "email_add_page.html", {"user": username, "emails": emails})
def edit_recevier_message(request):
username = request.session.get('user', '')
emails = Email.objects.all()
if request.method =="POST":
id = request.POST.get("id")
edit_sender_email_site = request.POST.get("edit_sender_email_site")
edit_recevier_email_sites = request.POST.get("edit_recevier_email_sites")
edit_email_subject = request.POST.get("edit_email_subject")
edit_recevier_email_port = request.POST.get("edit_recevier_email_port")
edit_email_body = request.POST.get("edit_email_body")
Email.objects.filter(email_id=id).update(sender=edit_sender_email_site, receivers=edit_recevier_email_sites, body=edit_email_body,
email_port=edit_recevier_email_port, subject=edit_email_subject)
return render(request,"email_add_page.html",{"user": username,"emails": emails})
def add_email_recevier(request):
username = request.session.get('user', '')
emails = Email.objects.all()
if request.method == "POST":
sender_email_site = request.POST.get("sender_email_site")
recevier_email_sites = request.POST.get("recevier_email_sites")
email_subject = request.POST.get("email_subject")
recevier_email_port = request.POST.get("recevier_email_port")
email_body = request.POST.get("email_body")
Email.objects.create(sender=sender_email_site,receivers=recevier_email_sites,body=email_body,email_port=recevier_email_port,subject=email_subject)
return render(request,"email_add_page.html",{"user": username,"emails": emails})
def add_web_casename(request):
username = request.session.get('user', '')
webcases = Webcase.objects.all()
if request.method == "POST":
webmodelname = request.POST.get("webmodelname", )
webcasename = request.POST.get("webcasename", )
webcharger = request.POST.get("webcharger", )
webaddcasedesc = request.POST.get("webaddcasedesc", )
Webcase.objects.get_or_create(webcase_models=webmodelname,webcasename=webcasename,webcase_charger=webcharger,webcasedesc=webaddcasedesc)
return render(request, "Web_test_robotframework.html", {"user": username, "webcases":webcases})
def searche_web_casename(request):
username = request.session.get('user', '')
webcases = Webcase.objects.all()
return render(request,"Web_test_robotframework.html", {"user": username, "webcases":webcases})
def webUI_periodic_task(request):
username = request.session.get('user','')
tasks = webtest_task.objects.all()
cases = Webcase.objects.all()
singel_tasks = webtest_task.objects.get_queryset().order_by('task_id')
paginator = Paginator(singel_tasks, 15) # 生成paginator对象,设置每页显示15条记录
page = request.GET.get('page', 1) # 获取当前页为第1页
currentPage = int(page) # 把当前页转换成整数
try:
singel_tasks = paginator.page(page) # 获取当前页码数的记录列表
except PageNotAnInteger:
singel_tasks = paginator.page(1) # 如果输入的页数不是整数则显示第1页内容
except EmptyPage:
singel_tasks = paginator.page(paginator.num_pages) # 如果输入的的页数不在系统的页数中,则显示最后一页
return render(request, "webcase_periodic_task.html", {"user": username, "singel_tasks": singel_tasks,"cases":cases,"tasks": tasks})