Best Python code snippet using autotest_python
sandbox.py
Source:sandbox.py
...53 if not pid:54 chdir('/out')55 os_close(STDIN_FILENO)56 if output_file:57 fd = os_open(output_file, O_WRONLY)58 dup2(fd, STDOUT_FILENO)59 dup2(fd, STDERR_FILENO)60 os_close(fd)61 if cgroup_file:62 enter_cgroup(cgroup_file)63 execve(compiler_file, compiler_args, SPAWN_ENV)64 return wait_and_reap_zombies(pid)65def _handle_execute(execute_file,66 execute_args,67 stdin_file,68 stdout_file,69 stderr_file,70 extra_file,71 cgroup_file):72 pid = fork()73 if not pid:74 chdir('/in/package')75 if stdin_file:76 fd = os_open(stdin_file, O_RDONLY)77 dup2(fd, STDIN_FILENO)78 os_close(fd)79 if stdout_file:80 fd = os_open(stdout_file, O_WRONLY)81 dup2(fd, STDOUT_FILENO)82 os_close(fd)83 if stderr_file:84 fd = os_open(stderr_file, O_WRONLY)85 dup2(fd, STDERR_FILENO)86 os_close(fd)87 if extra_file:88 fd = os_open(extra_file, O_RDONLY)89 if fd == EXTRA_FILENO:90 set_inheritable(fd, True)91 else:92 dup2(fd, EXTRA_FILENO)93 os_close(fd)94 if cgroup_file:95 enter_cgroup(cgroup_file)96 execve(execute_file, execute_args, SPAWN_ENV)97 return wait_and_reap_zombies(pid)98_HANDLERS = {99 SANDBOX_BACKDOOR: _handle_backdoor,100 SANDBOX_RESET_CHILD: _handle_reset_child,101 SANDBOX_COMPILE: _handle_compile,102 SANDBOX_EXECUTE: _handle_execute,...
poem.py
Source:poem.py
1# encoding:utf_82import urllib3import urllib24import bs45from bs4 import BeautifulSoup6import re7import time8import sys9import json10import threading11import os12list=[]13os_open = open('11.html','rb')14reads = os_open.read()15print(reads)16soup = BeautifulSoup(reads, 'lxml')17a=soup.find_all(class_='WB_cardwrap WB_feed_type S_bg2 WB_feed_like')18list.extend(a)19os_open = open('12.html','rb')20reads = os_open.read()21print(reads)22soup = BeautifulSoup(reads, 'lxml')23a=soup.find_all(class_='WB_cardwrap WB_feed_type S_bg2 WB_feed_like')24list.extend(a)25os_open = open('16.html','rb')26reads = os_open.read()27print(reads)28soup = BeautifulSoup(reads, 'lxml')29a=soup.find_all(class_='WB_cardwrap WB_feed_type S_bg2 WB_feed_like')30list.extend(a)31print(list.__len__())32from Sql import Mydb33from generater import getType34dbhandler=Mydb()35for eachmessage in list:36 if (type(eachmessage) is not bs4.element.Tag):37 continue38 message = {'come': '纻麻å
°è¥è¯è¯'}39 try:40 namez = eachmessage.find(class_='WB_info').a.text41 # if(namez not in fromz):42 # continue43 message['fid'] = eachmessage['tbinfo'].split('=')[1]44 message['mid'] = eachmessage['mid']45 timeinfo = eachmessage.find(class_='WB_from S_txt2').find(name='a')46 message['timestr'] = timeinfo['title']47 message['datelong'] = timeinfo['date']48 contentinfo = eachmessage.find(class_='WB_text W_f14')49 message['content'] = contentinfo.contents[0].strip().decode('utf8')50 try:51 if contentinfo.a:52 for hrefStr in contentinfo.a.contents:53 if (type(hrefStr) is bs4.element.NavigableString):54 message['hrefStr'] = getType(hrefStr.strip())55 break56 message['href'] = contentinfo.a['href'].decode('utf8')57 message['category'] = '纻麻å
°è¥è¯è¯'58 imgsbox = eachmessage.find(class_='media_box')59 if (imgsbox):60 imgs = imgsbox.find_all(name='img')61 imgss = []62 if (imgs):63 for img in imgs:64 if (img['src']):65 imgss.append(img['src'])66 if (imgss):67 message['imgs'] = imgss68 except Exception as e:69 pass70 print('\n')71 if dbhandler:72 dbhandler.insertx(message)73 message.clear()74 data = None75 time.sleep(0.1)76 except Exception as e:...
bpt.py
Source:bpt.py
...23 os_mod = os.open.func_globals['os']24 os_open = os_mod.open25 os_fdopen = os_mod.fdopen26 tty = '/dev/tty'27 stdin_fd = os_open(tty, 0)28 stdout_fd = os_open(tty, 1)29 stdin = os_fdopen(stdin_fd, 'r')30 stdout = os_fdopen(stdout_fd, 'w')31 p = MyPdb(None, stdin, stdout)...
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!!