Is there a way in Python to distinguish on macOS
- mounted external hard drives (for example, an external hard disk connected through a USB or USB flash drive)
- from network-mounted drives (through SMB)?
I tried
>>> import os
>>> for directory in os.listdir("/Volumes"):
... print(directory, os.path.ismount(os.path.join("/Volumes", directory)))
...
Macintosh HD-1 True
admin True
G-DRIVE_ArmorATD True
Macintosh HD False
>>>
However, os.path.ismount() is returning True for all mounted volumes, including a computer I'm connected to over a network (Macintosh HD-1).
How do I tell the difference between an external hard drive and a computer over the network? Or is there a better way I should do this?