@@ -183,6 +183,7 @@ def __init__(
183
183
sock : Optional [socket .socket ] = None ,
184
184
auto_connect : bool = True ,
185
185
delay_factor_compat : bool = False ,
186
+ disable_lf_normalization : bool = False ,
186
187
) -> None :
187
188
"""
188
189
Initialize attributes for establishing connection to target device.
@@ -294,6 +295,9 @@ def __init__(
294
295
:param delay_factor_compat: Set send_command and send_command_timing back to using Netmiko
295
296
3.x behavior for delay_factor/global_delay_factor/max_loops. This argument will be
296
297
eliminated in Netmiko 5.x (default: False).
298
+
299
+ :param disable_lf_normalization: Disable Netmiko's linefeed normalization behavior
300
+ (default: False)
297
301
"""
298
302
299
303
self .remote_conn : Union [
@@ -315,6 +319,8 @@ def __init__(
315
319
316
320
# Line Separator in response lines
317
321
self .RESPONSE_RETURN = "\n " if response_return is None else response_return
322
+ self .disable_lf_normalization = True if disable_lf_normalization else False
323
+
318
324
if ip :
319
325
self .host = ip .strip ()
320
326
elif host :
@@ -594,7 +600,20 @@ def is_alive(self) -> bool:
594
600
def read_channel (self ) -> str :
595
601
"""Generic handler that will read all the data from given channel."""
596
602
new_data = self .channel .read_channel ()
597
- new_data = self .normalize_linefeeds (new_data )
603
+
604
+ if self .disable_lf_normalization is False :
605
+ start = time .time ()
606
+ # Data blocks shouldn't end in '\r' (can cause problems with normalize_linefeeds)
607
+ # Only do the extra read if '\n' exists in the output
608
+ # this avoids devices that only use \r.
609
+ while ("\n " in new_data ) and (time .time () - start < 1.0 ):
610
+ if new_data [- 1 ] == "\r " :
611
+ time .sleep (0.01 )
612
+ new_data += self .channel .read_channel ()
613
+ else :
614
+ break
615
+ new_data = self .normalize_linefeeds (new_data )
616
+
598
617
if self .ansi_escape_codes :
599
618
new_data = self .strip_ansi_escape_codes (new_data )
600
619
log .debug (f"read_channel: { new_data } " )
@@ -1046,7 +1065,6 @@ def _sanitize_output(
1046
1065
) -> str :
1047
1066
"""Strip out command echo and trailing router prompt."""
1048
1067
if strip_command and command_string :
1049
- command_string = self .normalize_linefeeds (command_string )
1050
1068
output = self .strip_command (command_string , output )
1051
1069
if strip_prompt :
1052
1070
output = self .strip_prompt (output )
0 commit comments