I have the logical paths. For instance:- path1='C:/abc', path2='E:/xyz'
I want to check if both of them reside on same physical disk.
Or in general I want to map a logical path to associated physical drives.
I would also want to do the same for linux. For now I use "os.stat(path).st_dev" to get the device id. But the id seems to be different for logical disks on same same physical drive. So it doesn't actully work for me. Is there a better or direct solution to it.
This solved my problem
key = ''
for physical_disk in w.Win32_DiskDrive():
logical_disks = []
for partition in physical_disk.associators ("Win32_DiskDriveToDiskPartition"):
for logical_disk in partition.associators ("Win32_LogicalDiskToPartition"):
key = logical_disk.Description
if key not in all_logical_disks:
all_logical_disks[key] = []
logical_disks.append(logical_disk.Caption)
if logical_disks:
all_logical_disks[key].append(logical_disks)
This helped me to get a dict of type: {u'Local Fixed Disk': [[u'C:', u'D:'],[u'E:', u'F:']]} which grouped logical patitions in different physical disks. Now I can compare if the logical paths lie in the same list.