How to use run_reboot method in autotest

Best Python code snippet using autotest_python

main.py

Source:main.py Github

copy

Full Screen

...30 if axis == 1:31 return x, value, coords[2]32 y = (y_bounds[0][1] + 1 if y_bounds[0] else coords[1][0], y_bounds[1][0] - 1 if y_bounds[1] else coords[1][1])33 return x, y, value34def run_reboot(data, show=False):35 reactor = set()36 for state, x, y, z in data:37 for coords in list(reactor):38 new_bounds = []39 for ((c0, c1), (cb0, cb1)) in zip([x, y, z], coords):40 if cb0 < c0 < cb1:41 if cb0 <= c1 < cb1:42 new_bounds.append([(cb0, c0 - 1), (c1 + 1, cb1)])43 else:44 new_bounds.append([(cb0, c0 - 1), ()])45 elif cb0 == c0:46 new_bounds.append([(), (c1 + 1, cb1)] if cb1 > c1 else [(), ()])47 elif cb1 == c0:48 new_bounds.append([(cb0, cb1 - 1), ()])49 elif cb0 <= c1 < cb1:50 new_bounds.append([(), (c1 + 1, cb1)])51 elif c1 == cb1:52 new_bounds.append([(), ()])53 elif c0 <= cb0 <= cb1 <= c1:54 new_bounds.append([(), ()])55 if len(new_bounds) == 3:56 for axis in range(3):57 end, start = new_bounds[axis]58 match axis:59 case 0:60 if end:61 reactor.add((end, coords[1], coords[2]))62 if start:63 reactor.add((start, coords[1], coords[2]))64 case 1:65 if end:66 reactor.add(get_bounded(coords, axis, end, new_bounds[0]))67 if start:68 reactor.add(get_bounded(coords, axis, start, new_bounds[0]))69 case 2:70 if end:71 reactor.add(get_bounded(coords, axis, end, new_bounds[0], new_bounds[1]))72 if start:73 reactor.add(get_bounded(coords, axis, start, new_bounds[0], new_bounds[1]))74 reactor.remove(coords)75 if state:76 reactor.add((x, y, z))77 if show:78 viz(reactor)79 return reactor80def filter_50_50_cube(data):81 return ((-50, -50), (-50, -50), (-50, -50)) <= (data[1], data[2], data[3]) <= ((50, 50), (50, 50), (50, 50))82def part1():83 data = load_data()84 data = filter(filter_50_50_cube, data)85 reactor = run_reboot(data)86 print(sum(volume(k) for k in reactor))87def part2():88 data = load_data()89 reactor = run_reboot(data)90 print(sum(volume(k) for k in reactor))91if __name__ == '__main__':92 part1()...

Full Screen

Full Screen

display.py

Source:display.py Github

copy

Full Screen

1## For Raspberry Pi ZERO W - 2.2" pi-tft display hat.2##3## This is a simple python script template that can4## be set to start program on boot and loops forever.5##6## Place in /etc/rc.local before exit: 7## eg sudo python /home/pi/display.py &8##9## Currently implements reboot, shutdown, and program10## start/stop when the respective button is pressed.11##12## device layout:13## ______________________14## | | ____________ |15## | | *23 | | |*1716## | | *22 | screen | |17## | | *24 | 18x40 | |18## | | *5 |____________| |*419## |_|____________________|20from gpiozero import Button # to access buttons21from time import sleep # for sleep function22import os # for shutdown/kill control23import subprocess # to run program24import signal # to kill program25# might not need these - display backlight26import RPi.GPIO as GPIO27GPIO.setmode(GPIO.BCM)28GPIO.setwarnings(False)29GPIO.setup(27, GPIO.OUT)30## define display button Objects 31p4_start = Button(23)32p3_start = Button(22)33p2_start = Button(24)34p1_start = Button(5)35run_reboot = Button(17)36run_halt = Button(4)37## program/command list - set these.38halt = "shutdown now -h"39reboot = "reboot now"40p4 = "./home/pi/net_test.sh"41p3 = "pihole -t | awk '{print $5,$7,$8}' | cut -c -40"42p2 = "/usr/bin/htop"43p1 = "./home/pi/padd_mini.sh"44## if set to True, p1 will start on run45start_on_boot = True46## clear display47def d_refresh():48 for x in range(18):49 print()50## wait for system to fully boot51sleep(2)52## start p1 53if start_on_boot:54 proc = subprocess.Popen(p1, shell=True, preexec_fn=os.setsid)55else:56 proc = None57 58## button input loop59while True:60 if proc is None:61 ## run halt62 if run_halt.is_pressed:63 os.system(halt)64 ## run reboot65 elif run_reboot.is_pressed:66 os.system(reboot)67 ## start p168 elif p1_start.is_pressed:69 d_refresh()70 proc = subprocess.Popen(p1, shell=True, preexec_fn=os.setsid)71 ## start p272 elif p2_start.is_pressed:73 d_refresh()74 proc = subprocess.Popen(p2, shell=True, preexec_fn=os.setsid)75 ## start p376 elif p3_start.is_pressed:77 d_refresh()78 proc = subprocess.Popen(p3, shell=True, preexec_fn=os.setsid)79 ## start p480 elif p4_start.is_pressed:81 d_refresh()82 proc = subprocess.Popen(p4, shell=True, preexec_fn=os.setsid)83 ## if any button pressed while program running, kill program84 else:85 if run_halt.is_pressed or run_reboot.is_pressed or p1_start.is_pressed or p2_start.is_pressed or p3_start.is_pressed or p4_start.is_pressed:86 os.killpg(proc.pid, signal.SIGTERM)87 proc = None...

Full Screen

Full Screen

reboot.py

Source:reboot.py Github

copy

Full Screen

...5from ..reboot import run_reboot6reboot = bot.command('reboot', permission=SUPERUSER)7@reboot.handle()8async def first_receive(bot: Bot, event: Event) -> None:...

Full Screen

Full Screen

Automation Testing Tutorials

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.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run autotest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful