Update flash.py
This commit is contained in:
35
flash.py
35
flash.py
@@ -2,11 +2,20 @@
|
|||||||
|
|
||||||
import subprocess
|
import subprocess
|
||||||
import time
|
import time
|
||||||
|
import fourletterphat as flp
|
||||||
|
|
||||||
#--
|
#--
|
||||||
drive_blacklist = {"/boot","/"}
|
drive_blacklist = {"/boot","/"}
|
||||||
#--
|
#--
|
||||||
|
|
||||||
|
def disp_string(string):
|
||||||
|
for letter in range(0,4):
|
||||||
|
try:
|
||||||
|
flp.set_digit(letter, string[letter].upper())
|
||||||
|
except IndexError:
|
||||||
|
pass
|
||||||
|
flp.show()
|
||||||
|
|
||||||
def get_mountedlist():
|
def get_mountedlist():
|
||||||
return [item[item.find("/"):] for item in subprocess.check_output(
|
return [item[item.find("/"):] for item in subprocess.check_output(
|
||||||
["/bin/bash", "-c", "lsblk"]).decode("utf-8").split("\n") if "/" in item]
|
["/bin/bash", "-c", "lsblk"]).decode("utf-8").split("\n") if "/" in item]
|
||||||
@@ -27,14 +36,22 @@ def flash(dev):
|
|||||||
print(output)
|
print(output)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
disp_string("GO")
|
||||||
|
|
||||||
done = set()
|
done = set()
|
||||||
while True:
|
while True:
|
||||||
devs = get_mounted_devs()
|
try:
|
||||||
done = done.intersection(devs)
|
devs = get_mounted_devs()
|
||||||
for dev in devs:
|
done = done.intersection(devs)
|
||||||
if dev not in done:
|
for dev in devs:
|
||||||
print(f"Flashing {dev}")
|
if dev not in done:
|
||||||
if flash(dev):
|
print(f"Flashing {dev}")
|
||||||
print(f"Flashed {dev}")
|
disp_string(dev.split("/")[2])
|
||||||
done.add(dev)
|
if flash(dev):
|
||||||
time.sleep(1)
|
print(f"Flashed {dev}")
|
||||||
|
disp_string("DONE")
|
||||||
|
time.sleep(.5)
|
||||||
|
done.add(dev)
|
||||||
|
time.sleep(1)
|
||||||
|
except BaseException as err:
|
||||||
|
disp_string("err")
|
||||||
Reference in New Issue
Block a user