from threading import * class Drive(): index: int = None path: str total_sectors: str disk_type = None name: str block_size: int = 512 capacity: int serial_num = None def __init__(self, name, path, disk_type, block_size, capacity, dev_id, index): 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 self.serial_num = dev_id self.index = index def erase(self, progress=0) -> Thread: t = Thread(target=self.__erasing, args=(progress,)) t.start() return t def __erasing(self, progress): len_write = 0 with open(self.path, 'wb') as drive: while len_write < self.capacity: # drive.write(b"\x00"*self.block_size) len_write += self.block_size*64 progress['value'] = int(len_write/self.capacity * 100)