Update flash.py
This commit is contained in:
35
flash.py
35
flash.py
@@ -2,11 +2,20 @@
|
||||
|
||||
import subprocess
|
||||
import time
|
||||
import fourletterphat as flp
|
||||
|
||||
#--
|
||||
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():
|
||||
return [item[item.find("/"):] for item in subprocess.check_output(
|
||||
["/bin/bash", "-c", "lsblk"]).decode("utf-8").split("\n") if "/" in item]
|
||||
@@ -27,14 +36,22 @@ def flash(dev):
|
||||
print(output)
|
||||
return True
|
||||
|
||||
disp_string("GO")
|
||||
|
||||
done = set()
|
||||
while True:
|
||||
devs = get_mounted_devs()
|
||||
done = done.intersection(devs)
|
||||
for dev in devs:
|
||||
if dev not in done:
|
||||
print(f"Flashing {dev}")
|
||||
if flash(dev):
|
||||
print(f"Flashed {dev}")
|
||||
done.add(dev)
|
||||
time.sleep(1)
|
||||
try:
|
||||
devs = get_mounted_devs()
|
||||
done = done.intersection(devs)
|
||||
for dev in devs:
|
||||
if dev not in done:
|
||||
print(f"Flashing {dev}")
|
||||
disp_string(dev.split("/")[2])
|
||||
if flash(dev):
|
||||
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