diff --git a/flash.py b/flash.py old mode 100755 new mode 100644 index 7934f68..da360a0 --- a/flash.py +++ b/flash.py @@ -8,11 +8,13 @@ import time import fourletterphat as flp import os import tempfile +from shutil import copyfile #-- q = Queue() t = loader.bgload(3, .1) IMAGE = "image.img" +PWD = os.getcwd() #-- def disp_string(string): @@ -40,8 +42,10 @@ def get_mounted_devs(): def flash(dev): loader.q.put(dev) try: - flash_cmd = ["/bin/dd", f"if=./{IMAGE}", f"of={dev}"] - output = subprocess.check_output(flash_cmd).decode("utf-8") + flash_cmd = ["/bin/dd", f"if={IMAGE}", f"of={dev}"] + + subprocess.run(flash_cmd) + with tempfile.TemporaryDirectory() as tempdir: mount_cmd = ["mount",f"{dev}2", tempdir] umount_cmd = ["umount", tempdir] @@ -49,12 +53,16 @@ def flash(dev): subprocess.run(mount_cmd) os.chdir(tempdir) os.mkdir("ssh") + os.chdir(PWD) + copyfile("wpa_supplicant.conf", tempdir) subprocess.run(umount_cmd) return True + except BaseException as err: print(err) disp_string('ERR') + finally: loader.q.get() diff --git a/wpa_supplicant.conf b/wpa_supplicant.conf new file mode 100644 index 0000000..6039430 --- /dev/null +++ b/wpa_supplicant.conf @@ -0,0 +1,9 @@ +country=us +update_config=1 +ctrl_interface=/var/run/wpa_supplicant + +network={ + scan_ssid=1 + ssid="ssid" + psk="password" +}