-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMount.py
More file actions
31 lines (25 loc) · 946 Bytes
/
Copy pathMount.py
File metadata and controls
31 lines (25 loc) · 946 Bytes
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
import psutil
import platform
#only for linux and windows
def get_mounted_drives():
os_name=platform.system() #this will detect os
drive_list = []
partition_list = psutil.disk_partitions() #get partition list
if os_name.lower() =="windows":
for partition in partition_list:
drive_list.append(partition.mountpoint)
return drive_list
elif os_name.lower() == "linux":
#drive_list.append("/") #uncomment this to mount root
drive_list.append("/home/") #adding mount point manually
for partition in partition_list:
mount=partition.mountpoint
#most of the relavent mount point found in "/media/" .tested in ubuntu
if "/media/" in mount:
drive_list.append(mount)
return drive_list
else:
print("Something Wrong with mounted drive")
if __name__=="__main__" :
z=get_mounted_drives()
print((z))