def send_keys(session, keys, literal=True):
    """Send keys to a tmux session.
    This function is a wrapper around tmux's ``send-keys`` command.

    If ``literal`` is ``False``, tmux will attempt to convert keynames such as
    ``Escape`` or ``Space`` to their single-key equivalents.

    :param session: name of a tmux session
    :param keys: keystrokes to send to the tmux session
    :param literal: whether to prevent tmux from looking up keynames
    """

    args = ["tmux", "send-keys"]

    if literal:
        args.append('-l')

    args.append("-t{}".format(session))
    args.append(keys)

    cmd = ' '.join(args)

    logger.debug('Sending keys with command: %s', cmd)
    try:
        subprocess.check_output(args, stderr=subprocess.STDOUT)
    except subprocess.CalledProcessError as exc:
        output = exc.output.decode(locale.getdefaultlocale()[1])
        if 'session not found' in output:
            raise SessionNotFoundError(exc.returncode, cmd, exc.output,
                                       session=session)
        elif 'failed to connect to server' in output:
            raise ConnectionFailedError(exc.returncode, cmd, exc.output)
        else:
            raise
dataset/ETHPy150Open ddbeck/oraide/oraide/__init__.py/send_keys/original