How to use getLastLine method in autotest

Best Python code snippet using autotest_python

main.py

Source:main.py Github

copy

Full Screen

...40 elif result == 0 :41 return -142 else :43 poslist.append((x,y))44 importCSV.getLastLine(fname)45 lastLine = importCSV.getLastLine(fname)46 data2D = importCSV.getOneRow(lastLine)47 temp = importCSV.getOnePolygon(data2D)48 if drawPolygon.isSimilar(0.9, temp, polyList[0]):49 moves.append(importCSV.getOneMove(data2D))50 effectiveMoves.append((x,y))51 polyList.append(temp)52 return 15354def oneStep3(x,y):55 global multipoly56 global multiEff57 global count58 global poslist59 global polyList60 global moves61 global effectiveMoves62 global size63 mid = int((size[0]+size[2])/2);64 if (not (mid < x < size[2]-30)) or (not (size[1]+60 < y < size[3]-30)):65 return -166 elif (checkIfVisited(x,y, poslist)==1):67 return -168 else:69 MouseSimulate.mouseMove(x,y)70 count += 171 result = importCSV.ifPolygonExists(fname, count)72 if result == -1 :73 count -= 174 return -175 elif result == 0 :76 return -177 else :78 poslist.append((x,y))79 importCSV.getLastLine(fname)80 lastLine = importCSV.getLastLine(fname)81 data2D = importCSV.getOneRow(lastLine)82 temp = importCSV.getOnePolygon(data2D)83 if drawPolygon.isSimilar(0.9, temp, polyList[0]):84 moves.append(importCSV.getOneMove(data2D))85 effectiveMoves.append((x,y))86 polyList.append(temp)87 return 18889def oneStep(x,y):90 global multipoly91 global multiEff92 global count93 global poslist94 global polyList95 global moves96 global effectiveMoves97 global size98 if (not (size[0]+30 < x < size[2]-30)) or (not (size[1]+60 < y < size[3]-30)):99 return -1100 elif (checkIfVisited(x,y, poslist)==1):101 return -1102 else:103 MouseSimulate.mouseMove(x,y)104 count += 1105 result = importCSV.ifPolygonExists(fname, count)106 if result == -1 :107 count -= 1108 return -1109 elif result == 0 :110 return -1111 else :112 poslist.append((x,y))113 importCSV.getLastLine(fname)114 lastLine = importCSV.getLastLine(fname)115 data2D = importCSV.getOneRow(lastLine)116 temp = importCSV.getOnePolygon(data2D)117 if drawPolygon.isSimilar(0.9, temp, polyList[0]):118 moves.append(importCSV.getOneMove(data2D))119 effectiveMoves.append((x,y))120 polyList.append(temp)121 return 1122123def checkIfVisited(x, y, positions):124 if (x, y) in positions :125 return 1126 else :127 return 0128129def loop(positions, effectivePos):130 total = len(effectivePos)131 print(total)132 for step in effectivePos:133 x = step[0]134 y = step[1]135 if checkIfVisited(x-30, y, positions) == 0:136 oneStep(x-30,y)137 if checkIfVisited(x, y-30, positions) == 0:138 oneStep(x, y-30)139 if checkIfVisited(x+30, y, positions) == 0:140 oneStep(x+30, y)141 if checkIfVisited(x, y+30, positions) == 0:142 oneStep(x, y+30)143144def loop2(positions, effectivePos):145 for step in effectivePos:146 x = step[0]147 y = step[1]148 if checkIfVisited(x-10, y, positions) == 0:149 oneStep2(x-10,y)150 if checkIfVisited(x, y-10, positions) == 0:151 oneStep2(x, y-10)152 if checkIfVisited(x+10, y, positions) == 0:153 oneStep2(x+10, y)154 if checkIfVisited(x, y+10, positions) == 0:155 oneStep2(x, y+10)156157def loop3(positions, effectivePos):158 for step in effectivePos:159 x = step[0]160 y = step[1]161 if checkIfVisited(x-10, y, positions) == 0:162 oneStep3(x-10,y)163 if checkIfVisited(x, y-10, positions) == 0:164 oneStep3(x, y-10)165 if checkIfVisited(x+10, y, positions) == 0:166 oneStep3(x+10, y)167 if checkIfVisited(x, y+10, positions) == 0:168 oneStep3(x, y+10)169170def run2():171 global multipoly172 global multiEff173 global count174 global poslist175 global polyList176 global moves177 global effectiveMoves178 global size179 for x in range(size[0]+30, size[2]-30,30):180 for y in range(size[1]+60, size[3]-30,30):181 if (checkIfVisited(x,y, poslist)==0):182 poslist.append((x,y))183 MouseSimulate.mouseMove(x,y)184 count += 1185 result = importCSV.ifPolygonExists(fname, count)186 if result == 1:187 lastLine = importCSV.getLastLine(fname)188 data2D = importCSV.getOneRow(lastLine)189 effectiveMoves.append((x,y))190 moves.append(importCSV.getOneMove(data2D))191 polyList.append(importCSV.getOnePolygon(data2D))192 loop(poslist, effectiveMoves)193 if len(polyList) != 0:194 multipoly.append(polyList)195 multiEff.append(moves)196 polyList = []197 moves = []198 effectiveMoves = []199 elif result == -1:200 count -= 1201 print(count)202 print(poslist)203 print(multipoly)204 print(multiEff)205 print(effectiveMoves)206 print(moves)207208def run3():209 global multipoly210 global multiEff211 global count212 global poslist213 global polyList214 global moves215 global effectiveMoves216 global size217 mid = int((size[0]+size[2])/2)218 for x in range(mid, size[0]+30,-30):219 for y in range(size[1]+60, size[3]-30,30):220 if (checkIfVisited(x,y, poslist)==0):221 poslist.append((x,y))222 MouseSimulate.mouseMove(x,y)223 count += 1224 result = importCSV.ifPolygonExists(fname, count)225 if result == 1:226 lastLine = importCSV.getLastLine(fname)227 data2D = importCSV.getOneRow(lastLine)228 effectiveMoves.append((x,y))229 moves.append(importCSV.getOneMove(data2D))230 polyList.append(importCSV.getOnePolygon(data2D))231 loop2(poslist, effectiveMoves)232 if len(polyList) != 0:233 multipoly.append(polyList)234 multiEff.append(moves)235 polyList = []236 moves = []237 effectiveMoves = []238 elif result == -1:239 count -= 1240 for x in range(mid, size[2]-30,30):241 for y in range(size[1]+60, size[3]-30,30):242 if (checkIfVisited(x,y, poslist)==0):243 poslist.append((x,y))244 MouseSimulate.mouseMove(x,y)245 count += 1246 result = importCSV.ifPolygonExists(fname, count)247 if result == 1:248 lastLine = importCSV.getLastLine(fname)249 data2D = importCSV.getOneRow(lastLine)250 effectiveMoves.append((x,y))251 moves.append(importCSV.getOneMove(data2D))252 polyList.append(importCSV.getOnePolygon(data2D))253 loop3(poslist, effectiveMoves)254 if len(polyList) != 0:255 multipoly.append(polyList)256 multiEff.append(moves)257 polyList = []258 moves = []259 effectiveMoves = []260 elif result == -1:261 count -= 1262 print(count)263 print(poslist)264 print(multipoly)265 print(multiEff)266 print(effectiveMoves)267 print(moves)268269 270def run():271 global count272 global poslist273 global polyList274 global moves275 global pixelmoves276 while True:277 if MouseSimulate.mouseClick():278 x, y = MouseSimulate.getPos()279 if (not (size[0]+30 <= x <= size[2]-30)) or (not (size[1]+60 <= y <= size[3]-30)):280 break281 count += 1282 '''283 f = open(fname, 'r')284 fileLength = sum(1 for row in f)285 f.close()286 print(fileLength)287 if fileLength < count:288 print(1)289 count -= 1290 else :291 '''292 poslist.append((x,y))293 lastLine = importCSV.getLastLine(fname)294 data2D = importCSV.getOneRow(lastLine)295 effectiveMoves.append((x,y))296 moves.append(importCSV.getOneMove(data2D))297 polyList.append(importCSV.getOnePolygon(data2D))298 time.sleep(1)299 loop(poslist, effectiveMoves)300 print(count)301 print(poslist)302 print(effectiveMoves)303 print(moves)304305if __name__ == "__main__":306 307 previousLength = importCSV.getDataLength(fname) ...

Full Screen

Full Screen

nginx_analysis.py

Source:nginx_analysis.py Github

copy

Full Screen

1#!/usr/bin/env python2#-*- coding:utf-8 -*-3__author__ = 'Don'4from os import system5import datetime6Format = '%d/%b/%Y:%H:%M'7LastMinute = (datetime.datetime.today()-datetime.timedelta(minutes=1)).strftime(Format)8print LastMinute9#LastMinute = '09/Apr/2016:11:27'10MatchRecord = 'www.x.com'11LogPath = '/data/logs/nginx/access.log'12def GetLastLine():13 '''取最后一行数据'''14 global pos,flag15 while True:16 pos = pos - 117 try:18 f.seek(pos, 2) #从文件末尾的前一个字节开始读19 if f.read(1) == '\n':20 break21 except: #到达文件第一行,直接读取,退出22 if flag == False:23 f.seek(0, 0)24 flag = True25 return f.readline().strip()26 return f.readline().strip()27def HandleData():28 '''处理数据'''29 if flag:30 print "fail"31 return #当flag标志为True,说明到达文件第一行,直接return32 if len(GetLastLine()) == 0:33 print "kong"34 return #返回空行,直接return35 print GetLastLine()36 last_line = GetLastLine().split()37 #print LastMinute38 #print last_line[5][1:-3]39 global record_list40 #if last_line[0] != "-":41 if last_line[5][1:-3] == LastMinute and last_line[7] == MatchRecord:42 record_list.append(float(last_line[0]))43if __name__ == "__main__":44 with open(LogPath,'r') as f: #‘r’的话会有两个\n\n45 pos = 046 flag = False47 record_list = []48 for line in range(50000): #需要倒数多少行就循环多少次49 #HandleData()50 print GetLastLine()51 # print record_list52 print len(record_list)53 print sum(record_list)54 record_list.sort() #列表排序55 record_list = record_list[2:-2] #去除两个最大值和最小值56 request_avg = sum(record_list)/len(record_list) #总数除以数量57 request_avg_2 = float('%0.2f'%request_avg) #取小数点后两位...

Full Screen

Full Screen

test_tk.py

Source:test_tk.py Github

copy

Full Screen

1import pytest2from machaon.app import AppRoot3from machaon.process import ProcessMessage, Spirit, TempSpirit, Process4from machaon.ui.tk import tkLauncher5def gettext(log):6 return log.get(1.0, "end")7lastlineindex = ("end linestart -2 lines", "end linestart -2 lines lineend")8def getlastline(log):9 return log.get(*lastlineindex)10def getlasttag(log):11 return log.tag_names(lastlineindex[0])12@pytest.fixture13def approot():14 app = AppRoot()15 app.initialize(ui="tk", title="test")16 app.boot_ui()17 return app18def test_message_window(approot):19 spi = Spirit(approot)20 wnd = approot.get_ui()21 assert "\n" == gettext(wnd.log)22 wnd.insert_screen_text("message", "test-message")23 assert "test-message\n\n" == gettext(wnd.log)24 assert "test-message" == getlastline(wnd.log)25 wnd.insert_screen_text("error", "test-error-message")26 assert "test-error-message" == getlastline(wnd.log)27 assert ("error",) == getlasttag(wnd.log)28 wnd.insert_screen_text("hyperlink", "test-hyperlink", link="www.hellowork.go.jp", linktag="message-em")29 assert "test-hyperlink" == getlastline(wnd.log)30 assert set(("message-em","clickable","hlink-1")) == set(getlasttag(wnd.log))31 #wnd.log.mark_set("CURRENT", "end")32 l1 = wnd.log.get("end linestart -2 lines", "end linestart -1 lines")33 l2 = wnd.log.get("end linestart -3 lines", "end linestart -2 lines")34 wnd.message_handler(ProcessMessage(tag="delete-message", line=-1, count=1))35 assert "test-error-message" == getlastline(wnd.log)36 37 #wnd.run_mainloop()38def test_textindex(approot):39 from machaon.ui.tk import TextIndex as textindex40 assert textindex("1.2").line == 1 and textindex("1.2").char == 241 assert str(textindex("2.3")) == "2.3"42 assert str(textindex("10.2").move(char=5)) == "10.5"43 assert str(textindex("10.2").move(line=0, char=0)) == "0.0"44 assert str(textindex(line=3, char="end")) == "3.end"45 i = textindex("9.7")46 assert i.shifted(line=-1, char=1).string() == "8.8"47 assert i.string() == "9.7"48 assert textindex("1.0").compare(textindex("1.3")) == 149 assert textindex("1.2").compare(textindex("2.3")) == 150 assert textindex("2.3").compare(textindex("2.3")) == 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