How to use parse_wait method in yandex-tank

Best Python code snippet using yandex-tank

Parser.py

Source:Parser.py Github

copy

Full Screen

1import csv2import time3import xml.etree.ElementTree as ET4from Util import calc_millisec, log_print5xml = 'current.xml' # use 'current.xml' not results6parse_wait = 0.3 # seconds7def get_stint_info():8 try:9 stint_tree = ET.parse(xml)10 stint_root = stint_tree.getroot()11 stint_info = {}12 for result in stint_root.iter('result'):13 team_dict = {'last_time_line': result.get('lasttimeline'),14 'car_number': result.get('no')15 }16 if result.get('totaltime') == '':17 team_dict['total_time'] = '00:00:00.000'18 else:19 team_dict['total_time'] = result.get('totaltime')20 stint_info[result.get('regnumber')] = team_dict21 return stint_info22 except ET.ParseError:23 time.sleep(parse_wait)24 return get_stint_info()25def get_leader_board():26 try:27 leader_board_tree = ET.parse(xml)28 leader_board_root = leader_board_tree.getroot()29 leader_board = {}30 for result in leader_board_root.iter('result'):31 team_dict = {32 'car_num': result.get('no'),33 'position': result.get('position'),34 'team_name': result.get('firstname'),35 'best_lap_time': result.get('besttime'),36 'last_time': result.get('lasttime'),37 'total_time': result.get('totaltime')38 # add more fields39 }40 if result.get('sincepit') == '':41 team_dict['since_pit'] = 042 else:43 team_dict['since_pit'] = result.get('sincepit')44 leader_board[result.get('regnumber')] = team_dict45 return leader_board46 except ET.ParseError:47 time.sleep(parse_wait)48 return get_leader_board()49def get_race_data():50 try:51 race_data_tree = ET.parse(xml)52 race_data_root = race_data_tree.getroot()53 labels = race_data_root.findall('label')54 race_data = {}55 for label in labels:56 race_data[label.get('type')] = label.text57 return race_data58 except ET.ParseError:59 time.sleep(parse_wait)60 return get_race_data()61def gen_last_pit_time(file_name):62 if file_name != 'N/A':63 with open(file_name, 'r') as passings_csv:64 passings_obj = csv.reader(passings_csv)65 passings_dict = {}66 for passing in passings_obj:67 try:68 if 'P' in passing[3]:69 if passing[1] in passings_dict:70 if passings_dict[passing[1]] < calc_millisec(passing[7]):71 passings_dict[passing[1]] = calc_millisec(passing[7])72 elif passing[1] != '':73 passings_dict[passing[1]] = calc_millisec(passing[7])74 except IndexError:75 time.sleep(1)76 return gen_last_pit_time(file_name)77 return passings_dict78 else:79 log_print('Fatal Error: attempting to generate last pit time with no passings file name given')80 log_print('Ending program')81 # End Program xD...

Full Screen

Full Screen

parse.py

Source:parse.py Github

copy

Full Screen

...29 raise TypeError(f"unrecognized action: {data}")30def parse_click_action(data) -> ClickAction:31 match data:32 case {"id": str(btn), **rest}:33 return ClickAction(btn, parse_wait(rest), FieldType.ID)34 case {"name": str(btn), **rest}:35 return ClickAction(btn, parse_wait(rest), FieldType.NAME)36 case _:37 raise TypeError(f"error parsing click action: {data}")38def parse_wait(data) -> bool:39 match data:40 case {"wait": bool(wait)}:41 return wait42 case {}:43 return True44 case _:45 raise TypeError(f"error parsing wait: {data}") 46def parse_dataentry(data) -> list[DataPoint]:47 match data:48 case [{"name": name, "value": value}, *rest]:49 return [DataPoint(name, parse_datapoint(value), FieldType.NAME)] + parse_dataentry(rest)50 case [{"id": name, "value": value}, *rest]:51 return [DataPoint(name, parse_datapoint(value), FieldType.ID)] + parse_dataentry(rest)52 case []:...

Full Screen

Full Screen

cached.py

Source:cached.py Github

copy

Full Screen

...37def get_wait_time(office_id, refresh=True):38 '''Downloads data for a given office ID number and returns the wait time'''39 r = requests.get(DMV_OFFICES_URL + str(office_id))40 assert r.status_code == 200, "HTTP error %s" % (r.status_code,)41 return parse_wait(r.text)42def parse_wait(data):43 '''Returns the non-appointment wait time in minutes'''44 tree = etree.parse(data)45 root = tree.getroot()46 hour, mins = root.find('./fo_office/nonAppt').text.split(':')47 return int(hour,10) * 60 + int(mins,10)48if __name__ == "__main__":49 download_offices()50 valid_nums = parse_office_nums()51 assert len(valid_nums) == len(set(valid_nums)), "Some office indices repeat!"52 print valid_nums[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 yandex-tank 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