2018-07-27 18:35:39 -04:00
|
|
|
import pyb, os, micropython, sys
|
2018-07-15 06:53:48 -04:00
|
|
|
|
|
|
|
micropython.alloc_emergency_exception_buf(100)
|
|
|
|
|
2018-07-27 18:35:39 -04:00
|
|
|
sys.path.append('/flash/upip')
|
|
|
|
|
2018-07-16 18:04:42 -04:00
|
|
|
os.sync()
|
2018-07-15 06:53:48 -04:00
|
|
|
root = os.listdir()
|
|
|
|
|
|
|
|
def app(a):
|
|
|
|
if (a in root) and ("main.py" in os.listdir(a)):
|
|
|
|
return a + "/main.py"
|
|
|
|
|
|
|
|
def file(file, remove):
|
2018-07-16 18:04:42 -04:00
|
|
|
print(file)
|
2018-07-15 06:53:48 -04:00
|
|
|
try:
|
2018-07-16 18:04:42 -04:00
|
|
|
a = None
|
2018-07-15 06:53:48 -04:00
|
|
|
with open(file, 'r') as f:
|
|
|
|
a = f.read().strip()
|
2018-07-16 18:04:42 -04:00
|
|
|
if remove:
|
|
|
|
os.remove(file)
|
|
|
|
return app(a)
|
2018-07-15 06:53:48 -04:00
|
|
|
except Exception as e:
|
|
|
|
print(e)
|
|
|
|
|
|
|
|
def any_home():
|
|
|
|
return app(next(a for a in root if a.startswith("home")))
|
|
|
|
|
2018-08-05 17:14:31 -04:00
|
|
|
if "no_boot" in root:
|
|
|
|
os.remove("no_boot")
|
|
|
|
else:
|
|
|
|
start = None
|
|
|
|
if "main.py" in root:
|
|
|
|
start = "main.py"
|
|
|
|
start = file("once.txt", True) or file("default_app.txt", False) or any_home() or "bootstrap.py"
|
|
|
|
|
|
|
|
pyb.main(start)
|