How to use __put method in yandex-tank

Best Python code snippet using yandex-tank

calculadora.py

Source:calculadora.py Github

copy

Full Screen

...36 self.lastTxt = ''37 self.expected = ''38 self.type = 139 self.__clear()40 def __put(self, txt):41 self.lastTxt = txt42 self.txt = self.txt + txt43 self.label.setText(self.txt + '|' + self.expected)44 def __clear(self):45 self.lastTxt = ''46 self.txt = ''47 self.label.setText('|')48 self.expected = ''49 def __eval(self):50 j = 1j51 log = log1052 self.txt = self.txt.replace('^', '**')53 self.txt = self.txt.replace('π', 'pi')54 ans = eval(self.txt + self.expected)55 if isinstance(ans, complex):56 if ans.imag in [0, 0.0, -0.0]:57 ans = ans.real58 self.txt = str(ans)59 self.expected = ''60 self.lastTxt = self.txt[-1]61 self.label.setText(self.txt)62 def __onClick(self, *args, button: QtWidgets.QPushButton, **kwargs):63 id = button.text()64 # if self.txt in ['0.0', '0', '-0.0']:65 # self.__clear()66 if id in ['7', '8', '9', '4', '5', '6', '1', '2', '3']:67 if self.lastTxt in [')', 'π', 'j']:68 self.__put('*')69 self.__put(id)70 return71 if id == 'CE':72 self.__clear()73 return74 if id in ['*', '^', '/', '-', '+']:75 if self.lastTxt in ['7', '8', '9', '4', '5', '6', '1', '2', '3', '0',')','π', '.']:76 self.__put(id)77 elif id == '-' and self.lastTxt in ['(', ')', '+', '/', '*', '']:78 self.__put(id)79 return80 if id == '=':81 self.__eval()82 return83 if id == ')':84 if len(self.expected) == 0 or self.lastTxt in ['', '(', '*', '^', '/', '-', '+']:85 return86 self.expected = self.expected[1:]87 self.__put(id)88 return89 if id in ['(', 'π', 'cos', 'sin', 'tan', 'acos', 'asin', 'atan', 'exp', 'log']:90 if self.lastTxt in ['7', '8', '9', '4', '5', '6', '1', '2', '3','0', ')', '.', 'j', 'π']:91 self.__put('*')92 if id != 'π':93 self.expected = self.expected + ')'94 self.__put(id)95 if id not in ['(', 'π']:96 self.__put('(')97 return98 self.__put(id)99 def putButtons(self):100 i, j = 0, 1101 sep = 5102 self.buttonsWidget = []103 for bt in self.buttonsId:104 button = QtWidgets.QPushButton(bt, self)105 button.setObjectName(bt)106 button.clicked.connect(Func(self.__onClick, id=bt, button=button))107 self.grid.addWidget(button, i, j, 1, 1)108 self.buttonsWidget.append(button)109 j += 1110 if j >= sep:111 i, j = i + 1, 1112 i = 0...

Full Screen

Full Screen

stockfish.py

Source:stockfish.py Github

copy

Full Screen

...20 stdin=subprocess.PIPE,21 stdout=subprocess.PIPE22 )23 self.depth = str(depth)24 self.__put('uci')25 default_param = {26 'Write Debug Log': 'false',27 'Contempt': 0,28 'Min Split Depth': 0,29 'Threads': 1,30 'Ponder': 'false',31 'Hash': 16,32 'MultiPV': 1,33 'Skill Level': 20,34 'Move Overhead': 30,35 'Minimum Thinking Time': 20,36 'Slow Mover': 80,37 'UCI_Chess960': 'false'38 }39 default_param.update(param)40 self.param = default_param41 for name, value in list(default_param.items()):42 self.__set_option(name, value)43 self.__start_new_game()44 def __start_new_game(self):45 self.__put('ucinewgame')46 self.__isready()47 def __put(self, command):48 self.stockfish.stdin.write(command + '\n')49 self.stockfish.stdin.flush()50 def __set_option(self, optionname, value):51 self.__put('setoption name %s value %s' % (optionname, str(value)))52 stdout = self.__isready()53 if stdout.find('No such') >= 0:54 print(('stockfish was unable to set option %s' % optionname))55 def __isready(self):56 self.__put('isready')57 while True:58 text = self.stockfish.stdout.readline().strip()59 if text == 'readyok':60 return text61 def __go(self):62 self.__put('go depth %s' % self.depth)63 @staticmethod64 def __convert_move_list_to_str(moves):65 result = ''66 for move in moves:67 result += move + ' '68 return result.strip()69 def set_position(self, moves=None):70 """Sets current board positions.71 Args:72 moves: A list of moves to set this position on the board.73 Must be in full algebraic notation.74 example:75 ['e2e4', 'e7e5']76 Returns:77 None78 """79 if moves is None:80 moves = []81 self.__put('position startpos moves %s' %82 self.__convert_move_list_to_str(moves))83 84 def set_fen_position(self, fen_position):85 self.__put('position fen ' + fen_position)86 def get_best_move(self):87 """Get best move with current position on the board.88 Returns:89 A string of move in algebraic notation or False, if it's a mate now.90 """91 self.__go()92 while True:93 text = self.stockfish.stdout.readline().strip()94 split_text = text.split(' ')95 if split_text[0] == 'bestmove':96 if split_text[1] == '(none)':97 return False98 return split_text[1]99 def is_move_correct(self, move_value):100 """Checks new move.101 Args:102 move_value: New move value in algebraic notation.103 Returns:104 True, if new move is correct, else False.105 """106 self.__put('go depth 1 searchmoves %s' % move_value)107 while True:108 text = self.stockfish.stdout.readline().strip()109 split_text = text.split(' ')110 if split_text[0] == 'bestmove':111 if split_text[1] == '(none)':112 return False113 else:114 return True115 def __receive_text(p, exit_text = "Checkers:", max_lines = 100):116 """ Generic method for caputring (mutli-) line output """117 lines = []118 for i in range(max_lines):119 try:120 line = self.stockfish.stdout.readline()121 except:122 return lines123 lines.append(line)124 if line[:len(exit_text)] == exit_text:125 return lines126 return lines127 128 def get_position(self):129 self.__put('d')130 return self.__receive_text()131 def __del__(self):...

Full Screen

Full Screen

StockfishLib.py

Source:StockfishLib.py Github

copy

Full Screen

...12 stdin=subprocess.PIPE,13 stdout=subprocess.PIPE14 )15 self.depth = str(depth)16 self.__put('uci')17 default_param = {18 'Write Debug Log': 'false',19 'Contempt': 0,20 'Min Split Depth': 0,21 'Threads': 1,22 'Ponder': 'false',23 'Hash': 16,24 'MultiPV': 1,25 'Skill Level': 20,26 'Move Overhead': 30,27 'Minimum Thinking Time': 20,28 'Slow Mover': 80,29 'UCI_Chess960': 'false'30 }31 default_param.update(param)32 self.param = default_param33 for name, value in list(default_param.items()):34 self.__set_option(name, value)35 self.__start_new_game()36 def __start_new_game(self):37 self.__put('ucinewgame')38 self.__isready()39 def __put(self, command):40 self.stockfish.stdin.write(command + '\n')41 self.stockfish.stdin.flush()42 def __set_option(self, optionname, value):43 self.__put('setoption name %s value %s' % (optionname, str(value)))44 stdout = self.__isready()45 if stdout.find('No such') >= 0:46 print(('stockfish was unable to set option %s' % optionname))47 def __isready(self):48 self.__put('isready')49 while True:50 text = self.stockfish.stdout.readline().strip()51 if text == 'readyok':52 return text53 def __go(self):54 self.__put('go depth %s' % self.depth)55 @staticmethod56 def __convert_move_list_to_str(moves):57 result = ''58 for move in moves:59 result += move + ' '60 return result.strip()61 def set_position(self, moves=None):62 """Sets current board positions.63 Args:64 moves: A list of moves to set this position on the board.65 Must be in full algebraic notation.66 example:67 ['e2e4', 'e7e5']68 Returns:69 None70 """71 if moves is None:72 moves = []73 self.__put('position startpos moves %s' %74 self.__convert_move_list_to_str(moves))75 76 def set_fen_position(self, fen_position):77 self.__put('position fen ' + fen_position)78 def get_best_move(self):79 """Get best move with current position on the board.80 Returns:81 A string of move in algebraic notation or False, if it's a mate now.82 """83 self.__go()84 while True:85 text = self.stockfish.stdout.readline().strip()86 split_text = text.split(' ')87 if split_text[0] == 'bestmove':88 if split_text[1] == '(none)':89 return False90 return split_text[1]91 def is_move_correct(self, move_value):92 """Checks new move.93 Args:94 move_value: New move value in algebraic notation.95 Returns:96 True, if new move is correct, else False.97 """98 self.__put('go depth 1 searchmoves %s' % move_value)99 while True:100 text = self.stockfish.stdout.readline().strip()101 split_text = text.split(' ')102 if split_text[0] == 'bestmove':103 if split_text[1] == '(none)':104 return False105 else:106 return True107 108 def receive_text(self, exit_text = "Checkers:", max_lines = 100):109 """ Generic method for caputring (mutli-) line output 110 returns lines stripped of carriage return """111 lines = []112 for i in range(max_lines):113 try:114 line = self.stockfish.stdout.readline().strip()115 except:116 return lines117 lines.append(line)118 if line.find(exit_text) > -1:119 return lines120 return lines121 122 def get_position(self):123 self.__put('d')124 txt = self.receive_text()125 return txt126 def __del__(self):...

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