fix tilda-tools bootstrap
parent
1ef5e7786f
commit
be985b3240
|
@ -29,6 +29,12 @@ def makedirs(path):
|
||||||
if not exists(path):
|
if not exists(path):
|
||||||
os.mkdir(path)
|
os.mkdir(path)
|
||||||
|
|
||||||
|
def isdir(path):
|
||||||
|
try:
|
||||||
|
return os.stat(path)[0] & 0o170000 == 0o040000
|
||||||
|
except OSError:
|
||||||
|
return False
|
||||||
|
|
||||||
def h(p):
|
def h(p):
|
||||||
try:
|
try:
|
||||||
with open(p, "rb") as f:
|
with open(p, "rb") as f:
|
||||||
|
@ -49,3 +55,18 @@ def w(p, c):
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(str(e))
|
print(str(e))
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
def clean(path=""):
|
||||||
|
for s in os.listdir(path):
|
||||||
|
full = "/".join([path, s]) if path else s
|
||||||
|
try:
|
||||||
|
if isdir(full):
|
||||||
|
try:
|
||||||
|
clean(full)
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
os.rmdir(full)
|
||||||
|
else:
|
||||||
|
os.remove(full)
|
||||||
|
except Exception as e:
|
||||||
|
print("Error while trying to clean '%s'" % full)
|
||||||
|
|
|
@ -187,4 +187,32 @@ def end_copy_via_repl(args):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def clean_via_repl(args):
|
def clean_via_repl(args):
|
||||||
raise Exception("not implemented yet")
|
init_copy_via_repl(args)
|
||||||
|
print("Cleaning:", end=" ", flush=True)
|
||||||
|
try:
|
||||||
|
execbuffer(get_pyb(args), "clean()")
|
||||||
|
except PyboardError as er:
|
||||||
|
print("FAIL")
|
||||||
|
print(er)
|
||||||
|
pyb.close()
|
||||||
|
sys.exit(1)
|
||||||
|
print("DONE")
|
||||||
|
|
||||||
|
def hard_reset(args):
|
||||||
|
pyb = get_pyb(args)
|
||||||
|
print("Hard reset:", end=" ", flush=True)
|
||||||
|
try:
|
||||||
|
pyb.enter_raw_repl()
|
||||||
|
execbuffer(pyb, "import machine\nmachine.reset()\n")
|
||||||
|
print("UNEXPECTED")
|
||||||
|
except PyboardError as er:
|
||||||
|
print("FAIL")
|
||||||
|
print(er)
|
||||||
|
pyb.close()
|
||||||
|
sys.exit(1)
|
||||||
|
except Exception as e:
|
||||||
|
if "Errno 6" in str(e):
|
||||||
|
print("DONE")
|
||||||
|
else:
|
||||||
|
raise e
|
||||||
|
|
||||||
|
|
|
@ -58,9 +58,7 @@ def sync(args, patterns, resources, verbose, skip_wifi):
|
||||||
return synced_resources
|
return synced_resources
|
||||||
|
|
||||||
def clean(args):
|
def clean(args):
|
||||||
print("Cleaning:", end=" ", flush=True)
|
|
||||||
pyboard_util.clean_via_repl(args)
|
pyboard_util.clean_via_repl(args)
|
||||||
print("DONE")
|
|
||||||
|
|
||||||
def set_boot_app(args, app_to_boot):
|
def set_boot_app(args, app_to_boot):
|
||||||
content = app_to_boot + "\n"
|
content = app_to_boot + "\n"
|
||||||
|
|
|
@ -119,7 +119,7 @@ def main():
|
||||||
if command == "bootstrap":
|
if command == "bootstrap":
|
||||||
sync.clean(args)
|
sync.clean(args)
|
||||||
sync.sync(args, ["bootstrap.py"], {}, args.verbose, args.skip_wifi)
|
sync.sync(args, ["bootstrap.py"], {}, args.verbose, args.skip_wifi)
|
||||||
pyboard_util.soft_reset(args)
|
pyboard_util.hard_reset(args)
|
||||||
|
|
||||||
if command == "sync":
|
if command == "sync":
|
||||||
if args.clean:
|
if args.clean:
|
||||||
|
|
6
boot.py
6
boot.py
|
@ -1,5 +1,6 @@
|
||||||
import os, tilda
|
import os, tilda
|
||||||
|
|
||||||
|
print("EMF: boot.py")
|
||||||
os.sync()
|
os.sync()
|
||||||
root = os.listdir()
|
root = os.listdir()
|
||||||
|
|
||||||
|
@ -23,9 +24,12 @@ def any_home():
|
||||||
return h[0] if len(h) else False
|
return h[0] if len(h) else False
|
||||||
|
|
||||||
if "no_boot" in root:
|
if "no_boot" in root:
|
||||||
|
print("no_boot found, aborting boot sequence")
|
||||||
|
else:
|
||||||
start = None
|
start = None
|
||||||
if "main.py" in root:
|
if "main.py" in root:
|
||||||
start = "main.py"
|
start = "main.py"
|
||||||
start = file("once.txt", True) or file("default_app.txt", False) or any_home() or "bootstrap.py"
|
start = start or file("once.txt", True) or file("default_app.txt", False) or any_home() or "bootstrap.py"
|
||||||
print("Booting into %s" % start)
|
print("Booting into %s" % start)
|
||||||
tilda.main(start)
|
tilda.main(start)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue