Best Python code snippet using lettuce_webdriver_python
run.py
Source: run.py
...87 snapshot.save(p, "PNG")88 self.show_label("[INFO] saved {}".format(filename))89 def record_video(self):90 return91 def set_save_directory(self):92 self.output_path = filedialog.askdirectory(93 initialdir=self.output_path, title="Set output path")94 return95 def send_to_torch(self):96 # Create image97 ts = datetime.datetime.now() # grab the current timestamp98 filename = "{}.jpg".format(ts.strftime(99 "%Y-%m-%d_%H-%M-%S"))100 p = os.path.join('/tmp/', filename)101 ok, frame = self.vs.read()102 if ok:103 snapshot = Image.fromarray(cv2.cvtColor(frame, cv2.COLOR_BGR2RGBA))104 snapshot.save(p, "PNG")105 if not os.path.isdir(config.YOLOv5_PATH) or not os.path.isfile(config.WEIGHTS):...
external_render.py
Source: external_render.py
...51 self.frame_end = frame_end52 self.exist_images = []53 self.save_directory_os = ''54 self.hash_list = []55 self.set_save_directory()56 self.set_exist_images()57 self.set_hash_list()58 self.render()59 def closed_range(self, start, stop, step=1):60 direction = 1 if (step > 0) else -161 return range(start, stop + direction, step)62 def setup_render_params(self, root_frame, frame):63 bpy.context.scene.frame_set(root_frame)64 bpy.data.scenes['Scene'].frame_start = ((frame - 1) % self.frame_step) + 165 box = bpy.data.objects['LightSceneBoxCamera' + str(self.target_camera)]66 cam = bpy.data.objects['CameraScene' + str(self.target_camera)]67 box.location = cam.location68 box.rotation_euler = cam.rotation_euler69 images_dir = self.project_name + '_images'70 save_directory = '//..\\' + images_dir + '\\cross\\scene-' + str(self.target_camera) + '\\'71 path_to_render_output = save_directory + 'root-' + str(root_frame) + '_frame-' + str(frame)72 bpy.data.scenes['Scene'].render.filepath = path_to_render_output73 def set_save_directory(self):74 images_dir = self.project_name + '_images'75 scene = 'scene-' + str(self.target_camera)76 self.save_directory_os = os.path.join(bpy.path.abspath('//'), '..', images_dir, 'cross', scene)77 def set_exist_images(self):78 files = os.listdir(self.save_directory_os)79 print('Walk in ' + self.save_directory_os)80 for file in files:81 if '.png' in file:82 path_to_image = os.path.join(self.save_directory_os, file)83 extract_data_from_path = re.findall(r'scene-(\d+).*root-(\d+).*frame-(\d+)', path_to_image)84 self.exist_images.append({85 'scene': int(extract_data_from_path[0][0]),86 'root': int(extract_data_from_path[0][1]),87 'frame': int(extract_data_from_path[0][2]),...
views.py
Source: views.py
1from django.shortcuts import render, redirect2from django.contrib import messages3from django.contrib.auth import authenticate4from django.contrib.auth import login5from django.contrib.auth.decorators import login_required6from django.contrib.auth.forms import AuthenticationForm7from matplotlib.style import context8from .forms import UserRegisterForm9from django.core.mail import send_mail10from django.core.mail import EmailMultiAlternatives11from django.template.loader import get_template12from django.template import Context13import os14def index(request):15 return render(request, 'account/home.html', {'title': 'Home'})16def atm_branch(request):17 return render(request, 'account/atm_branch.html', {'title':'ATM Branches'})18def contact_us(request):19 return render(request, 'account/contact_us.html', {'title':'Contact Us'})20def about_us(request):21 return render(request, 'account/about_us.html', {'title':'About Us'})22def user(request):23 return render(request, 'account/user_profile.html', {'title':'User Profile'})24def user_panel(request):25 # set_save_directory = r'static/'26 # os.chdir(set_save_directory)27 file = open(r'/home/rafsunsheikh/Desktop/signatureFraud/signatureFraud/detection/number.txt', 'r')28 number = int(file.read())29 file.close()30 number = number - 131 context = {32 'number': number,33 'title': 'User Panel'34 }35 return render(request, 'account/admin_user.html', context=context)36def register(request):37 if request.method == 'POST':38 form = UserRegisterForm(request.POST)39 if form.is_valid():40 form.save()41 username = form.cleaned_data.get('username')42 email = form.cleaned_data.get('email')43 ###############################mail system ####################44 # htmly = get_template('account/Email.html')45 # d = {'username': username }46 # subject, from_email, to = 'welcome', 'rafsun.sheikh@gmail.com', email47 # html_content = htmly.render(d)48 # msg = EmailMultiAlternatives(subject, html_content, from_email, [to])49 # msg.attach_alternative(html_content, "text/html")50 # msg.send()51 # ###################################################################52 # messages.success(request, f'Your account has been created ! You are not able to log in')53 messages.success(request, 'Account Created successfully! Welcome {}'.format(username) )54 return redirect('login')55 else:56 form = UserRegisterForm()57 return render(request, 'account/register.html', {'form' : form, 'title' : 'register here'})58def user_login(request):59 if request.method == 'POST':60 username = request.POST['username']61 password = request.POST['password']62 user = authenticate(request, username = username, password = password)63 if user is not None:64 form = login(request, user )65 messages.success(request, f' welcome {username}')66 return redirect('index')67 else:68 messages.info(request, f'account done not exit please sign in')69 form = AuthenticationForm()...
Check out the latest blogs from LambdaTest on this topic:
API (Application Programming Interface) is a set of definitions and protocols for building and integrating applications. It’s occasionally referred to as a contract between an information provider and an information user establishing the content required from the consumer and the content needed by the producer.
There is just one area where each member of the software testing community has a distinct point of view! Metrics! This contentious issue sparks intense disputes, and most conversations finish with no definitive conclusion. It covers a wide range of topics: How can testing efforts be measured? What is the most effective technique to assess effectiveness? Which of the many components should be quantified? How can we measure the quality of our testing performance, among other things?
When I started writing tests with Cypress, I was always going to use the user interface to interact and change the application’s state when running tests.
Many theoretical descriptions explain the role of the Scrum Master as a vital member of the Scrum team. However, these descriptions do not provide an honest answer to the fundamental question: “What are the day-to-day activities of a Scrum Master?”
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!!