# Buggy code
def devices_detailed(increment=""):
    if increment is None:
        raise FileNotFoundError(
            "guiscrcpy couldn't find adb. "
            "Please specify path to adb in configuration filename"
        )
    proc = Popen(_(increment + " devices -l"), stdout=PIPE)
    output = [[y.strip() for y in x.split()] for x in decode_process(proc)[1:]][:-1]
    devices_found = []
    for device in output:
        description = {
            "identifier": device[0],
            "status": device[1],
            "product": get(device, 2, ":").split(":")[-1],
            "model": get(device, 3, ":").split(":")[-1],
            "device": get(device, 4, ":").split(":")[-1],
            "transport_id": get(device, 5, ":").split(":")[-1],
        }
        devices_found.append(description)
    logging.debug("ADB: {}".format(devices_found))
    return devices_found


# Traceback (IndexError)
me@host:~$ Downloads/guiscrcpy-x86_64.AppImage


guiscrcpy
by srevinsaju
3.7.post195.dev
Licensed under GNU GPL v3 (c) 2020



MSG: Please ensure you have enabled USB Debugging on your device. See README.md for more details

(python3.8:31901): dbind-WARNING **: 10:21:56.701: Couldn't register with accessibility bus: Did not receive a reply. Possible causes include: the remote application did not send a reply, the message bus security policy blocked the reply, the reply timeout expired, or the network connection was broken.
Traceback (most recent call last):
File "/tmp/.mount_guiscrzbudZI/opt/python3.8/bin/guiscrcpy", line 9, in <module>
sys.exit(bootstrap())
File "/tmp/.mount_guiscrzbudZI/opt/python3.8/lib/python3.8/site-packages/guiscrcpy/launcher.py", line 1109, in bootstrap
bootstrap0()
File "/tmp/.mount_guiscrzbudZI/opt/python3.8/lib/python3.8/site-packages/guiscrcpy/launcher.py", line 1079, in bootstrap0
guiscrcpy = InterfaceGuiscrcpy()
File "/tmp/.mount_guiscrzbudZI/opt/python3.8/lib/python3.8/site-packages/guiscrcpy/launcher.py", line 337, in __init__
self.refresh_devices()
File "/tmp/.mount_guiscrzbudZI/opt/python3.8/lib/python3.8/site-packages/guiscrcpy/launcher.py", line 344, in refresh_devices
self.scan_devices_update_list_view()
File "/tmp/.mount_guiscrzbudZI/opt/python3.8/lib/python3.8/site-packages/guiscrcpy/launcher.py", line 625, in scan_devices_update_list_view
devices = adb.devices_detailed(adb.path)
File "/tmp/.mount_guiscrzbudZI/opt/python3.8/lib/python3.8/site-packages/guiscrcpy/lib/check.py", line 180, in devices_detailed
'product': get(device, 2, ':').split(':')[1],
IndexError: list index out of range

# Fixed code
def devices_detailed(increment=""):
    if increment is None:
        raise FileNotFoundError(
            "guiscrcpy couldn't find adb. "
            "Please specify path to adb in configuration filename"
        )
    proc = Popen(_(increment + " devices -l"), stdout=PIPE)
    output = [[y.strip() for y in x.split()] for x in decode_process(proc)[1:]][:-1]
    devices_found = []
    for device in output:
        # https://github.com/srevinsaju/guiscrcpy/issues/117
        if "udev" in device and "permission" in device:
            # This is an error with some linux and Windows OSes
            # This happens because the udev is not configured
            # and linux adb does not have access to reading the device
            # the status hence should be 'no_permission'
            status = "no_permission"
        else:
            status = device[1]
        description = {
            "identifier": device[0],
            "status": status,
            "product": get(device, 2, ":").split(":")[-1],
            "model": get(device, 3, ":").split(":")[-1],
            "device": get(device, 4, ":").split(":")[-1],
            "transport_id": get(device, 5, ":").split(":")[-1],
        }
        devices_found.append(description)
    logging.debug("ADB: {}".format(devices_found))
    return devices_found