[FIX] Fix disk type on Windows
This commit is contained in:
parent
21324b62f1
commit
0ffe7d07df
@ -86,10 +86,13 @@ class App:
|
||||
import wmi
|
||||
c = wmi.WMI()
|
||||
self.drives = []
|
||||
ws = wmi.WMI(namespace='root/Microsoft/Windows/Storage')
|
||||
drives_mt = ws.MSFT_PhysicalDisk()
|
||||
if disks := c.Win32_DiskDrive():
|
||||
for disk in disks:
|
||||
self.drives.append(Drive(disk.Model, disk.Name, disk.InterfaceType, disk.DefaultBlockSize, int(
|
||||
disk.Size), disk.SerialNumber, disk.Index))
|
||||
for drive in drives_mt:
|
||||
if disk.Index == int(drive.DeviceId):
|
||||
self.drives.append(Drive(disk.Model, disk.Name, drive.MediaType, disk.DefaultBlockSize, int(disk.Size), disk.SerialNumber, disk.Index))
|
||||
elif self.OS_TYPE == "Linux":
|
||||
from diskinfo import DiskInfo
|
||||
di = DiskInfo()
|
||||
|
||||
@ -29,6 +29,13 @@ erasing_methods = {
|
||||
}
|
||||
}
|
||||
|
||||
win_types = {
|
||||
0: "Unspecified",
|
||||
3: "HDD",
|
||||
4: "SSD",
|
||||
5: "SCM"
|
||||
}
|
||||
|
||||
def get_random_bytes(size):
|
||||
seed=os.urandom(32)
|
||||
backend = default_backend()
|
||||
@ -56,7 +63,10 @@ class Drive():
|
||||
|
||||
def __init__(self, name, path, disk_type, block_size, capacity, dev_id, index):
|
||||
self.name = name
|
||||
self.disk_type = disk_type
|
||||
if isinstance(disk_type, int):
|
||||
self.disk_type = win_types[disk_type]
|
||||
else:
|
||||
self.disk_type = disk_type
|
||||
self.path = path
|
||||
if block_size is not None:
|
||||
self.block_size = block_size
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user