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
(input_str, uses_pty=False)
| 70 | |
| 71 | |
| 72 | def sanitize_output(input_str, uses_pty=False): |
| 73 | """ |
| 74 | Function which sanitizes paramiko output (stdout / stderr). |
| 75 | |
| 76 | It strips trailing carriage return and new line characters and if pty is used, it also replaces |
| 77 | all occurrences of \r\n with \n. |
| 78 | |
| 79 | By default when pty is used, all \n characters are convered to \r\n and that's not desired |
| 80 | in our remote runner action output. |
| 81 | |
| 82 | :param input_str: Input string to be sanitized. |
| 83 | :type input_str: ``str`` |
| 84 | |
| 85 | :rtype: ``str`` |
| 86 | |
| 87 | """ |
| 88 | output = strip_shell_chars(input_str) |
| 89 | |
| 90 | if uses_pty: |
| 91 | output = output.replace("\r\n", "\n") |
| 92 | |
| 93 | return output |
| 94 | |
| 95 | |
| 96 | def strip_shell_chars(input_str): |