Skip to content

TypeError from extract_udevadm_info #90

@hello-binit

Description

@hello-binit

The stretch_factory.hello_device_utils.extract_udevadm_info() method throws a TypeError if it's unable to find the provided port. Minimal reproducible example:

import stretch_factory.hello_device_utils as hdu
hdu.extract_udevadm_info('/dev/gibberish')

The exception is:

TypeError                                 Traceback (most recent call last)
<ipython-input-5-891b81f5b8aa> in <module>
----> 1 hdu.extract_udevadm_info('/dev/gibberish')

~/.local/lib/python3.10/site-packages/stretch_factory/hello_device_utils.py in extract_udevadm_info(usb_port, ID_NAME)
    577     value = None
    578     dname = bytes(usb_port[5:], 'utf-8')
--> 579     out = exec_process([b'udevadm', b'info', b'-n', dname], True)
    580     if ID_NAME is None:
    581         value = out.decode(encoding='UTF-8')

~/.local/lib/python3.10/site-packages/stretch_factory/hello_device_utils.py in exec_process(cmdline, silent, input, **kwargs)
     80     if returncode != 0:
     81         raise RuntimeError('Got return value %d while executing "%s", stderr output was:\n%s' % (
---> 82         returncode, " ".join(cmdline), stderr.rstrip(b"\n")))
     83     return stdout
     84 

TypeError: sequence item 0: expected str instance, bytes found

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions