Skip to content

Commit

Permalink
q-dev: less scary device category names
Browse files Browse the repository at this point in the history
  • Loading branch information
piotrbartman committed Oct 29, 2024
1 parent ca725e7 commit a627696
Showing 1 changed file with 20 additions and 7 deletions.
27 changes: 20 additions & 7 deletions qubesadmin/device_protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -655,7 +655,7 @@ class DeviceCategory(Enum):
)
Wireless = ("ue0****", "p0d****")
Bluetooth = ("ue00101", "p0d11**")
Mass_Data = ("b******", "u08****", "p01****")
Storage = ("b******", "u08****", "p01****")
Network = ("p02****",)
Memory = ("p05****",)
PCI_Bridge = ("p06****",)
Expand Down Expand Up @@ -770,23 +770,28 @@ def __str__(self):
"no subclass",
"unused",
"undefined",
"vendor specific subclass",
):
# if not, try interface
result = self._load_classes(self.devclass).get(
self._interface_encoding[1:], None
)
if result is None or result.lower() in (
"none",
"no subclass",
"unused",
"undefined",
):
# if not, try class
result = self._load_classes(self.devclass).get(
self._interface_encoding[1:-4] + "****", None
)
if result is None:
result = f"Unclassified {self.devclass} device"
if result is None or result.lower() in (
"none",
"unused",
"undefined",
"vendor specific class",
):
result = f"{self.devclass.upper()} device"
return result
if self.devclass == "mic":
return "Microphone"
Expand Down Expand Up @@ -974,9 +979,17 @@ def description(self) -> str:
else:
vendor = "unknown vendor"

cat = self.interfaces[0].category.name
if cat == "Other":
cat = str(self.interfaces[0])
for interface in self.interfaces:
if interface.category.name != "Other":
cat = interface.category.name
break
else:
for interface in self.interfaces:
if str(interface) != f"{self.devclass.upper()} device":
cat = str(interface)
break
else:
cat = f"{self.devclass.upper()} device"
return f"{cat}: {vendor} {prod}"

@property
Expand Down

0 comments on commit a627696

Please sign in to comment.