Repository navigation
Expand file tree
/
Copy pathboot.py
More file actions
69 lines (55 loc) · 1.56 KB
/
Copy pathboot.py
File metadata and controls
69 lines (55 loc) · 1.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
import sys, wifi, socketpool, time, os, json, microcontroller, storage
import digitalio, board
try: import ampule
except: pass
try:
import load_settings
settings = load_settings.settings()
except: pass
if not "S2" in os.uname().machine: # Träskylt:
try:
from load_screen import *
import check_button
from check_button import *
# from check_button import check_if_button_pressed
except:
def pprint(text, line=0,color=0):
return
def time_button(): return
else:
def pprint(text, line=0,color=0): return
def time_button(): return
def boot_splash():
pprint("Booting...", line=0, color="white")
def check_if_button_pressed_on_boot():
try:
return time_button()
except Exception as e:
print(e)
return 1
def lock():
storage.disable_usb_drive()
storage.remount("/", False)
boot_splash()
if "unlock" in os.listdir():
lock()
try: os.remove("unlock")
except: pass
storage.enable_usb_drive()
pprint("Unlocking filesystem", line=1, color="red")
time.sleep(1)
elif check_if_button_pressed_on_boot():
pprint("Unlocking filesystem", line=1, color="red")
time.sleep(1)
else:
lock()
pprint("Hold to unlock", line=1, color="green")
#pprint("Locked filesystem")
time.sleep(1)
try: os.remove("code.py")
except: pass
try: os.remove("reboot_required")
except: pass
#try: clearscreen(True)
#except Exception as e: pprint(str(e))
#while True: pass