Best Python code snippet using pyatom_python
check_bashtard.py
Source: check_bashtard.py
...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)...
rmtree.py
Source: rmtree.py
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):...
Check out the latest blogs from LambdaTest on this topic:
Pair testing can help you complete your testing tasks faster and with higher quality. But who can do pair testing, and when should it be done? And what form of pair testing is best for your circumstance? Check out this blog for more information on how to conduct pair testing to optimize its benefits.
We launched LT Browser in 2020, and we were overwhelmed by the response as it was awarded as the #5 product of the day on the ProductHunt platform. Today, after 74,585 downloads and 7,000 total test runs with an average of 100 test runs each day, the LT Browser has continued to help developers build responsive web designs in a jiffy.
To understand the agile testing mindset, we first need to determine what makes a team “agile.” To me, an agile team continually focuses on becoming self-organized and cross-functional to be able to complete any challenge they may face during a project.
The QA testing career includes following an often long, winding road filled with fun, chaos, challenges, and complexity. Financially, the spectrum is broad and influenced by location, company type, company size, and the QA tester’s experience level. QA testing is a profitable, enjoyable, and thriving career choice.
Dries Buytaert, a graduate student at the University of Antwerp, came up with the idea of developing something similar to a chat room. Moreover, he modified the conventional chat rooms into a website where his friends could post their queries and reply through comments. However, for this project, he thought of creating a temporary archive of posts.
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!!