How to use _waitFor method in pyatom

Best Python code snippet using pyatom_python

check_bashtard.py

Source:check_bashtard.py Github

copy

Full Screen

...6SEPARATOR = '-------------------\n'7class Bashtard:8 def __init__(self, host, port):9 self.con = socket.create_connection((host, port))10 self._waitFor('What is your name? ')11 12 def _waitFor(self, good, bad = None):13 buf = ''14 while (not good in buf) and (bad is None or not bad in buf):15 d = self.con.recv(1)16 if d is None or len(d) == 0:17 return None18 buf += d19 if not bad is None and bad in buf:20 raise Exception()21 return buf22 def _waitForOptions(self):23 self._waitFor('What do you want to do? ')24 def createUser(self, username, password):25 try:26 self.con.send('%s\n' % username)27 self._waitFor('What will be your password? ', 'What is your password? ')28 self.con.send('%s\n' % password)29 self._waitFor('Hope you will find this service useful.\n')30 return True31 except Exception as e:32 return False33 def authenticate(self, username, password):34 try:35 self.con.send('%s\n' % username)36 self._waitFor('What is your password? ', 'What will be your password? ')37 self.con.send('%s\n' % password)38 self._waitFor('That was right.\n', 'Bad password\n')39 return True40 except:41 return False42 def sendMail(self, receiver, message):43 self._waitForOptions()44 try:45 self.con.send('write\n')46 self._waitFor('Who do you want to write to? ')47 self.con.send('%s\n' % receiver)48 self._waitFor('What do you want to say to %s? ' % receiver)49 self.con.send('%s\n' % message)50 self._waitFor('Thanks!\n')51 return True52 except Exception as e:53 return False54 def readFile(self, f):55 self._waitForOptions()56 try:57 self.con.send('read\n')58 self._waitFor('files do you want to read? ')59 self.con.send('%s\n' % f)60 c = self._waitFor(SEPARATOR)61 c = c[0:-len(SEPARATOR)]62 return c.strip()63 except Exception as e:64 return False65 def listUsers(self):66 self._waitForOptions()67 try:68 self.con.send('list_users\n')69 return self._waitFor(SEPARATOR).split('\n')[:-2]70 except Exception as e:71 print e72 return False73 def listFiles(self):74 self._waitForOptions()75 try:76 self.con.send('list_files\n')77 return self._waitFor(SEPARATOR).split('\n')[:-2]78 except:79 pass80 return False81def md5sum(data):82 m = md5.new()83 m.update(data)84 return m.hexdigest()85def friend(name):86 digest = md5sum(name)87 return (digest[0:len(digest) / 2], digest[len(digest) / 2:])88def plant(host, port, username, password):89 try:90 b = Bashtard(host, port)91 fb = Bashtard(host, port)...

Full Screen

Full Screen

rmtree.py

Source:rmtree.py Github

copy

Full Screen

1#Embedded file name: e:\jenkins\workspace\client_SERENITY\branches\release\SERENITY\carbon\common\stdlib\testfixtures\rmtree.py2import errno3import os4import shutil5import sys6import time7import warnings8if sys.platform.startswith('win'):9 def _waitfor(func, pathname, waitall = False):10 func(pathname)11 if waitall:12 dirname = pathname13 else:14 dirname, name = os.path.split(pathname)15 dirname = dirname or '.'16 timeout = 0.00117 while timeout < 1.0:18 L = os.listdir(dirname)19 if not (L if waitall else name in L):20 return21 time.sleep(timeout)22 timeout *= 223 warnings.warn('tests may fail, delete still pending for ' + pathname, RuntimeWarning, stacklevel=4)24 def _rmtree(path):25 def _rmtree_inner(path):26 for name in os.listdir(path):27 fullname = os.path.join(path, name)28 if os.path.isdir(fullname):29 _waitfor(_rmtree_inner, fullname, waitall=True)30 os.rmdir(fullname)31 else:32 os.unlink(fullname)33 _waitfor(_rmtree_inner, path, waitall=True)34 _waitfor(os.rmdir, path)35else:36 _rmtree = shutil.rmtree37def rmtree(path):38 try:39 _rmtree(path)40 except OSError as e:41 if e.errno not in (errno.ENOENT, errno.ESRCH):...

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 pyatom 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