change back to previous working dir
This commit is contained in:
12
flash.py
Executable file → Normal file
12
flash.py
Executable file → Normal file
@@ -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()
|
||||
|
||||
|
||||
9
wpa_supplicant.conf
Normal file
9
wpa_supplicant.conf
Normal file
@@ -0,0 +1,9 @@
|
||||
country=us
|
||||
update_config=1
|
||||
ctrl_interface=/var/run/wpa_supplicant
|
||||
|
||||
network={
|
||||
scan_ssid=1
|
||||
ssid="ssid"
|
||||
psk="password"
|
||||
}
|
||||
Reference in New Issue
Block a user