Best Python code snippet using ATX
mixins.py
Source:mixins.py
...220class MinitouchStreamMixin(object):221 __touch_queue = None222 __minitouch_process = None223224 def __install_minitouch(self):225 # install minicap & minitouch226 os.system('python -m atx minicap')227228 def open_minitouch_stream(self, port=1111):229 if self.__touch_queue is None:230 self.__touch_queue = Queue.Queue()231232 # ensure minicap installed233 out = self.raw_cmd('shell', 'ls', '"/data/local/tmp/minitouch"', stdout=subprocess.PIPE).communicate()[0]234 if 'No such file or directory' in out:235 self.__install_minitouch()236237 if self.__minitouch_process is not None:238 self.__minitouch_process.kill()239240 out = self.raw_cmd('shell', 'ps', '-C', '/data/local/tmp/minitouch', stdout=subprocess.PIPE).communicate()[0]241 out = out.strip().split('\n')242 if len(out) > 1:243 p = None244 else:245 p = self.raw_cmd('shell', '/data/local/tmp/minitouch')246 time.sleep(1)247 if p.poll() is not None:248 print 'start minitouch failed.'249 return
...
MyTouch.py
Source:MyTouch.py
...12 __touch_queue = None13 __minitouch_process = None14 def __init__(self):15 self.serial = None16 def __install_minitouch(self):17 # install minicap & minitouch18 #os.system('python -m atx minicap')19 pass20 def raw_cmd(self, *args, **kwargs):21 cmds = ['adb','-s',self.serial] + list(args)22 return subprocess.Popen(cmds, **kwargs)23 def open_minitouch_stream(self, serial = None,port=1111):24 self.serial = serial25 if self.__touch_queue is None:26 self.__touch_queue = Queue.Queue()27 # ensure minicap installed28 out = self.raw_cmd('shell', 'ls', '"/data/local/tmp/minitouch"', stdout=subprocess.PIPE).communicate()[0]29 if 'No such file or directory' in out:30 self.__install_minitouch()31 if self.__minitouch_process is not None:32 self.__minitouch_process.kill()33 out = self.raw_cmd('shell', 'ps', '-C', '/data/local/tmp/minitouch', stdout=subprocess.PIPE).communicate()[0]34 out = out.strip().split('\n')35 if len(out) > 1:36 p = None37 else:38 p = self.raw_cmd('shell', '/data/local/tmp/minitouch')39 time.sleep(1)40 if p.poll() is not None:41 print 'start minitouch failed.'42 return43 self.__minitouch_process = p 44 self.raw_cmd('forward', 'tcp:%s' % port, 'localabstract:minitouch').wait()...
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!!