How to use recordLine method in autotest

Best Python code snippet using autotest_python

app.py

Source:app.py Github

copy

Full Screen

1#!/usr/bin/python2# -*-coding:utf-8-*-3import json4import requests5from flask import Flask,render_template,request,session,url_for,redirect,session,make_response6g_record_line = {}7app = Flask(__name__)8#登录页9@app.route("/")10def index():11 return render_template("index.html", is_dtoken=False)12#获取用户帐号以及密码并储存,重定向到域名列表路由13@app.route("/login",methods=["POST"])14def login_d():15 user_mail = request.form["user_mail"]16 user_passwd = request.form["user_passwd"]17 user_d = request.form.get('user_d')18 login_data = {"login_email": user_mail,"login_password": user_passwd,"login_code": user_d,"format": "json"}19 login_request = requests.post("https://dnsapi.cn/User.Detail",data=login_data)20 print login_request.cookies21 user_message = json.loads(login_request.text)22 user_status = user_message["status"]23 user_code = user_status["code"]24 if int(user_code) == 1:25 session["user_mail"] = user_mail26 session["user_passwd"] = user_passwd27 session['cookies'] = ''28 for i in login_request.cookies:29 if i.name[0] == 't':30 session['cookies'] = {i.name: i.value}31 return redirect(url_for('domainlist', state=' '))32 elif int(user_code) == 50:33 return render_template("index.html", is_dtoken=True, user_mail=user_mail, user_passwd=user_passwd)34 else:35 return render_template("index.html", is_dtoken=False, user_mail=user_mail, user_passwd=user_passwd)36#进入域名列表37@app.route("/domainlist/<state>")38def domainlist(domainfree=None,domainvip=None,state=None):39 login_data = {"login_email": session["user_mail"],"login_password": session["user_passwd"],"format": "json","error_on_empty": "no"}40 login_request = requests.post("https://dnsapi.cn/Domain.List",data=login_data, cookies=session['cookies'])41 domainlist = json.loads(login_request.text)42 domaininfo = domainlist["info"]43 domainnum = domaininfo["all_total"]44 vip_total = domaininfo["vip_total"]45 46 print domainnum,vip_total47 domainlists = domainlist["domains"]48 domainfree = []49 domainvip = []50 for domainmessage in domainlists:51 domainname = domainmessage["name"]52 domaingrade = domainmessage["grade"]53 domainid = domainmessage["id"]54 domainstatus = domainmessage["status"]55 t = {"domainname":domainname,"domainid": domainid,"status": domainstatus}56 if domaingrade == "D_Free" or domaingrade == "DP_Free":57 domainfree.append(t)58 print domainname,"is free"59 else:60 domainvip.append(t)61 print domainvip,"is vip"62 return render_template("domainlist.html",domainfree=domainfree,domainvip=domainvip,state=state)63#从域名列表进入添加域名页面64@app.route("/add_domain",methods=["GET"])65def add_domain():66 return render_template("adddomain.html")67#添加域名并返回添加成功与否68@app.route("/add_domains",methods=["POST","GET"])69def Add_Domains(add_domain_status=None):70 add_domain = request.form["add_domain"]71 add_domain_data = {"login_email": session["user_mail"],"login_password": session["user_passwd"],"domain":add_domain,"format":"json"} 72 add_domain_request = requests.post("https://dnsapi.cn/Domain.Create",data=add_domain_data,cookies=session['cookies'])73 add_domain_result = json.loads(add_domain_request.text)74 status = add_domain_result['status']75 code = int(status['code'])76 print code77 if code == 1:78 add_domain_status = "success"79 elif code == 7 or code == 11 or code == 12:80 add_domain_status = "exists"81 else:82 add_domain_status = "fail"83 return render_template("adddomain.html", add_domain_status=add_domain_status)84#编辑域名85@app.route("/editdomain")86def editdomain():87 domain = request.args.get("domain")88 domainid = request.args.get("domain_id")89 rm_state = request.args.get("rm_state")90 print domain,domainid91 editdomain_data = {"login_email": session["user_mail"],"login_password": session["user_passwd"],"domain_id": domainid,"format":"json","error_on_empty": "no"}92 editdomain_request = requests.post("https://dnsapi.cn/Record.List",data=editdomain_data,cookies=session['cookies'])93 editdomain_result = json.loads(editdomain_request.text)94 records = editdomain_result["records"]95 print records96 return render_template("editdomain.html",records=records,domain=domain,domainid=domainid,rm_state=rm_state)97#进入修改域名记录(后续)98@app.route("/edit_record")99def edit_record():100 domain = request.args.get("domain")101 record_id = request.args.get("record_id")102 domainid = request.args.get("domain_id")103 recordinfo_data = {"login_email": session["user_mail"],"login_password": session["user_passwd"],"domain_id": domainid,"format":"json","record_id": record_id}104 recordinfo_request = requests.post("https://dnsapi.cn/Record.Info",data=recordinfo_data,cookies=session['cookies'])105 recordinfo_result = json.loads(recordinfo_request.text)106 domain_grade = recordinfo_result["domain"]["domain_grade"]107 sub_domain = recordinfo_result["record"]["sub_domain"]108 record_value = recordinfo_result["record"]["value"]109 record_type = recordinfo_result["record"]["record_type"]110 ttl = recordinfo_result["record"]["ttl"]111 mx = recordinfo_result["record"]["mx"]112 rl_key = 'rl_' + session['user_mail'] + '_' + domain113 if rl_key in g_record_line:114 recordline = g_record_line[rl_key]115 else:116 recordline_data = {"login_email": session["user_mail"],"login_password": session["user_passwd"],"domain_id": domainid,"format": "json","domain_grade": domain_grade}117 recordline_request = requests.post("https://dnsapi.cn/Record.Line",data=recordline_data,cookies=session["cookies"])118 recordline_result = json.loads(recordline_request.text)119 recordline = recordline_result["lines"]120 g_record_line[rl_key] = recordline121 return render_template("edit_record.html",domain=domain,recordline=recordline,sub_domain=sub_domain,record_value=record_value,record_type=record_type,ttl=ttl,mx=mx,domain_id=domainid,record_id=record_id)122@app.route("/editrecord",methods=["POST","GET"])123def editrecord():124 #recordline = request.args.get("recordline")125 domain = request.args.get("domain")126 domain_id = request.args.get("domain_id")127 record_id = request.args.get("record_id")128 print domain_id,record_id129 sub_domain = request.form["sub_domain"]130 record_type = request.form["record_type"]131 recordline = request.form["recordline"]132 record_value = request.form["record_value"]133 mx = request.form["mx"]134 ttl = request.form["ttl"]135 modify_data = {"login_email": session["user_mail"],"login_password": session["user_passwd"],"domain_id": domain_id,"format":"json","record_id": record_id,"sub_domain": sub_domain,"record_type": record_type,"record_line": recordline,"value": record_value,"mx": mx,"ttl": ttl}136 recordmodify_request = requests.post("https://dnsapi.cn/Record.Modify",data=modify_data,cookies=session["cookies"])137 recordmodify_result = json.loads(recordmodify_request.text)138 recordmodify_code = recordmodify_result["status"]["code"]139 print recordmodify_code140 if int(recordmodify_code) == 1:141 modify_status = "successful"142 else:143 modify_status = "wrong"144 rl_key = 'rl_' + session['user_mail'] + '_' + domain145 return render_template("edit_record.html",domain=domain,recordline=g_record_line[rl_key],sub_domain=sub_domain,record_value=record_value,record_type=record_type,ttl=ttl,mx=mx,domain_id=domain_id,record_id=record_id,modify_status=modify_status)146 #return recordmodify_code147 148#禁用记录(后续)149@app.route("/record_status/")150def record_status():151 return render_template("record_status.html")152#删除记录153@app.route("/rm_record")154def rm_record():155 domain = request.args.get("domain")156 record_id = request.args.get("record_id")157 domain_id = request.args.get("domain_id")158 print domain,record_id,domain_id159 return render_template("rm_record.html",record_id=record_id,domain_id=domain_id,domain=domain)160#确认删除记录161@app.route("/rm_record_sure")162def rm_record_sure():163 domain = request.args.get("domain")164 record_id = request.args.get("record_id")165 domain_id = request.args.get("domain_id")166 rm_record_data = {"login_email": session["user_mail"],"login_password": session["user_passwd"],"domain_id": domain_id,"format":"json","record_id": record_id}167 rm_record_request = requests.post("https://dnsapi.cn/Record.Remove",data=rm_record_data,cookies=session["cookies"])168 rm_record_result = json.loads(rm_record_request.text)169 rm_code = rm_record_result["status"]["code"]170 print rm_code,domain,domain_id171 if int(rm_code) == 1:172 rm_state = "success"173 return redirect(url_for("editdomain",domain=domain,domain_id=domain_id,rm_state=rm_state))174 else:175 rm_state = "wrong"176 return redirect(url_for("editdomain",domain=domain,domain_id=domain_id,rm_state=rm_state))177#删除域名178@app.route("/rm/<domain>",methods=["GET"])179def rm(domain):180 return render_template("rm.html",domain=domain)181#确认删除182@app.route("/rm_domain/<domain>",methods=["GET"])183def rm_domain(domain):184 D_code = request.args.get("D_code",None)185 rm_data = {"login_email": session["user_mail"],"login_password": session["user_passwd"],"domain": domain,"format": "json","login_code": D_code}186 rm_request = requests.post("https://dnsapi.cn/Domain.Remove",data=rm_data,cookies=session['cookies'])187 rm_result = json.loads(rm_request.text)188 status = rm_result["status"]189 code = int(status["code"])190 print code191 if code == 1:192 return redirect(url_for("domainlist",state="del domain is successful"))193 elif code == -15 or code == 7 or code == 8:194 state = "domain was ban,lock or vip"195 return redirect(url_for("domainlist",state=state))196 #需要加入D令牌判断 code == 50 197 elif code == 50:198 return render_template("D_code.html",domain=domain)199#禁用域名200@app.route("/disabled/<domain>")201def disabled(domain):202 return render_template("disabled.html",domain=domain)203#确认禁用204@app.route("/disabled_domain/<domain>")205def disabled_domain(domain):206 disabled_data = {"login_email": session["user_mail"],"login_password": session["user_passwd"],"domain": domain,"status": "disable","format": "json"}207 disabled_request = requests.post("https://dnsapi.cn/Domain.Status",data=disabled_data,cookies=session['cookies'])208 disabled_result = json.loads(disabled_request.text)209 status = disabled_result["status"]210 code = int(status["code"])211 if code == 1:212 return redirect(url_for("domainlist",state="disable domain is successful"))213 else:214 state = "domain is not disabled"215 return redirect(url_for("domainlist",state=state))216 #需要加上D令牌报错判断 code == 50217#启用域名218@app.route("/enable/<domain>")219def enable(domain):220 enable_data = {"login_email": session["user_mail"],"login_password": session["user_passwd"],"domain": domain,"status": "enable","format": "json"}221 enable_request = requests.post("https://dnsapi.cn/Domain.Status",data=enable_data,cookies=session['cookies'])222 enable_result = json.loads(enable_request.text)223 status = enable_result["status"]224 code = int(status["code"])225 if code == 1:226 return redirect(url_for("domainlist",state="enable domain is successful"))227 else:228 state = "domain is not enabled"229 return redirect(url_for("domainlist",state=state))230#退出登录231@app.route("/login_out")232def login_out():233 session.pop("user_mail",None)234 session.pop("user_passwd", None)235 session.pop("cookies", None)236 return redirect(url_for("index"))237if __name__ == "__main__": 238 app.secret_key = 'fuckmjj'...

Full Screen

Full Screen

team_record_seasons.py

Source:team_record_seasons.py Github

copy

Full Screen

1import pymysql2import csv3def main():4 # connect to db5 conn = pymysql.connect(host = "ix.cs.uoregon.edu", port = 3637, user = "modere", password = "michaelodere1", db = "NFLDB")6 # get cursor7 cur = conn.cursor()8 # create command9 stmt = "INSERT INTO team_season_performance (season_id, team_id, wins, losses, ties, home, road, points_for, points_against, touchdowns) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s)"10 records = csv.reader(open('csv/Team_Record_2007-2016.csv'))11 owners = csv.reader(open('csv/owners.csv'))12 recordList = list(records)13 ownersList = list(owners)14 # Delete top layer15 recordList.remove(recordList[0])16 ownersList.remove(ownersList[0])17 season_id = 200618 teamNumber = 019 for recordLine in recordList:20 if teamNumber % 32 == 0:21 season_id = season_id + 122 teamLocation, teamName = splitName(recordLine[1])23 team_id = 124 for ownerLine in ownersList:25 tempLocation, tempName = splitName(ownerLine[2])26 if teamName == tempName:27 break28 team_id = team_id + 129 #"url","Team","Wins","Losses","Tie","Points For","Points Against","Touchdowns","Home","Road"30 wins = recordLine[2]31 losses = recordLine[3]32 ties = recordLine[4]33 points_for = recordLine[5]34 points_against = recordLine[6]35 touchdowns = recordLine[7]36 home = recordLine[8]37 road = recordLine[9]38 teamData = (season_id, team_id, wins, losses, ties, home, road, points_for, points_against, touchdowns)39 print teamData40 # execute command for each line of data41 cur.execute(stmt, teamData)42 teamNumber = teamNumber + 143 # save44 conn.commit()45 # close46 cur.close()47 conn.close()48def splitName(name):49 temp = name.split()50 if len(temp) > 2:51 teamLocation = temp[0] + ' ' + temp[1]52 teamName = temp[2]53 return (teamLocation, teamName)54 elif len(temp) > 1:55 teamLocation = temp[0]56 teamName = temp[1]57 return (teamLocation, teamName)58 return None59if __name__ == '__main__':...

Full Screen

Full Screen

filereader.py

Source:filereader.py Github

copy

Full Screen

1# filereader.py2#3# Created by: R. Necaise4# Modified by: 5#6#7class StudentFileReader :8 def __init__( self, inputSrc ):9 self._inputSrc = inputSrc10 self._inputFile = None11 def open( self ):12 self._inputFile = open(self._inputSrc, "r" )13 def close( self ):14 self._inputFile.close()15 self._inputFile = None16 def fetchRecord( self ):17 line = self._inputFile.readline()18 if line == "" :19 return None20 record = StudentRecord()21 RecordLine = line.split(":")22 # change below23 record.idNum = int(RecordLine[0])24 record.firstName = RecordLine[1]25 record.lastName = RecordLine[2]26 record.classCode = int(RecordLine[3])27 record.gpa = float(RecordLine[4])28 # change above29 return record30class StudentRecord :31 def __init__( self ):32 self.idNum = 033 self.firstName = ""34 self.lastName = ""35 self.classCode = 0...

Full Screen

Full Screen

Automation Testing Tutorials

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.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run autotest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful