def determine_socket(path=default_path):
    """Determine the socket with which to connect."""
    sockets = list_sockets(path)

    if not len(sockets):
        return None

    if len(sockets) == 1:
        return os.path.join(path, sockets[0])
    
    try:
        import dialog
        # If we aren't running from within TM use the first socket found.
    except __HOLE__:
        sock = sockets[0]
    else:
        sock = dialog.menu(sockets)            

    return os.path.join(path, sock)
dataset/ETHPy150Open mattfoster/ipython-tmbundle/Support/lib/ipythonClient.py/determine_socket