Add function to access the paths of the files

This commit is contained in:
Hoang Hong Quan
2024-10-01 23:45:52 +07:00
parent af2dbcb3c5
commit 3da550a636
2 changed files with 13 additions and 1 deletions

View File

@@ -16,6 +16,7 @@ class WindowsHardwareInfo:
self.classify_gpu = gpu_identifier.GPUIdentifier().classify_gpu
self.get_device_location_paths = device_locator.WindowsDeviceLocator().get_device_location_paths
self.utils = utils.Utils()
self.usb_ids = self.utils.read_file(self.utils.get_full_path("Scripts", "datasets", "usb.ids"))
def parse_device_path(self, device_path):
if "VEN" in device_path:
@@ -341,7 +342,10 @@ class WindowsHardwareInfo:
seen_ids.add(device_info.get("Device ID"))
if not device_info.get("Bus Type") in ("ACPI"):
device_name = self.utils.usb_ids.get(device_info.get("Device ID")[:4], {}).get("devices", {}).get(device_info.get("Device ID")[5:]) or device_name
try:
device_name = self.usb_ids.get(device_info.get("Device ID")[:4]).get("devices")[device_info.get("Device ID")[5:]]
except:
pass
device_info["Bus Type"] = "USB"
del device_info["Device Type"]
else:

View File

@@ -10,6 +10,14 @@ class Utils:
def __init__(self, script_name = "Hardware Sniffer"):
self.script_name = script_name
def get_full_path(self, *path):
if getattr(sys, 'frozen', False):
base_path = sys._MEIPASS
else:
base_path = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
return os.path.join(base_path, *path)
def write_file(self, file_path, data):
file_extension = os.path.splitext(file_path)[1]