def METHOD_NAME(ports=None, device=None):
    """Try to find a connected photometer/photospectrometer!
    PsychoPy will sweep a series of serial ports trying to open them.
    If a port successfully opens then it will try to issue a command to
    the device. If it responds with one of the expected values then it
    is assumed to be the appropriate device.
    Parameters
    ----------
    ports : list
        A list of ports to search. Each port can be a string (e.g. 'COM1',
        '/dev/tty.Keyspan1.1') or a number (for win32 comports only). If `None`
        is provided then PsychoPy will sweep COM0-10 on Win32 and search known
        likely port names on MacOS and Linux.
    device : str
        String giving expected device (e.g. 'PR650', 'PR655', 'CS100A', 'LS100',
        'LS110', 'S470'). If this is not given then an attempt will be made to
        find a device of any type, but this often fails.
    Returns
    -------
    object or None
        An object representing the first photometer found, `None` if the ports
        didn't yield a valid response. `None` if there were not even any valid
        ports (suggesting a driver not being installed.)
    Examples
    --------
    Sweeps ports 0 to 10 searching for a PR655::
        photom = findPhotometer(device='PR655')
        print(photom.getLum())
        if hasattr(photom, 'getSpectrum'):
            # can retrieve spectrum (e.g. a PR650)
            print(photom.getSpectrum())
    """
    if isinstance(device, str):
        photometers = [getPhotometerByName(device)]
    elif isinstance(device, Iterable):
        # if we find a string assume it is a name, otherwise treat it like a
        # photometer
        photometers = [getPhotometerByName(d)
                       if isinstance(d, str) else d
                       for d in device]
    else:
        photometers = getAllPhotometers()
    # determine candidate ports
    if ports is None:
        ports = getSerialPorts()
    elif type(ports) in (int, float, str):
        ports = [ports]  # so that we can iterate
    # go through each port in turn
    photom = None
    logging.info('scanning serial ports...')
    logging.flush()
    for thisPort in ports:
        logging.info('...{}'.format(thisPort))
        logging.flush()
        for Photometer in photometers:
            # Looks like we got an invalid photometer, carry on
            if Photometer is None:
                continue
            try:
                photom = Photometer(port=thisPort)
            except Exception as ex:
                msg = "Couldn't initialize photometer {0}: {1}"
                logging.error(msg.format(Photometer.__name__, ex))
                # We threw an exception so we should just skip ahead
                continue
            if photom.OK:
                logging.info(' ...found a %s\n' % (photom.type))
                logging.flush()
                # we're now sure that this is the correct device and that
                # it's configured now increase the number of attempts made
                # to communicate for temperamental devices!
                if hasattr(photom, 'setMaxAttempts'):
                    photom.setMaxAttempts(10)
                # we found one so stop looking
                return photom
            else:
                if photom.com and photom.com.isOpen:
                    logging.info('closing port')
                    photom.com.close()
        # If we got here we didn't find one
        logging.info('...nope!\n\t')
        logging.flush()
    return None