Best Python code snippet using autotest_python
student.py
Source:student.py
...53 def file_name(self) -> str:54 """Returns the name of file that the student is saved in."""55 return self.university_login56 @property57 def remote_login(self) -> Optional[str]:58 if self.__remote_login is None:59 self.load_properties()60 return self.__remote_login61 @remote_login.setter62 def remote_login(self, value):63 self.__remote_login = value64 @property65 def email(self) -> Optional[str]:66 if self.__email is None:67 self.load_properties()68 return self.__email69 @email.setter70 def email(self, value):71 self.__email = value72 @property73 def name(self) -> Optional[str]:74 if self.__name is None:75 self.load_properties()76 return self.__name...
middleware.py
Source:middleware.py
1# -*- coding: utf-8 -*-2"""3* Purpose : Single Sign-on der WWU4* Creation Date : 11-05-20155* Author : maltsev6"""7from random import random8from django.contrib.auth import login9from django.contrib.auth.models import User10from app.common.util import unescapeHTML11class SingleSignOnMiddleware:12 def process_request(self, request):13 """Authentifiziert über SSO authentifizierten Benutzer in Django14 :param request: Anfrage des Clients15 """16 if 'REMOTE_USER' not in request.META or request.user.is_authenticated():17 return18 user = self.get_user(request)19 if user:20 user.backend = 'django.contrib.auth.backends.ModelBackend'21 login(request, user)22 def get_user(self, request):23 """Gibt den über SSO authentifizierten Benutzer zurück24 :param request: Anfrage des Clients25 :return: django.contrib.auth.models.User26 """27 remote_login = request.META.get('REMOTE_USER')28 if not remote_login:29 return None30 email = remote_login + '@uni-muenster.de'31 if User.objects.filter(email__iexact=email).exists():32 user = User.objects.get(email__iexact=email)33 else:34 full_name = request.META.get('HTTP_X_TRUSTED_REMOTE_NAME', '')35 user = self.register_user(email, full_name)36 return user37 def register_user(self, email, full_name):38 """Registriert den Benutzer39 :param email: E-Mail-Adresse40 :param full_name: Vollname41 :return: django.contrib.auth.models.User42 """43 new_user = User.objects.create_user(email, email, password=str(random()))44 first_name, last_name = self.split_name(full_name)45 if first_name:46 new_user.first_name = first_name47 if last_name:48 new_user.last_name = last_name49 new_user.save()50 return new_user51 def split_name(self, full_name):52 """Teilt Vollname in Vor- und Nachname53 :param full_name: Vollname54 :return: tuple55 """56 full_name_decoded = unescapeHTML(full_name.replace(' ', ' '))57 name_parts = full_name_decoded.split(' ')58 if len(name_parts) == 2:59 return tuple(name_parts)60 else:61 # Vor- und/oder Nachname besteht aus mehreren Wörtern => schwer richtig zu parsen...
python.py
Source:python.py
1import argparse2from remote_login import RemoteLogin3parser = argparse.ArgumentParser(description='Remote login to processor')4parser.add_argument("key", type=str, help="give the ssh key")5parser.add_argument("ip", type=str, help="Enter ip address")6parser.add_argument(7 "operation",8 choices=[9 "r",10 "u",11 "d"],12 help="kind of operation")13args = parser.parse_args()14print(args)15if args.operation == "r":16 remote_login = RemoteLogin(17 args.ip,18 args.port,19 args.user,20 args.password,21 args.key,22 "/home/user/remote_login/download_files/",23 "/var/log")24 command = str(input("Enter the command:"))25 remote_login.execute_commands([command])26if args.operation == "u":27 remote_path = str(input("Enter Remote Path:"))28 remote_login = RemoteLogin(29 args.ip,30 args.port,31 args.user,32 args.password,33 args.key,34 "/home/user/remote_login/download_files/",35 remote_path)36 remote_login.upload_single_file(37 str(input("Give uploaded File with Path:")))38if args.operation == "d":39 local_path = str(input("Enter Local Path:"))40 remote_login = RemoteLogin(41 args.ip,42 args.port,43 args.user,44 args.password,45 args.key,46 local_path,47 "/var/log")48 remote_login.download_file(...
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!!