[NEW] Base class for drives
This commit is contained in:
parent
287ab4588d
commit
684a56ca67
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
venv
|
||||
__pycache__
|
||||
25
main.py
Normal file
25
main.py
Normal file
@ -0,0 +1,25 @@
|
||||
from utils.utils_drive import Drive
|
||||
from utils.globals import *
|
||||
|
||||
|
||||
if OS_TYPE == "Windows":
|
||||
import wmi
|
||||
c = wmi.WMI()
|
||||
drives = []
|
||||
if disks := c.Win32_DiskDrive():
|
||||
for disk in disks:
|
||||
drives.append(Drive(disk.Model, disk.Name, disk.InterfaceType, disk.DefaultBlockSize, int(disk.Size)))
|
||||
elif OS_TYPE == "Linux":
|
||||
import subprocess
|
||||
|
||||
# Execute the lsblk command to get information about block devices
|
||||
result = subprocess.run(['lsblk', '-o', 'NAME,SIZE,MODEL,VENDOR,TRAN'], capture_output=True, text=True)
|
||||
|
||||
# Get the output
|
||||
output = result.stdout
|
||||
|
||||
# Вывод информации о дисках
|
||||
print(output)
|
||||
|
||||
# for drive in drives:
|
||||
# print(f"{drive.name} | {drive.path} | {drive.disk_type} | {drive.block_size} | {drive.capacity}")
|
||||
3
utils/globals.py
Normal file
3
utils/globals.py
Normal file
@ -0,0 +1,3 @@
|
||||
import platform
|
||||
|
||||
OS_TYPE = platform.system()
|
||||
27
utils/utils_drive.py
Normal file
27
utils/utils_drive.py
Normal file
@ -0,0 +1,27 @@
|
||||
from utils.globals import OS_TYPE
|
||||
|
||||
class Drive():
|
||||
|
||||
path: str
|
||||
|
||||
total_sectors: str
|
||||
|
||||
disk_type = None
|
||||
|
||||
name: str
|
||||
|
||||
block_size: int = 512
|
||||
|
||||
capacity: int
|
||||
|
||||
def __init__(self, name , path, disk_type, block_size, capacity):
|
||||
self.name = name
|
||||
self.disk_type = disk_type
|
||||
self.path = path
|
||||
if block_size is not None:
|
||||
self.block_size = block_size
|
||||
self.capacity = capacity
|
||||
|
||||
def erase(self):
|
||||
pass
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user