-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcopytree.py
More file actions
22 lines (20 loc) · 826 Bytes
/
copytree.py
File metadata and controls
22 lines (20 loc) · 826 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# Run this on the device via REPL
import os
def copytree(src, dst):
# dst is a host-side path, we send one file at a time via host script
# but for simplicity we'll just print what needs to be copied
# → you will run mpremote cp manually for each file
for entry in os.listdir(src):
s = src + '/' + entry if src != '/' else '/' + entry
try:
st = os.stat(s)
if st[0] & 0o170000 == 0o040000: # is directory
print(f"DIR {s}")
copytree(s, dst) # recurse
else:
print(f"FILE {s}")
# → copy this file manually from host:
# mpremote cp ":{s}" "{dst}/{entry}"
except OSError:
pass # skip broken symlinks / permission issues
copytree('/lib', '')