Best Python code snippet using playwright-python
wheel_builder.py
Source:wheel_builder.py
1"""Orchestrator for building wheels from InstallRequirements.2"""3import logging4import os.path5import re6import shutil7from pip._internal.models.link import Link8from pip._internal.operations.build.wheel import build_wheel_pep5179from pip._internal.operations.build.wheel_legacy import build_wheel_legacy10from pip._internal.utils.logging import indent_log11from pip._internal.utils.misc import ensure_dir, hash_file, is_wheel_installed12from pip._internal.utils.setuptools_build import make_setuptools_clean_args13from pip._internal.utils.subprocess import call_subprocess14from pip._internal.utils.temp_dir import TempDirectory15from pip._internal.utils.typing import MYPY_CHECK_RUNNING16from pip._internal.utils.urls import path_to_url17from pip._internal.vcs import vcs18if MYPY_CHECK_RUNNING:19 from typing import (20 Any, Callable, Iterable, List, Optional, Tuple,21 )22 from pip._internal.cache import WheelCache23 from pip._internal.req.req_install import InstallRequirement24 BinaryAllowedPredicate = Callable[[InstallRequirement], bool]25 BuildResult = Tuple[List[InstallRequirement], List[InstallRequirement]]26logger = logging.getLogger(__name__)27_egg_info_re = re.compile(r'([a-z0-9_.]+)-([a-z0-9_.!+-]+)', re.IGNORECASE)28def _contains_egg_info(s):29 # type: (str) -> bool30 """Determine whether the string looks like an egg_info.31 :param s: The string to parse. E.g. foo-2.132 """33 return bool(_egg_info_re.search(s))34def _should_build(35 req, # type: InstallRequirement36 need_wheel, # type: bool37 check_binary_allowed, # type: BinaryAllowedPredicate38):39 # type: (...) -> bool40 """Return whether an InstallRequirement should be built into a wheel."""41 if req.constraint:42 # never build requirements that are merely constraints43 return False44 if req.is_wheel:45 if need_wheel:46 logger.info(47 'Skipping %s, due to already being wheel.', req.name,48 )49 return False50 if need_wheel:51 # i.e. pip wheel, not pip install52 return True53 # From this point, this concerns the pip install command only54 # (need_wheel=False).55 if req.editable or not req.source_dir:56 return False57 if not check_binary_allowed(req):58 logger.info(59 "Skipping wheel build for %s, due to binaries "60 "being disabled for it.", req.name,61 )62 return False63 if not req.use_pep517 and not is_wheel_installed():64 # we don't build legacy requirements if wheel is not installed65 logger.info(66 "Using legacy 'setup.py install' for %s, "67 "since package 'wheel' is not installed.", req.name,68 )69 return False70 return True71def should_build_for_wheel_command(72 req, # type: InstallRequirement73):74 # type: (...) -> bool75 return _should_build(76 req, need_wheel=True, check_binary_allowed=_always_true77 )78def should_build_for_install_command(79 req, # type: InstallRequirement80 check_binary_allowed, # type: BinaryAllowedPredicate81):82 # type: (...) -> bool83 return _should_build(84 req, need_wheel=False, check_binary_allowed=check_binary_allowed85 )86def _should_cache(87 req, # type: InstallRequirement88):89 # type: (...) -> Optional[bool]90 """91 Return whether a built InstallRequirement can be stored in the persistent92 wheel cache, assuming the wheel cache is available, and _should_build()93 has determined a wheel needs to be built.94 """95 if req.editable or not req.source_dir:96 # never cache editable requirements97 return False98 if req.link and req.link.is_vcs:99 # VCS checkout. Do not cache100 # unless it points to an immutable commit hash.101 assert not req.editable102 assert req.source_dir103 vcs_backend = vcs.get_backend_for_scheme(req.link.scheme)104 assert vcs_backend105 if vcs_backend.is_immutable_rev_checkout(req.link.url, req.source_dir):106 return True107 return False108 assert req.link109 base, ext = req.link.splitext()110 if _contains_egg_info(base):111 return True112 # Otherwise, do not cache.113 return False114def _get_cache_dir(115 req, # type: InstallRequirement116 wheel_cache, # type: WheelCache117):118 # type: (...) -> str119 """Return the persistent or temporary cache directory where the built120 wheel need to be stored.121 """122 cache_available = bool(wheel_cache.cache_dir)123 assert req.link124 if cache_available and _should_cache(req):125 cache_dir = wheel_cache.get_path_for_link(req.link)126 else:127 cache_dir = wheel_cache.get_ephem_path_for_link(req.link)128 return cache_dir129def _always_true(_):130 # type: (Any) -> bool131 return True132def _build_one(133 req, # type: InstallRequirement134 output_dir, # type: str135 build_options, # type: List[str]136 global_options, # type: List[str]137):138 # type: (...) -> Optional[str]139 """Build one wheel.140 :return: The filename of the built wheel, or None if the build failed.141 """142 try:143 ensure_dir(output_dir)144 except OSError as e:145 logger.warning(146 "Building wheel for %s failed: %s",147 req.name, e,148 )149 return None150 # Install build deps into temporary directory (PEP 518)151 with req.build_env:152 return _build_one_inside_env(153 req, output_dir, build_options, global_options154 )155def _build_one_inside_env(156 req, # type: InstallRequirement157 output_dir, # type: str158 build_options, # type: List[str]159 global_options, # type: List[str]160):161 # type: (...) -> Optional[str]162 with TempDirectory(kind="wheel") as temp_dir:163 assert req.name164 if req.use_pep517:165 assert req.metadata_directory166 wheel_path = build_wheel_pep517(167 name=req.name,168 backend=req.pep517_backend,169 metadata_directory=req.metadata_directory,170 build_options=build_options,171 tempd=temp_dir.path,172 )173 else:174 wheel_path = build_wheel_legacy(175 name=req.name,176 setup_py_path=req.setup_py_path,177 source_dir=req.unpacked_source_directory,178 global_options=global_options,179 build_options=build_options,180 tempd=temp_dir.path,181 )182 if wheel_path is not None:183 wheel_name = os.path.basename(wheel_path)184 dest_path = os.path.join(output_dir, wheel_name)185 try:186 wheel_hash, length = hash_file(wheel_path)187 shutil.move(wheel_path, dest_path)188 logger.info('Created wheel for %s: '189 'filename=%s size=%d sha256=%s',190 req.name, wheel_name, length,191 wheel_hash.hexdigest())192 logger.info('Stored in directory: %s', output_dir)193 return dest_path194 except Exception as e:195 logger.warning(196 "Building wheel for %s failed: %s",197 req.name, e,198 )199 # Ignore return, we can't do anything else useful.200 if not req.use_pep517:201 _clean_one_legacy(req, global_options)202 return None203def _clean_one_legacy(req, global_options):204 # type: (InstallRequirement, List[str]) -> bool205 clean_args = make_setuptools_clean_args(206 req.setup_py_path,207 global_options=global_options,208 )209 logger.info('Running setup.py clean for %s', req.name)210 try:211 call_subprocess(clean_args, cwd=req.source_dir)212 return True213 except Exception:214 logger.error('Failed cleaning build dir for %s', req.name)215 return False216def build(217 requirements, # type: Iterable[InstallRequirement]218 wheel_cache, # type: WheelCache219 build_options, # type: List[str]220 global_options, # type: List[str]221):222 # type: (...) -> BuildResult223 """Build wheels.224 :return: The list of InstallRequirement that succeeded to build and225 the list of InstallRequirement that failed to build.226 """227 if not requirements:228 return [], []229 # Build the wheels.230 logger.info(231 'Building wheels for collected packages: %s',232 ', '.join(req.name for req in requirements), # type: ignore233 )234 with indent_log():235 build_successes, build_failures = [], []236 for req in requirements:237 cache_dir = _get_cache_dir(req, wheel_cache)238 wheel_file = _build_one(239 req, cache_dir, build_options, global_options240 )241 if wheel_file:242 # Update the link for this.243 req.link = Link(path_to_url(wheel_file))244 req.local_file_path = req.link.file_path245 assert req.link.is_wheel246 build_successes.append(req)247 else:248 build_failures.append(req)249 # notify success/failure250 if build_successes:251 logger.info(252 'Successfully built %s',253 ' '.join([req.name for req in build_successes]), # type: ignore254 )255 if build_failures:256 logger.info(257 'Failed to build %s',258 ' '.join([req.name for req in build_failures]), # type: ignore259 )260 # Return a list of requirements that failed to build...
Car.js
Source:Car.js
1/**2 * @author alteredq / http://alteredqualia.com/3 */4THREE.Car = function () {5 var scope = this;6 // car geometry manual parameters7 this.modelScale = 1;8 this.backWheelOffset = 2;9 this.autoWheelGeometry = true;10 // car geometry parameters automatically set from wheel mesh11 // - assumes wheel mesh is front left wheel in proper global12 // position with respect to body mesh13 // - other wheels are mirrored against car root14 // - if necessary back wheels can be offset manually15 this.wheelOffset = new THREE.Vector3();16 this.wheelDiameter = 1;17 // car "feel" parameters18 this.MAX_SPEED = 2200;19 this.MAX_REVERSE_SPEED = -1500;20 this.MAX_WHEEL_ROTATION = 0.6;21 this.FRONT_ACCELERATION = 1250;22 this.BACK_ACCELERATION = 1500;23 this.WHEEL_ANGULAR_ACCELERATION = 1.5;24 this.FRONT_DECCELERATION = 750;25 this.WHEEL_ANGULAR_DECCELERATION = 1.0;26 this.STEERING_RADIUS_RATIO = 0.0023;27 this.MAX_TILT_SIDES = 0.05;28 this.MAX_TILT_FRONTBACK = 0.015;29 // internal control variables30 this.speed = 0;31 this.acceleration = 0;32 this.wheelOrientation = 0;33 this.carOrientation = 0;34 // car rigging35 this.root = new THREE.Object3D();36 this.frontLeftWheelRoot = new THREE.Object3D();37 this.frontRightWheelRoot = new THREE.Object3D();38 this.bodyMesh = null;39 this.frontLeftWheelMesh = null;40 this.frontRightWheelMesh = null;41 this.backLeftWheelMesh = null;42 this.backRightWheelMesh = null;43 this.bodyGeometry = null;44 this.wheelGeometry = null;45 this.bodyMaterials = null;46 this.wheelMaterials = null;47 // internal helper variables48 this.loaded = false;49 this.meshes = [];50 // API51 this.enableShadows = function ( enable ) {52 for ( var i = 0; i < this.meshes.length; i ++ ) {53 this.meshes[ i ].castShadow = enable;54 this.meshes[ i ].receiveShadow = enable;55 }56 };57 this.setVisible = function ( enable ) {58 for ( var i = 0; i < this.meshes.length; i ++ ) {59 this.meshes[ i ].visible = enable;60 this.meshes[ i ].visible = enable;61 }62 };63 this.loadPartsJSON = function ( bodyURL, wheelURL ) {64 var loader = new THREE.JSONLoader();65 loader.load( bodyURL, function( geometry, materials ) { createBody( geometry, materials ) } );66 loader.load( wheelURL, function( geometry, materials ) { createWheels( geometry, materials ) } );67 };68 this.loadPartsBinary = function ( bodyURL, wheelURL ) {69 var loader = new THREE.BinaryLoader();70 loader.load( bodyURL, function( geometry, materials ) { createBody( geometry, materials ) } );71 loader.load( wheelURL, function( geometry, materials ) { createWheels( geometry, materials ) } );72 };73 this.updateCarModel = function ( delta, controls ) {74 // speed and wheels based on controls75 if ( controls.moveForward ) {76 this.speed = THREE.Math.clamp( this.speed + delta * this.FRONT_ACCELERATION, this.MAX_REVERSE_SPEED, this.MAX_SPEED );77 this.acceleration = THREE.Math.clamp( this.acceleration + delta, -1, 1 );78 }79 if ( controls.moveBackward ) {80 this.speed = THREE.Math.clamp( this.speed - delta * this.BACK_ACCELERATION, this.MAX_REVERSE_SPEED, this.MAX_SPEED );81 this.acceleration = THREE.Math.clamp( this.acceleration - delta, -1, 1 );82 }83 if ( controls.moveLeft ) {84 this.wheelOrientation = THREE.Math.clamp( this.wheelOrientation + delta * this.WHEEL_ANGULAR_ACCELERATION, - this.MAX_WHEEL_ROTATION, this.MAX_WHEEL_ROTATION );85 }86 if ( controls.moveRight ) {87 this.wheelOrientation = THREE.Math.clamp( this.wheelOrientation - delta * this.WHEEL_ANGULAR_ACCELERATION, - this.MAX_WHEEL_ROTATION, this.MAX_WHEEL_ROTATION );88 }89 // speed decay90 if ( ! ( controls.moveForward || controls.moveBackward ) ) {91 if ( this.speed > 0 ) {92 var k = exponentialEaseOut( this.speed / this.MAX_SPEED );93 this.speed = THREE.Math.clamp( this.speed - k * delta * this.FRONT_DECCELERATION, 0, this.MAX_SPEED );94 this.acceleration = THREE.Math.clamp( this.acceleration - k * delta, 0, 1 );95 } else {96 var k = exponentialEaseOut( this.speed / this.MAX_REVERSE_SPEED );97 this.speed = THREE.Math.clamp( this.speed + k * delta * this.BACK_ACCELERATION, this.MAX_REVERSE_SPEED, 0 );98 this.acceleration = THREE.Math.clamp( this.acceleration + k * delta, -1, 0 );99 }100 }101 // steering decay102 if ( ! ( controls.moveLeft || controls.moveRight ) ) {103 if ( this.wheelOrientation > 0 ) {104 this.wheelOrientation = THREE.Math.clamp( this.wheelOrientation - delta * this.WHEEL_ANGULAR_DECCELERATION, 0, this.MAX_WHEEL_ROTATION );105 } else {106 this.wheelOrientation = THREE.Math.clamp( this.wheelOrientation + delta * this.WHEEL_ANGULAR_DECCELERATION, - this.MAX_WHEEL_ROTATION, 0 );107 }108 }109 // car update110 var forwardDelta = this.speed * delta;111 this.carOrientation += ( forwardDelta * this.STEERING_RADIUS_RATIO )* this.wheelOrientation;112 // displacement113 this.root.position.x += Math.sin( this.carOrientation ) * forwardDelta;114 this.root.position.z += Math.cos( this.carOrientation ) * forwardDelta;115 // steering116 this.root.rotation.y = this.carOrientation;117 // tilt118 if ( this.loaded ) {119 this.bodyMesh.rotation.z = this.MAX_TILT_SIDES * this.wheelOrientation * ( this.speed / this.MAX_SPEED );120 this.bodyMesh.rotation.x = - this.MAX_TILT_FRONTBACK * this.acceleration;121 }122 // wheels rolling123 var angularSpeedRatio = 1 / ( this.modelScale * ( this.wheelDiameter / 2 ) );124 var wheelDelta = forwardDelta * angularSpeedRatio;125 if ( this.loaded ) {126 this.frontLeftWheelMesh.rotation.x += wheelDelta;127 this.frontRightWheelMesh.rotation.x += wheelDelta;128 this.backLeftWheelMesh.rotation.x += wheelDelta;129 this.backRightWheelMesh.rotation.x += wheelDelta;130 }131 // front wheels steering132 this.frontLeftWheelRoot.rotation.y = this.wheelOrientation;133 this.frontRightWheelRoot.rotation.y = this.wheelOrientation;134 };135 // internal helper methods136 function createBody ( geometry, materials ) {137 scope.bodyGeometry = geometry;138 scope.bodyMaterials = materials;139 createCar();140 };141 function createWheels ( geometry, materials ) {142 scope.wheelGeometry = geometry;143 scope.wheelMaterials = materials;144 createCar();145 };146 function createCar () {147 if ( scope.bodyGeometry && scope.wheelGeometry ) {148 // compute wheel geometry parameters149 if ( scope.autoWheelGeometry ) {150 scope.wheelGeometry.computeBoundingBox();151 var bb = scope.wheelGeometry.boundingBox;152 scope.wheelOffset.addVectors( bb.min, bb.max );153 scope.wheelOffset.multiplyScalar( 0.5 );154 scope.wheelDiameter = bb.max.y - bb.min.y;155 scope.wheelGeometry.center();156 }157 // rig the car158 var s = scope.modelScale,159 delta = new THREE.Vector3();160 var bodyFaceMaterial = new THREE.MeshFaceMaterial( scope.bodyMaterials );161 var wheelFaceMaterial = new THREE.MeshFaceMaterial( scope.wheelMaterials );162 // body163 scope.bodyMesh = new THREE.Mesh( scope.bodyGeometry, bodyFaceMaterial );164 scope.bodyMesh.scale.set( s, s, s );165 scope.root.add( scope.bodyMesh );166 // front left wheel167 delta.multiplyVectors( scope.wheelOffset, new THREE.Vector3( s, s, s ) );168 scope.frontLeftWheelRoot.position.add( delta );169 scope.frontLeftWheelMesh = new THREE.Mesh( scope.wheelGeometry, wheelFaceMaterial );170 scope.frontLeftWheelMesh.scale.set( s, s, s );171 scope.frontLeftWheelRoot.add( scope.frontLeftWheelMesh );172 scope.root.add( scope.frontLeftWheelRoot );173 // front right wheel174 delta.multiplyVectors( scope.wheelOffset, new THREE.Vector3( -s, s, s ) );175 scope.frontRightWheelRoot.position.add( delta );176 scope.frontRightWheelMesh = new THREE.Mesh( scope.wheelGeometry, wheelFaceMaterial );177 scope.frontRightWheelMesh.scale.set( s, s, s );178 scope.frontRightWheelMesh.rotation.z = Math.PI;179 scope.frontRightWheelRoot.add( scope.frontRightWheelMesh );180 scope.root.add( scope.frontRightWheelRoot );181 // back left wheel182 delta.multiplyVectors( scope.wheelOffset, new THREE.Vector3( s, s, -s ) );183 delta.z -= scope.backWheelOffset;184 scope.backLeftWheelMesh = new THREE.Mesh( scope.wheelGeometry, wheelFaceMaterial );185 scope.backLeftWheelMesh.position.add( delta );186 scope.backLeftWheelMesh.scale.set( s, s, s );187 scope.root.add( scope.backLeftWheelMesh );188 // back right wheel189 delta.multiplyVectors( scope.wheelOffset, new THREE.Vector3( -s, s, -s ) );190 delta.z -= scope.backWheelOffset;191 scope.backRightWheelMesh = new THREE.Mesh( scope.wheelGeometry, wheelFaceMaterial );192 scope.backRightWheelMesh.position.add( delta );193 scope.backRightWheelMesh.scale.set( s, s, s );194 scope.backRightWheelMesh.rotation.z = Math.PI;195 scope.root.add( scope.backRightWheelMesh );196 // cache meshes197 scope.meshes = [ scope.bodyMesh, scope.frontLeftWheelMesh, scope.frontRightWheelMesh, scope.backLeftWheelMesh, scope.backRightWheelMesh ];198 // callback199 scope.loaded = true;200 if ( scope.callback ) {201 scope.callback( scope );202 }203 }204 };205 function quadraticEaseOut( k ) { return - k * ( k - 2 ); }206 function cubicEaseOut( k ) { return --k * k * k + 1; }207 function circularEaseOut( k ) { return Math.sqrt( 1 - --k * k ); }208 function sinusoidalEaseOut( k ) { return Math.sin( k * Math.PI / 2 ); }209 function exponentialEaseOut( k ) { return k === 1 ? 1 : - Math.pow( 2, - 10 * k ) + 1; }...
wheel.py
Source:wheel.py
...38 "Error decoding metadata for {}: {}".format(39 self._wheel_name, e40 )41 )42def pkg_resources_distribution_for_wheel(wheel_zip, name, location):43 # type: (ZipFile, str, str) -> Distribution44 """Get a pkg_resources distribution given a wheel.45 :raises UnsupportedWheel: on any errors46 """47 info_dir, _ = parse_wheel(wheel_zip, name)48 metadata_files = [49 p for p in wheel_zip.namelist() if p.startswith("{}/".format(info_dir))50 ]51 metadata_text = {} # type: Dict[str, bytes]52 for path in metadata_files:53 # If a flag is set, namelist entries may be unicode in Python 2.54 # We coerce them to native str type to match the types used in the rest55 # of the code. This cannot fail because unicode can always be encoded56 # with UTF-8.57 full_path = ensure_str(path)58 _, metadata_name = full_path.split("/", 1)59 try:60 metadata_text[metadata_name] = read_wheel_metadata_file(61 wheel_zip, full_path62 )63 except UnsupportedWheel as e:64 raise UnsupportedWheel(65 "{} has an invalid wheel, {}".format(name, str(e))66 )67 metadata = WheelMetadata(metadata_text, location)68 return DistInfoDistribution(69 location=location, metadata=metadata, project_name=name70 )71def parse_wheel(wheel_zip, name):72 # type: (ZipFile, str) -> Tuple[str, Message]73 """Extract information from the provided wheel, ensuring it meets basic74 standards.75 Returns the name of the .dist-info directory and the parsed WHEEL metadata.76 """77 try:78 info_dir = wheel_dist_info_dir(wheel_zip, name)79 metadata = wheel_metadata(wheel_zip, info_dir)80 version = wheel_version(metadata)81 except UnsupportedWheel as e:82 raise UnsupportedWheel(83 "{} has an invalid wheel, {}".format(name, str(e))84 )85 check_compatibility(version, name)...
AWSAutonomousVehicleIOT.py
Source:AWSAutonomousVehicleIOT.py
1#!/usr/bin/python2# Replace aws_rest_endpoint with your AWS IoT endpoint dns name3# Replace the ca_path, cert_path and key_path with the credentials to you created with the AWS IoT service4# Replace your vehicleid and wheel_travel with your vehicle information5# DynamoDB TTL is set for 30 days for expiration6# battery_capacity is an arbitrary number7# Replace vehicle_topic with the AWS IoT that you want to send the telemetry to8import time9from time import sleep10import json11import random12import uuid13import datetime14import paho.mqtt.client as paho15import ssl16import rightfrontwheel17import leftfrontwheel18import rightrearwheel19import leftrearwheel20# Fill out this area with AWS account specific details21aws_rest_endpoint = "youriotendpoint.iot.us-east-1.amazonaws.com"22awsport = 888323# Location of Certificates24ca_path = "/home/pi/d2/creds/VeriSign-Class 3-Public-Primary-Certification-Authority-G5.pem"25cert_path = "/home/pi/d2/creds/avaws01.donkeycar.cert.pem"26key_path = "/home/pi/d2/creds/avaws01.donkeycar.private.key"27connflag = False28def on_connect(client, userdata, flags, rc):29 global connflag30 connflag = True31 print("Connection returned result: " + str(rc))32def on_message(client, userdata, msg):33 print(msg.topic+" "+str(msg.payload))34 print(Iot_Topic+str(msg.payload))35def getTime():36 currenttime = time.localtime()37 return (time.strftime("%Y%m%d%H%M%S", currenttime))38def drivetelemetry():39 vehicleid = "avaws01"40 actualtime = getTime()41 unixtime = str(datetime.datetime.now())42 event = uuid.uuid4()43 eventid = event.hex44 dynamodb_ttl = int(time.time()) + 259200045 wheel_travel = 9.546 feet = 1247 wheel_rotations_per_mile = 6336048 speed_reset = random.randint(1, 9)49 battery_capacity = 532050 right_front_wheel_rpm = int(rightfrontwheel.get_wheelrpm())51 right_front_wheel_odometer = round((rightfrontwheel.get_wheeldistance())/feet, 2)52 right_front_wheel_distance = right_front_wheel_rpm * wheel_travel53 right_front_wheel_mpm = right_front_wheel_distance / wheel_rotations_per_mile54 right_front_wheel_mph = right_front_wheel_mpm * 6055 right_front_wheel_speed = round(right_front_wheel_mph)56 right_front_wheel_data = {"right_front_speed": right_front_wheel_speed, "right_front_rpm": right_front_wheel_rpm, "right_front_wheel_odometer": right_front_wheel_odometer}57 left_front_wheel_rpm = int(leftfrontwheel.get_wheelrpm())58 left_front_wheel_odometer = round((leftfrontwheel.get_wheeldistance())/feet, 2)59 left_front_wheel_distance = left_front_wheel_rpm * wheel_travel60 left_front_wheel_mpm = left_front_wheel_distance / wheel_rotations_per_mile61 left_front_wheel_mph = left_front_wheel_mpm * 6062 left_front_wheel_speed = round(left_front_wheel_mph)63 left_front_wheel_data = {"left_front_speed": left_front_wheel_speed, "left_front_rpm": left_front_wheel_rpm, "left_front_wheel_odometer": left_front_wheel_odometer}64 right_rear_wheel_rpm = int(rightrearwheel.get_wheelrpm())65 right_rear_wheel_odometer = round((rightrearwheel.get_wheeldistance())/feet, 2)66 right_rear_wheel_distance = right_rear_wheel_rpm * wheel_travel67 right_rear_wheel_mpm = right_rear_wheel_distance / wheel_rotations_per_mile68 right_rear_wheel_mph = right_rear_wheel_mpm * 6069 right_rear_wheel_speed = round(right_rear_wheel_mph)70 right_rear_wheel_data = {"right_rear_speed": right_rear_wheel_speed, "right_rear_rpm": right_rear_wheel_rpm, "right_rear_wheel_odometer": right_rear_wheel_odometer}71 left_rear_wheel_rpm = int(leftrearwheel.get_wheelrpm())72 left_rear_wheel_odometer = round((leftrearwheel.get_wheeldistance())/feet, 2)73 left_rear_wheel_distance = left_rear_wheel_rpm * wheel_travel74 left_rear_wheel_mpm = left_rear_wheel_distance / wheel_rotations_per_mile75 left_rear_wheel_mph = left_rear_wheel_mpm * 6076 left_rear_wheel_speed = round(left_rear_wheel_mph)77 left_rear_wheel_data = {"left_rear_speed": left_rear_wheel_speed, "left_rear_rpm": left_rear_wheel_rpm, "left_rear_wheel_odometer": left_rear_wheel_odometer}78 vehicle_speed = int((right_front_wheel_speed + right_rear_wheel_speed + left_front_wheel_speed + left_rear_wheel_speed)/4)79 average_wheel_rpm = int((right_front_wheel_rpm + right_rear_wheel_rpm + left_front_wheel_rpm + left_rear_wheel_rpm)/4)80 vehicle_odometer = ((right_front_wheel_odometer + right_rear_wheel_odometer + left_front_wheel_odometer + left_rear_wheel_odometer)/4)81 remaining_power = int(battery_capacity - vehicle_odometer)82 engine_rpm = int(average_wheel_rpm * 11)83 # JSON Key/Value pairs of telemetry84 vehiclepayload = json.dumps(85 {86 "vehicleid": vehicleid,87 "eventid": eventid,88 "time": actualtime,89 "timestamp": unixtime,90 "average_wheel_rpm": average_wheel_rpm,91 "engine_rpm": engine_rpm,92 "vehicle_speed": vehicle_speed,93 "vehicle_odometer": vehicle_odometer,94 "remaining_power": remaining_power,95 "right_front_wheel_rpm": right_front_wheel_rpm,96 "left_front_wheel_rpm": left_front_wheel_rpm,97 "right_rear_wheel_rpm": right_rear_wheel_rpm,98 "left_rear_wheel_rpm": left_rear_wheel_rpm,99 "right_front_wheel_speed": right_front_wheel_speed,100 "left_front_wheel_speed": left_front_wheel_speed,101 "right_rear_wheel_speed": right_rear_wheel_speed,102 "left_rear_wheel_speed": left_rear_wheel_speed,103 "right_front_wheel_odometer": right_front_wheel_odometer,104 "left_front_wheel_odometer": left_front_wheel_odometer,105 "right_rear_wheel_odometer": right_rear_wheel_odometer,106 "left_rear_wheel_odometer": left_rear_wheel_odometer,107 "dynamodb_ttl": dynamodb_ttl108 }109 )110 # print (vehiclepayload)111 return(vehiclepayload)112# Logging can be enabled by uncommenting below113# def on_log(client, userdata, level, buf):114 # print(msg.topic+" "+str(msg.payload))115 # print(Iot_Topic +str(msg.payload))116mqttc = paho.Client()117mqttc.on_connect = on_connect118mqttc.on_message = on_message119# mqttc.on_log = on_log120mqttc.tls_set(ca_path, certfile=cert_path, keyfile=key_path, cert_reqs=ssl.CERT_REQUIRED, tls_version=ssl.PROTOCOL_TLSv1_2, ciphers=None)121mqttc.connect(aws_rest_endpoint, awsport, keepalive=60)122# Begin reading sensor telemetry123mqttc.loop_start()124# drivetelemetry()125for r in range(10000000):126 # Sending telemetry to AWS IoT Service127 vehicle_topic = "/topics/DonkeyCars/AVAWS01"128 telemetry_payload = drivetelemetry()129 print(telemetry_payload)130 mqttc.publish(vehicle_topic, telemetry_payload, 1)...
LambdaTest’s Playwright tutorial will give you a broader idea about the Playwright automation framework, its unique features, and use cases with examples to exceed your understanding of Playwright testing. This tutorial will give A to Z guidance, from installing the Playwright framework to some best practices and advanced concepts.
Get 100 minutes of automation test minutes FREE!!