Skip to content

Commit

Permalink
system: get_usb_devices(): refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
Obijuan committed Mar 4, 2024
1 parent a626d27 commit 4d57e5f
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions apio/managers/system.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,13 @@ def lsserial():

def get_usb_devices(self) -> list:
"""Return a list of the connected USB devices
This list is obtained by running the "lsusb" command
This list is obtained by running the "lsusb" command
* OUTPUT: A list of objects with the usb devices
Ex. [{'hwid':'1d6b:0003'}, {'hwid':'8087:0aaa'}, ...]
It raises an exception in case of not being able to
execute the "lsusb" command
"""

# -- Initial empty usb devices list
Expand All @@ -105,12 +111,12 @@ def get_usb_devices(self) -> list:
# -- Ex: [{'hwid':'1d6b:0003'}, {'hwid':'04f2:b68b'}...]
usb_devices = self._parse_usb_devices(result["out"])

# -- Return the devices
return usb_devices

# -- It was not possible to run the "lsusb" command
# -- for reading the usb devices
else:
raise RuntimeError("Error executing lsusb")

return usb_devices
raise RuntimeError("Error executing lsusb")

def get_ftdi_devices(self):
"""DOC: TODO"""
Expand Down

0 comments on commit 4d57e5f

Please sign in to comment.