make the code slightly less terrible

This commit is contained in:
askiiart 2024-11-14 08:38:48 -06:00
parent 36f999b402
commit 431f665cf2

View file

@ -2,6 +2,7 @@ import GPUtil
import time
from pySerialTransfer import pySerialTransfer as txfer
from subprocess import getoutput
from glob import glob
try:
# ---
@ -13,11 +14,10 @@ try:
port = 'ttyACM'
while True:
ports = getoutput(f'ls /dev | grep {port}').split('\n')
if ports != ['']:
ports.sort()
port = ports[len(ports) - 1]
try:
port = glob(f'ls /dev/{port}*')[-]
break
except IndexError:
print('Waiting for Arduino...')
time.sleep(3)