Best Python code snippet using robotframework-appiumlibrary_python
input.py
Source:input.py
1import time2import pygame3pygame.joystick.init()4EVENTTYPES = QUIT, KEYDOWN, KEYUP, KEYDOWN2, KEYUP2, MOUSEMOVE, MOUSEWHEEL, MOUSEDOWN, MOUSEUP, WINDOWMOTION, VIDEORESIZE, DROPFILE, JOYAXISMOTION, JOYBALLMOTION, JOYHATMOTION, JOYBUTTONDOWN, JOYBUTTONUP, CONTROLLERADDED, CONTROLLERREMOVED, FINGERMOTION, FINGERUP, FINGERDOWN, FINGERUP2, FINGERDOWN2, MOUSEUP2, MOUSEDOWN2, WINDOWMOVED, KEYHOLD, MOUSEHOLD, NONEEVENT = [i for i in range(30)]5KEYS = BACKSPACE, TAB, CLEAR, RETURN, PAUSE, ESCAPE, SPACE, EXCLAIM, DOUBLEQUOTE, HASH, DOLLAR, AMPERSAND, QUOTE, LEFTPAREN, RIGHTPAREN, ASTERISK, PLUS, COMMA, MINUS, PERIOD, SLASH, ZERO, ONE, TWO, THREE, FOUR, FIVE, SIX, SEVEN, EIGHT, NINE, COLON, SEMICOLON, LESS, EQUALS, GREATER, QUESTION, AT, LEFTBRACKET, BACKSLASH, RIGHTBRACKET, CARET, UNDERSCORE, BACKQUOTE, A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z, DELETE, KP_ZERO, KP_ONE, KP_TWO, KP_THREE, KP_FOUR, KP_FIVE, KP_SIX, KP_SEVEN, KP_EIGHT, KP_NINE, KP_PERIOD, KP_DIVIDE, KP_MULTIPLY, KP_MINUS, KP_PLUS, KP_ENTER, KP_EQUALS, UP, DOWN, LEFT, RIGHT, INSERT, HOME, END, PAGEUP, PAGEDOWN, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, F13, F14, F15, NUMLOCK, CAPSLOCK, SCROLLLOCK, RSHIFT, LSHIFT, RCTRL, LCTRL, RALT, LALT, RMETA, LMETA, LSUPER, RSUPER, MODE, HELP, PRINT, SYSREQ, BREAK, MENU, POWER, EURO = pygame.K_BACKSPACE, pygame.K_TAB, pygame.K_CLEAR, pygame.K_RETURN, pygame.K_PAUSE, pygame.K_ESCAPE, pygame.K_SPACE, pygame.K_EXCLAIM, pygame.K_QUOTEDBL, pygame.K_HASH, pygame.K_DOLLAR, pygame.K_AMPERSAND, pygame.K_QUOTE, pygame.K_LEFTPAREN, pygame.K_RIGHTPAREN, pygame.K_ASTERISK, pygame.K_PLUS, pygame.K_COMMA, pygame.K_MINUS, pygame.K_PERIOD, pygame.K_SLASH, pygame.K_0, pygame.K_1, pygame.K_2, pygame.K_3, pygame.K_4, pygame.K_5, pygame.K_6, pygame.K_7, pygame.K_8, pygame.K_9, pygame.K_COLON, pygame.K_SEMICOLON, pygame.K_LESS, pygame.K_EQUALS, pygame.K_GREATER, pygame.K_QUESTION, pygame.K_AT, pygame.K_LEFTBRACKET, pygame.K_BACKSLASH, pygame.K_RIGHTBRACKET, pygame.K_CARET, pygame.K_UNDERSCORE, pygame.K_BACKQUOTE, pygame.K_a, pygame.K_b, pygame.K_c, pygame.K_d, pygame.K_e, pygame.K_f, pygame.K_g, pygame.K_h, pygame.K_i, pygame.K_j, pygame.K_k, pygame.K_l, pygame.K_m, pygame.K_n, pygame.K_o, pygame.K_p, pygame.K_q, pygame.K_r, pygame.K_s, pygame.K_t, pygame.K_u, pygame.K_v, pygame.K_w, pygame.K_x, pygame.K_y, pygame.K_z, pygame.K_DELETE, pygame.K_KP0, pygame.K_KP1, pygame.K_KP2, pygame.K_KP3, pygame.K_KP4, pygame.K_KP5, pygame.K_KP6, pygame.K_KP7, pygame.K_KP8, pygame.K_KP9, pygame.K_KP_PERIOD, pygame.K_KP_DIVIDE, pygame.K_KP_MULTIPLY, pygame.K_KP_MINUS, pygame.K_KP_PLUS, pygame.K_KP_ENTER, pygame.K_KP_EQUALS, pygame.K_UP, pygame.K_DOWN, pygame.K_RIGHT, pygame.K_LEFT, pygame.K_INSERT, pygame.K_HOME, pygame.K_END, pygame.K_PAGEUP, pygame.K_PAGEDOWN, pygame.K_F1, pygame.K_F2, pygame.K_F3, pygame.K_F4, pygame.K_F5, pygame.K_F6, pygame.K_F7, pygame.K_F8, pygame.K_F9, pygame.K_F10, pygame.K_F11, pygame.K_F12, pygame.K_F13, pygame.K_F14, pygame.K_F15, pygame.K_NUMLOCK, pygame.K_CAPSLOCK, pygame.K_SCROLLOCK, pygame.K_RSHIFT, pygame.K_LSHIFT, pygame.K_RCTRL, pygame.K_LCTRL, pygame.K_RALT, pygame.K_LALT, pygame.K_RMETA, pygame.K_LMETA, pygame.K_LSUPER, pygame.K_RSUPER, pygame.K_MODE, pygame.K_HELP, pygame.K_PRINT, pygame.K_SYSREQ, pygame.K_BREAK, pygame.K_MENU, pygame.K_POWER, pygame.K_EURO6MODS = MOD_NONE, MOD_LSHIFT, MOD_RSHIFT, MOD_SHIFT, MOD_LCTRL, MOD_RCTRL, MOD_CTRL, MOD_LALT, MOD_RALT, MOD_ALT, MOD_LMETA, MOD_RMETA, MOD_META, MOD_CAPSLOCK, MOD_NUMLOCK, MOD_MODE = pygame.KMOD_NONE, pygame.KMOD_LSHIFT, pygame.KMOD_RSHIFT, pygame.KMOD_SHIFT, pygame.KMOD_LCTRL, pygame.KMOD_RCTRL, pygame.KMOD_CTRL, pygame.KMOD_LALT, pygame.KMOD_RALT, pygame.KMOD_ALT, pygame.KMOD_LMETA, pygame.KMOD_RMETA, pygame.KMOD_META, pygame.KMOD_CAPS, pygame.KMOD_NUM, pygame.KMOD_MODE7TYPENAMES = ['QUIT', 'KEYDOWN', 'KEYUP', 'KEYDOWN2', 'KEYUP2', 'MOUSEMOVE', 'MOUSEWHEEL', 'MOUSEDOWN', 'MOUSEUP', 'WINDOWMOTION', 'VIDEORESIZE', 'DROPFILE', 'JOYAXISMOTION', 'JOYBALLMOTION', 'JOYHATMOTION', 'JOYBUTTONDOWN', 'JOYBUTTONUP', 'CONTROLLERADDED', 'CONTROLLERREMOVED', 'FINGERMOTION', 'FINGERUP', 'FINGERDOWN', 'FINGERUP2', 'FINGERDOWN2', 'MOUSEUP2', 'MOUSEDOWN2', 'WINDOWMOVED', 'NONEEVENT']8KEY_LAG_TIME = 0.8 # amount of time in between two accepted keystrokes to count as KEY2, in seconds9controllers = [pygame.joystick.Joystick(c) for c in range(pygame.joystick.get_count())]10class Event:11 def __init__(self, type, dict=None, **attributes):12 if dict is None:13 dict = {}14 if dict:15 self.attr = dict16 elif attributes:17 self.attr = attributes18 else:19 self.attr = {}20 self.type = type21 def __getattr__(self, item):22 return self.attr[item]23 def __getitem__(self, item):24 return self.attr[item]25 def __eq__(self, other):26 return (self.attr, self.type) == (other.attr, other.type)27 def __repr__(self):28 return f'Event({TYPENAMES[self.type]}), {self.attr}'29class Input:30 def __init__(self, game, cache_length=1024):31 self.game = game32 self.cache = [[], []] # time, event33 self.length = cache_length34 self.posted_events = []35 self._held_keys = {'keys': [], 'mouse': []}36 def post(self, event):37 self.posted_events.append(event)38 def get(self):39 global controllers40 return_list = []41 cur_time = time.time()42 while len(self.cache[0]) > self.length:43 self.cache[1].pop(0)44 self.cache[0].pop(0)45 for event in pygame.event.get():46 if event.type == pygame.KEYDOWN:47 if len([cache_event for t, cache_event in zip(self.cache[0], self.cache[1]) if cache_event == Event(KEYDOWN, {'key': event.key, 'unicode': event.unicode, 'mod': event.mod, 'scancode': event.scancode}) and t >= cur_time - KEY_LAG_TIME]):48 return_list.append(Event(KEYDOWN2, {'key': event.key, 'unicode': event.unicode, 'mod': event.mod, 'scancode': event.scancode}))49 self.cache[1].append(Event(KEYDOWN2, {'key': event.key, 'unicode': event.unicode, 'mod': event.mod, 'scancode': event.scancode}))50 self.cache[0].append(cur_time)51 return_list.append(Event(KEYDOWN, {'key': event.key, 'unicode': event.unicode, 'mod': event.mod, 'scancode': event.scancode}))52 self.cache[1].append(Event(KEYDOWN, {'key': event.key, 'unicode': event.unicode, 'mod': event.mod, 'scancode': event.scancode}))53 self.cache[0].append(cur_time)54 if event.key not in self._held_keys['keys']:55 self._held_keys['keys'].append(event.key)56 else:57 return_list.append(Event(KEYDOWN, {'key': event.key, 'unicode': event.unicode, 'mod': event.mod, 'scancode': event.scancode}))58 self.cache[1].append(Event(KEYDOWN, {'key': event.key, 'unicode': event.unicode, 'mod': event.mod, 'scancode': event.scancode}))59 self.cache[0].append(cur_time)60 if event.key not in self._held_keys['keys']:61 self._held_keys['keys'].append(event.key)62 elif event.type == pygame.MOUSEBUTTONDOWN:63 if len([cache_event for t, cache_event in zip(self.cache[0], self.cache[1]) if cache_event == Event(MOUSEDOWN, {'pos': event.pos, 'button': event.button}) and t >= cur_time - KEY_LAG_TIME]):64 return_list.append(Event(MOUSEDOWN2, {'pos': event.pos, 'button': event.button}))65 self.cache[1].append(Event(MOUSEDOWN2, {'pos': event.pos, 'button': event.button}))66 self.cache[0].append(cur_time)67 return_list.append(Event(MOUSEDOWN, {'pos': event.pos, 'button': event.button}))68 self.cache[1].append(Event(MOUSEDOWN, {'pos': event.pos, 'button': event.button}))69 self.cache[0].append(cur_time)70 if event.button not in self._held_keys['mouse']:71 self._held_keys['mouse'].append(event.button)72 else:73 return_list.append(Event(MOUSEDOWN, {'pos': event.pos, 'button': event.button}))74 self.cache[1].append(Event(MOUSEDOWN, {'pos': event.pos, 'button': event.button}))75 self.cache[0].append(cur_time)76 if event.button not in self._held_keys['mouse']:77 self._held_keys['mouse'].append(event.button)78 elif event.type == pygame.MOUSEBUTTONUP:79 if len([cache_event for t, cache_event in zip(self.cache[0], self.cache[1]) if cache_event == Event(MOUSEUP, {'pos': event.pos, 'button': event.button}) and t >= cur_time - KEY_LAG_TIME]):80 return_list.append(Event(MOUSEUP2, {'pos': event.pos, 'button': event.button}))81 self.cache[1].append(Event(MOUSEUP2, {'pos': event.pos, 'button': event.button}))82 self.cache[0].append(cur_time)83 return_list.append(Event(MOUSEUP, {'pos': event.pos, 'button': event.button}))84 self.cache[1].append(Event(MOUSEUP, {'pos': event.pos, 'button': event.button}))85 self.cache[0].append(cur_time)86 self._held_keys['mouse'].remove(event.button)87 else:88 return_list.append(Event(MOUSEUP, {'pos': event.pos, 'button': event.button}))89 self.cache[1].append(Event(MOUSEUP, {'pos': event.pos, 'button': event.button}))90 self.cache[0].append(cur_time)91 self._held_keys['mouse'].remove(event.button)92 elif event.type == pygame.KEYUP:93 if len([cache_event for t, cache_event in zip(self.cache[0], self.cache[1]) if cache_event == Event(KEYUP, {'key': event.key, 'mod': event.mod}) and t >= cur_time - KEY_LAG_TIME]):94 return_list.append(Event(KEYUP2, {'key': event.key, 'mod': event.mod}))95 self.cache[1].append(Event(KEYUP2, {'key': event.key, 'mod': event.mod}))96 self.cache[0].append(cur_time)97 return_list.append(Event(KEYUP, {'key': event.key, 'mod': event.mod}))98 self.cache[1].append(Event(KEYUP, {'key': event.key, 'mod': event.mod}))99 self.cache[0].append(cur_time)100 self._held_keys['keys'].remove(event.key)101 else:102 return_list.append(Event(KEYUP, {'key': event.key, 'mod': event.mod}))103 self.cache[1].append(Event(KEYUP, {'key': event.key, 'mod': event.mod}))104 self.cache[0].append(cur_time)105 self._held_keys['keys'].remove(event.key)106 elif event.type == pygame.QUIT:107 return_list.append(Event(QUIT))108 self.cache[1].append(Event(QUIT))109 self.cache[0].append(cur_time)110 elif event.type == pygame.MOUSEMOTION:111 return_list.append(Event(MOUSEMOVE, {'pos': event.pos, 'buttons': event.buttons, 'rel': event.rel}))112 self.cache[1].append(Event(MOUSEMOVE, {'pos': event.pos, 'buttons': event.buttons, 'rel': event.rel}))113 self.cache[0].append(cur_time)114 elif event.type == pygame.JOYAXISMOTION:115 return_list.append(Event(JOYAXISMOTION, {'instance_id': event.instance_id, 'axis': event.axis, 'value': event.value}))116 self.cache[1].append(Event(JOYAXISMOTION, {'instance_id': event.instance_id, 'axis': event.axis, 'value': event.value}))117 self.cache[0].append(cur_time)118 elif event.type == pygame.JOYBALLMOTION:119 return_list.append(Event(JOYBALLMOTION, {'instance_id': event.instance_id, 'ball': event.ball, 'rel': event.rel}))120 self.cache[1].append(Event(JOYBALLMOTION, {'instance_id': event.instance_id, 'ball': event.ball, 'rel': event.rel}))121 self.cache[0].append(cur_time)122 elif event.type == pygame.JOYHATMOTION:123 return_list.append(Event(JOYHATMOTION, {'instance_id': event.instance_id, 'hat': event.hat, 'value': event.value}))124 self.cache[1].append(Event(JOYHATMOTION, {'instance_id': event.instance_id, 'hat': event.hat, 'value': event.value}))125 self.cache[0].append(cur_time)126 elif event.type == pygame.JOYBUTTONUP:127 return_list.append(Event(JOYBUTTONUP, {'instance_id': event.instance_id, 'button': event.button}))128 self.cache[1].append(Event(JOYBUTTONUP, {'instance_id': event.instance_id, 'button': event.button}))129 self.cache[0].append(cur_time)130 elif event.type == pygame.JOYBUTTONDOWN:131 return_list.append(Event(JOYBUTTONDOWN, {'instance_id': event.instance_id, 'button': event.button}))132 self.cache[1].append(Event(JOYBUTTONDOWN, {'instance_id': event.instance_id, 'button': event.button}))133 self.cache[0].append(cur_time)134 elif event.type == pygame.MOUSEWHEEL:135 return_list.append(Event(MOUSEWHEEL, {'flipped': event.flipped, 'x': event.x, 'y': event.y}))136 self.cache[1].append(Event(MOUSEWHEEL, {'flipped': event.flipped, 'x': event.x, 'y': event.y}))137 self.cache[0].append(cur_time)138 elif event.type == pygame.JOYDEVICEADDED:139 return_list.append(Event(CONTROLLERADDED, {'device_id': event.device_id}))140 controllers = [pygame.joystick.Joystick(c) for c in range(pygame.joystick.get_count())]141 self.cache[1].append(Event(CONTROLLERADDED, {'device_id': event.device_id}))142 self.cache[0].append(cur_time)143 elif event.type == pygame.JOYDEVICEREMOVED:144 return_list.append(Event(CONTROLLERREMOVED, {'device_id': event.device_id}))145 controllers = [pygame.joystick.Joystick(c) for c in range(pygame.joystick.get_count())]146 self.cache[1].append(Event(CONTROLLERREMOVED, {'device_id': event.device_id}))147 self.cache[0].append(cur_time)148 elif event.type == pygame.WINDOWMOVED:149 return_list.append(Event(WINDOWMOVED, {'x': event.x, 'y': event.y}))150 self.cache[1].append(Event(WINDOWMOVED, {'x': event.x, 'y': event.y}))151 self.cache[0].append(cur_time)152 elif event.type == pygame.VIDEORESIZE:153 return_list.append(Event(VIDEORESIZE, {'size': event.size, 'w': event.w, 'h': event.h}))154 self.cache[1].append(Event(VIDEORESIZE, {'size': event.size, 'w': event.w, 'h': event.h}))155 self.cache[0].append(cur_time)156 elif event.type == pygame.DROPFILE:157 return_list.append(Event(DROPFILE, {'file': event.file}))158 self.cache[1].append(Event(DROPFILE, {'file': event.file}))159 self.cache[0].append(cur_time)160 elif event.type == pygame.FINGERMOTION:161 return_list.append(Event(FINGERMOTION, {'touch_id': event.touch_id, 'finger_id': event.finger_id, 'x': event.x, 'y': event.y, 'dx': event.dx, 'dy': event.dy}))162 self.cache[1].append(Event(FINGERMOTION, {'touch_id': event.touch_id, 'finger_id': event.finger_id, 'x': event.x, 'y': event.y, 'dx': event.dx, 'dy': event.dy}))163 self.cache[0].append(cur_time)164 elif event.type == pygame.FINGERUP:165 if len([cache_event for t, cache_event in zip(self.cache[0], self.cache[1]) if cache_event == Event(FINGERUP, {'touch_id': event.touch_id, 'finger_id': event.finger_id, 'x': event.x, 'y': event.y, 'dx': event.dx, 'dy': event.dy}) and t >= cur_time - KEY_LAG_TIME]):166 return_list.append(Event(FINGERUP2, {'touch_id': event.touch_id, 'finger_id': event.finger_id, 'x': event.x, 'y': event.y, 'dx': event.dx, 'dy': event.dy}))167 self.cache[1].append(Event(FINGERUP2, {'touch_id': event.touch_id, 'finger_id': event.finger_id, 'x': event.x, 'y': event.y, 'dx': event.dx, 'dy': event.dy}))168 self.cache[0].append(cur_time)169 return_list.append(Event(FINGERUP, {'touch_id': event.touch_id, 'finger_id': event.finger_id, 'x': event.x, 'y': event.y, 'dx': event.dx, 'dy': event.dy}))170 self.cache[1].append(Event(FINGERUP, {'touch_id': event.touch_id, 'finger_id': event.finger_id, 'x': event.x, 'y': event.y, 'dx': event.dx, 'dy': event.dy}))171 self.cache[0].append(cur_time)172 else:173 return_list.append(Event(FINGERUP, {'touch_id': event.touch_id, 'finger_id': event.finger_id, 'x': event.x, 'y': event.y, 'dx': event.dx, 'dy': event.dy}))174 self.cache[1].append(Event(FINGERUP, {'touch_id': event.touch_id, 'finger_id': event.finger_id, 'x': event.x, 'y': event.y, 'dx': event.dx, 'dy': event.dy}))175 self.cache[0].append(cur_time)176 elif event.type == pygame.FINGERDOWN:177 if len([cache_event for t, cache_event in zip(self.cache[0], self.cache[1]) if cache_event == Event(FINGERDOWN, {'touch_id': event.touch_id, 'finger_id': event.finger_id, 'x': event.x, 'y': event.y, 'dx': event.dx, 'dy': event.dy}) and t >= cur_time - KEY_LAG_TIME]):178 return_list.append(Event(FINGERDOWN2, {'touch_id': event.touch_id, 'finger_id': event.finger_id, 'x': event.x, 'y': event.y, 'dx': event.dx, 'dy': event.dy}))179 self.cache[1].append(Event(FINGERDOWN2, {'touch_id': event.touch_id, 'finger_id': event.finger_id, 'x': event.x, 'y': event.y, 'dx': event.dx, 'dy': event.dy}))180 self.cache[0].append(cur_time)181 return_list.append(Event(FINGERDOWN, {'touch_id': event.touch_id, 'finger_id': event.finger_id, 'x': event.x, 'y': event.y, 'dx': event.dx, 'dy': event.dy}))182 self.cache[1].append(Event(FINGERDOWN, {'touch_id': event.touch_id, 'finger_id': event.finger_id, 'x': event.x, 'y': event.y, 'dx': event.dx, 'dy': event.dy}))183 self.cache[0].append(cur_time)184 else:185 return_list.append(Event(FINGERDOWN, {'touch_id': event.touch_id, 'finger_id': event.finger_id, 'x': event.x, 'y': event.y, 'dx': event.dx, 'dy': event.dy}))186 self.cache[1].append(Event(FINGERDOWN, {'touch_id': event.touch_id, 'finger_id': event.finger_id, 'x': event.x, 'y': event.y, 'dx': event.dx, 'dy': event.dy}))187 self.cache[0].append(cur_time)188 for key in self._held_keys['keys']:189 self.posted_events.append(Event(KEYHOLD, {'key': key}))190 for button in self._held_keys['mouse']:191 self.posted_events.append(Event(MOUSEMOVE, {'button': button}))192 for event in self.posted_events:193 return_list.append(event)194 self.posted_events *= 0...
lesson_1_1.py
Source:lesson_1_1.py
1class Phone:2 def __init__(self, number, camera, screen, CPU, memory, touch_id, flash):3 if isinstance(number, str):4 self.number = number5 else:6 raise ValueError('Number is str!!!')7 if isinstance(camera, float):8 self.camera = camera9 else:10 raise ValueError('Camera should be float')11 if isinstance(screen, bool):12 self.screen = screen13 else:14 raise Exception('Screen is boolean!!!')15 if isinstance(CPU, float):16 self.cpu = CPU17 else:18 raise ValueError('CPU is float!!!')19 if isinstance(memory, int):20 self.memory = memory21 else:22 raise Exception('Memory is integer!!!')23 if isinstance(touch_id, bool):24 self.touch = touch_id25 else:26 raise ValueError('Touch id is boolean')27 if isinstance(flash, bool):28 self.flash = flash29 else:30 raise ValueError('Flash is boolean')31 def __str__(self):32 return f'Number: {self.number}\n' \33 f'Camera: {self.camera}\n' \34 f'Screen: {self.screen}\n' \35 f'CPU: {self.cpu}\n' \36 f'Memory: {self.memory}\n' \37 f'Touch ID: {self.touch}\n' \38 f'Flash: {self.flash}\n'39nokia_6300 = Phone('+996666321', 1.2, False, 0.7, 512, False, True)40print(nokia_6300)41class IPhone(Phone):42 def __init__(self, number, camera, screen, CPU, memory, touch_id, flash, ecosystem, fame, icloud):43 super().__init__(number, camera, screen, CPU, memory, touch_id, flash)44 if isinstance(ecosystem, bool):45 self.eco = ecosystem46 else:47 raise ValueError('Ecosystem is boolean')48 if isinstance(fame, str):49 self.fame = fame50 else:51 raise ValueError('Fame is string')52 if isinstance(icloud, int):53 self.cloud = icloud54 else:55 raise ValueError('Icloud is integer')56 def __str__(self):57 return super(IPhone, self).__str__() + f'Ecosystem: {self.eco}\n' \58 f'Fame: {self.fame}\n' \59 f'ICloud: {self.cloud}GB\n'60iphone_1 = IPhone('+996556996', 16.0, True, 2.4, 512, True, True, True, 'This is Iphone',61 icloud=32)...
utilTurnOffHpTouch.py
Source:utilTurnOffHpTouch.py
1#!/usr/bin/python2# -*- coding: utf-8 -*-3# @Author: zealotnt4# @Date: 2017-03-30 21:03:105import os6import sys7import time8import subprocess9import re10result = subprocess.check_output("xinput list", shell=True)11print result12touch_id = re.findall(r'SynPS/2 Synaptics TouchPad\s+id=(\d+)', result)13if len(touch_id) != 0:14 print "Touchpad_id = " + touch_id[0]15 os.system("xinput set-prop " + touch_id[0] + " \"Device Enabled\" 0")16else:17 print "Can't find touchpad_id, exit"...
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!