-
Notifications
You must be signed in to change notification settings - Fork 18
/
sdumount.py
38 lines (32 loc) · 984 Bytes
/
sdumount.py
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
from sys import implementation
from pydos_hw import Pydos_hw
if implementation.name.upper() == "MICROPYTHON":
from os import umount
elif implementation.name.upper() == "CIRCUITPYTHON":
from storage import umount
drive = "/sd"
if __name__ != "PyDOS":
passedIn = ""
envVars = {}
if passedIn != "":
drive = passedIn
if drive[0] != '/':
drive = '/'+drive
unmounted = False
for i in range(len(Pydos_hw.SDdrive)):
if drive == Pydos_hw.SDdrive[i]:
umount(drive)
unmounted = True
if Pydos_hw.SD[i]: # Micropython doesn't use Pydos_hw.SD
if 'deinit' in dir(Pydos_hw.SD[i]):
Pydos_hw.SD[i].deinit()
Pydos_hw.SD[i] = None
Pydos_hw.SDdrive[i] = None
break
if not unmounted and drive != '/':
try:
umount(drive)
except:
print("Mount point "+drive+" not found.")
elif drive == '/':
print("Can't umount root folder")