def validate_port(ports):
    """Validate a port string supplied by the user

    Parameters
    ----------
    ports : str
    	Must be: the string all
        A numeric port number
        A comma separated list of numbers
        	converted to a list for blacklist code use

    Returns
    -------
    tuple
        bool True/False
            True if OK, False if error
        str
            Returned value or  Error
    """

    ports = ports.strip()
    if not any(ports):
        return (False, 'Ports cannot be empty')
    plist = (l.strip() for l in ports.split(','))
    slist = (l for l in plist if l != '')
    out = []
    for p in slist:
        if p == 'all':
            return (True, 'all')
        try:
            pi = int(p)
            out.append(pi)
        except ValueError:
            return (False, f'Non-numeric port value found {p}')

    # make ordered list with no duplicates
    # ports are already ints
    ordered = sorted(list(set(out)))
    return (True, ordered)