You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
echo" with open('${PERSISTENT_FILE_FOR_UNPACK}', 'w') as f:">>${BOOT_FILE}
113
-
echo" f.write('Hi! Delete this file to restore the ${FROZEN_EXAMPLES_UNPACKED_DIR} to its default state. WARNING: This will override ALL of your changes to that directory.')">>${BOOT_FILE}
114
-
115
-
# Now, copy the unpacked frozen data filesystem to a mutable location if the source and destination are provided
116
-
# Simple recursive function to copy the directory tree (since i.e. shutil.copytree is not available on MicroPython)
117
-
if [ -n"$SOURCE_DIR" ] && [ -n"$DESTINATION_DIR" ];then
118
-
echo"Copying frozen data from ${SOURCE_DIR} to ${DESTINATION_DIR} in _boot.py"
119
-
local BOOT_FILE="micropython/ports/${TARGET_PORT_NAME}/modules/_boot.py"
120
-
echo" def copytree(src, dst):">>${BOOT_FILE}
121
-
echo" try:">>${BOOT_FILE}
122
-
echo" os.mkdir(dst)">>${BOOT_FILE}
123
-
echo" except OSError:">>${BOOT_FILE}
124
-
echo" pass">>${BOOT_FILE}
125
-
echo" for entry in os.ilistdir(src):">>${BOOT_FILE}
# Finally, unmount the source directory if it is mounted
137
-
echo" try:">>${BOOT_FILE}
138
-
echo" os.umount('/${SOURCE_DIR}')">>${BOOT_FILE}
139
-
echo" except Exception as e:">>${BOOT_FILE}
140
-
echo" print('umount failed:', e)">>${BOOT_FILE}
141
-
fi
112
+
echo" f.write('Hi! Delete this file and reset your board to restore the ${FROZEN_EXAMPLES_UNPACKED_DIR} directory to its default state. WARNING: This will override ALL of your changes to that directory.')">>${BOOT_FILE}
142
113
143
-
# If the ADD_TO_SYSPATH flag is true, add the destination directory to sys.path
144
-
if [ "$ADD_TO_SYSPATH"=true ];then
145
-
echo"Adding ${DESTINATION_DIR} to sys.path in _boot.py"
114
+
# If a destination directory is provided, we will add it to the sys.path so that the modules in the unpacked directory can be imported
115
+
if [ -n"$UNPACKED_DIR" ];then
116
+
echo"Adding ${UNPACKED_DIR} to sys.path in _boot.py"
# Add necessary content to the boot.py file to unpack the frozen data filesystem on boot
176
147
# Provide the source and destination directories to copy the frozen data filesystem to a mutable (and non-hidden) location
177
148
# Provide "true" as the last argument to add the destination directory to sys.path (since our examples directory contains modules that we want to be importable...)
0 commit comments