def sanitize_output(input_str, uses_pty=False):
    """
    Function which sanitizes paramiko output (stdout / stderr).

    It strips trailing carriage return and new line characters and if pty is used, it also replaces
    all occurrences of \r\n with \n.

    By default when pty is used, all \n characters are convered to \r\n and that's not desired
    in our remote runner action output.

    :param input_str: Input string to be sanitized.
    :type input_str: ``str``

    :rtype: ``str``

    """
    output = strip_shell_chars(input_str)

    if uses_pty:
        output = output.replace("\r\n", "\n")

    return output

    Function which sanitizes paramiko output (stdout / stderr).

    It strips trailing carriage return and new line characters and if pty is used, it also replaces
    all occurrences of 
 with 
.

    By default when pty is used, all 
 characters are convered to 
 and that's not desired
    in our remote runner action output.

    :param input_str: Input string to be sanitized.
    :type input_str: ``str``

    :rtype: ``str``

    
st2common/st2common/util/misc.py