Added methods vendor_code and device_code.
This commit is contained in:
parent
6cc3a29828
commit
605b40a8f7
|
|
@ -14,6 +14,16 @@ class PciDevice:
|
||||||
def is_vga(self) -> bool:
|
def is_vga(self) -> bool:
|
||||||
return exists(f"/sys/bus/pci/devices/{self.device_id}/boot_vga")
|
return exists(f"/sys/bus/pci/devices/{self.device_id}/boot_vga")
|
||||||
|
|
||||||
|
def vendor_code(self, remove_prefix: bool = True) -> str:
|
||||||
|
with open(f"/sys/bus/pci/devices/{self.device_id}/vendor") as vendor:
|
||||||
|
return vendor.read() if not remove_prefix else vendor.read(
|
||||||
|
).lstrip("0x")
|
||||||
|
|
||||||
|
def device_code(self, remove_prefix: bool = True) -> str:
|
||||||
|
with open(f"/sys/bus/pci/devices/{self.device_id}/vendor") as device:
|
||||||
|
return device.read() if not remove_prefix else device.read(
|
||||||
|
).lstrip("0x")
|
||||||
|
|
||||||
def unbind_driver(self):
|
def unbind_driver(self):
|
||||||
with open(f"/sys/bus/pci/devices/{self.device_id}/driver/unbind",
|
with open(f"/sys/bus/pci/devices/{self.device_id}/driver/unbind",
|
||||||
"w") as device_driver:
|
"w") as device_driver:
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue