Best Python code snippet using lisa_python
BaseClass.py
Source:BaseClass.py
...62 if self.data == {}:63 continue64 self.data += self.get_league(league)65 return self.data66 async def launch_async(self):67 self.session = self._async_session.ClientSession(connector_owner=False)68 async with self.session.get(self._url):69 self.launched = True70 async def async_get_league(self, league: Betid = Betid.PREMIERLEAGUE, async_session: aiohttp.ClientSession = None):71 """72 Provides access to available league level odds for unplayed matches73 Returns:74 [type]: [description]75 """76 if not self.launched:77 await self.launch_async()78 if not async_session:79 async_session = self.session80 async with async_session as session:81 try:82 async with session.get(url=league.to_endpoint(self.site)) as resp:83 return self.normalizer(await resp.json())84 # print(res.status_code)85 # self.data = jsonpaths.bet9ja_validator(self.rawdata)86 except Exception as e:87 print(e)88 return {}89 async def async_get_all(self):90 """91 provides odds for all 1x2 and doublechance markets for all implemented leagues92 Returns:93 Sequence[Mapping[str, str]]: A lis94 """95 if not self.launched:96 await self.launch_async()97 self.launched = True98 work = await asyncio.gather(*[self.async_get_league(league) for league in Betid])99 # test = [league for league in work if league != {}]100 data = []101 for league in work:102 if league == {}:103 continue104 data += league...
workflow.py
Source:workflow.py
...65 )66async def set_property(db, workflow, key, value):67 workflow[key] = value68 await db.workflow_update(workflow['_id'], workflow)69async def launch_async(db, workflow, resume):70 # re-initialize database backend71 db.initialize()72 # start workflow73 work_dir = os.path.join(env.WORKFLOWS_DIR, workflow['_id'])74 proc = run_workflow(workflow, work_dir, resume)75 proc_pid = proc.pid76 print('%d: saving workflow pid...' % (proc_pid))77 # save workflow pid78 await set_property(db, workflow, 'pid', proc.pid)79 print('%d: waiting for workflow to finish...' % (proc_pid))80 # wait for workflow to complete81 if proc.wait() == 0:82 print('%d: workflow completed' % (proc_pid))83 await set_property(db, workflow, 'status', 'completed')84 else:85 print('%d: workflow failed' % (proc_pid))86 await set_property(db, workflow, 'status', 'failed')87 return88 print('%d: saving output data...' % (proc_pid))89 # save output data90 output_dir = os.path.join(env.WORKFLOWS_DIR, workflow['_id'], workflow['output_dir'])91 proc = save_output(workflow, output_dir)92 proc_out, _ = proc.communicate()93 print(proc_out.decode('utf-8'))94 if proc.wait() == 0:95 print('%d: save output data completed' % (proc_pid))96 else:97 print('%d: save output data failed' % (proc_pid))98def launch(db, workflow, resume):99 asyncio.run(launch_async(db, workflow, resume))100def cancel(workflow):101 # terminate child process102 if workflow['pid'] != -1:103 try:104 os.kill(workflow['pid'], signal.SIGINT)105 except ProcessLookupError:106 pass107 # delete pods if relevant108 if env.NXF_EXECUTOR == 'k8s':109 proc = subprocess.Popen(110 ['scripts/kube-cancel.sh', get_run_name(workflow)],111 stdout=subprocess.PIPE,112 stderr=subprocess.STDOUT113 )...
stupid.py
Source:stupid.py
...8 print "Hello world!"9def bye():10 print "Good bye cruel world..."11@async12def launch_async(arg):13 sleep(random.randint(2, 10))14 print "Hola %s" % arg15@serial16def pfinish():17 print "Finished!"18def main(*args):19 # next two in serial20 hello()21 bye()22 # next in parallel23 for x in args:24 launch_async(x)...
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!!