MCPcopy Create free account
hub / github.com/StackStorm/st2 / sanitize_output

Function sanitize_output

st2common/st2common/util/misc.py:72–93  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

70
71
72def 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
96def strip_shell_chars(input_str):

Callers 3

runMethod · 0.90

Calls 1

strip_shell_charsFunction · 0.85