diff --git a/netmiko/avaya/avaya_ers_ssh.py b/netmiko/avaya/avaya_ers_ssh.py index 9a41bae92..b3f65dc56 100644 --- a/netmiko/avaya/avaya_ers_ssh.py +++ b/netmiko/avaya/avaya_ers_ssh.py @@ -27,7 +27,7 @@ def special_login_handler(self, delay_factor=.5): i = 0 while i <= 12: if self.remote_conn.recv_ready(): - output = self.remote_conn.recv(MAX_BUFFER).decode('utf-8') + output = self.remote_conn.recv(MAX_BUFFER).decode('utf-8', 'ignore') if 'Ctrl-Y' in output: self.remote_conn.sendall(CTRL_Y) if 'sername' in output: diff --git a/netmiko/base_connection.py b/netmiko/base_connection.py index 58c28c685..db2a8ac26 100644 --- a/netmiko/base_connection.py +++ b/netmiko/base_connection.py @@ -177,7 +177,7 @@ def establish_connection(self, sleep_time=3, verbose=True, timeout=8, time.sleep(sleep_time) # Strip any initial data if self.remote_conn.recv_ready(): - return self.remote_conn.recv(MAX_BUFFER).decode('utf-8') + return self.remote_conn.recv(MAX_BUFFER).decode('utf-8', 'ignore') else: i = 0 while i <= 10: @@ -185,7 +185,7 @@ def establish_connection(self, sleep_time=3, verbose=True, timeout=8, self.remote_conn.sendall('\n') time.sleep(.5) if self.remote_conn.recv_ready(): - return self.remote_conn.recv(MAX_BUFFER).decode('utf-8') + return self.remote_conn.recv(MAX_BUFFER).decode('utf-8', 'ignore') else: i += 1 return "" @@ -216,7 +216,7 @@ def disable_paging(self, command="terminal length 0\n", delay_factor=.5): time.sleep(1 * delay_factor) # Clear the buffer on the screen - output = self.remote_conn.recv(MAX_BUFFER).decode('utf-8') + output = self.remote_conn.recv(MAX_BUFFER).decode('utf-8', 'ignore') if self.ansi_escape_codes: output = self.strip_ansi_escape_codes(output) @@ -259,7 +259,7 @@ def set_base_prompt(self, pri_prompt_terminator='#', self.clear_buffer() self.remote_conn.sendall("\n") self.wait_for_recv_ready(delay_factor) - prompt = self.remote_conn.recv(MAX_BUFFER).decode('utf-8') + prompt = self.remote_conn.recv(MAX_BUFFER).decode('utf-8', 'ignore') # Some platforms have ANSI escape codes if self.ansi_escape_codes: @@ -302,7 +302,7 @@ def find_prompt(self, delay_factor=.5): self.remote_conn.sendall("\n") time.sleep(1 * delay_factor) - prompt = self.remote_conn.recv(MAX_BUFFER).decode('utf-8') + prompt = self.remote_conn.recv(MAX_BUFFER).decode('utf-8', 'ignore') # Some platforms have ANSI escape codes if self.ansi_escape_codes: @@ -326,7 +326,7 @@ def clear_buffer(self): ''' if self.remote_conn.recv_ready(): - return self.remote_conn.recv(MAX_BUFFER).decode('utf-8') + return self.remote_conn.recv(MAX_BUFFER).decode('utf-8', 'ignore') else: return None @@ -369,7 +369,7 @@ def send_command(self, command_string, delay_factor=.5, max_loops=30, i += 1 # Keep reading data as long as available (up to max_loops) if self.remote_conn.recv_ready(): - output += self.remote_conn.recv(MAX_BUFFER).decode('utf-8') + output += self.remote_conn.recv(MAX_BUFFER).decode('utf-8', 'ignore') else: not_done = False @@ -447,7 +447,7 @@ def send_command_expect(self, command_string, expect_string=None, if self.remote_conn.recv_ready(): if debug: print("recv_ready = True") - output += self.remote_conn.recv(MAX_BUFFER).decode('utf-8') + output += self.remote_conn.recv(MAX_BUFFER).decode('utf-8', 'ignore') if search_pattern in output: break else: diff --git a/netmiko/cisco/cisco_asa_ssh.py b/netmiko/cisco/cisco_asa_ssh.py index cfe3b9be5..33a90e165 100644 --- a/netmiko/cisco/cisco_asa_ssh.py +++ b/netmiko/cisco/cisco_asa_ssh.py @@ -63,12 +63,12 @@ def enable(self, delay_factor=.5): self.remote_conn.sendall("\nenable\n") time.sleep(1 * delay_factor) - output = self.remote_conn.recv(MAX_BUFFER).decode('utf-8') + output = self.remote_conn.recv(MAX_BUFFER).decode('utf-8', 'ignore') if 'password' in output.lower(): self.remote_conn.sendall(self.secret + '\n') self.remote_conn.sendall('\n') time.sleep(1 * delay_factor) - output += self.remote_conn.recv(MAX_BUFFER).decode('utf-8') + output += self.remote_conn.recv(MAX_BUFFER).decode('utf-8', 'ignore') if not self.check_enable_mode(): raise ValueError("Failed to enter enable mode") diff --git a/netmiko/cisco/cisco_wlc_ssh.py b/netmiko/cisco/cisco_wlc_ssh.py index 079301f58..2f00da3d9 100644 --- a/netmiko/cisco/cisco_wlc_ssh.py +++ b/netmiko/cisco/cisco_wlc_ssh.py @@ -29,7 +29,7 @@ def special_login_handler(self, delay_factor=.5): i = 0 while i <= 12: if self.remote_conn.recv_ready(): - output = self.remote_conn.recv(MAX_BUFFER).decode('utf-8') + output = self.remote_conn.recv(MAX_BUFFER).decode('utf-8', 'ignore') if 'login as' in output or 'User' in output: self.remote_conn.sendall(self.username + '\n') elif 'Password' in output: @@ -84,8 +84,7 @@ def send_command_w_enter(self, *args, **kwargs): i += 1 if self.remote_conn.recv_ready(): # Unicode error occurred in output (errors=ignore strips this out). - output += self.remote_conn.recv(MAX_BUFFER).decode('utf-8', - errors='ignore') + output += self.remote_conn.recv(MAX_BUFFER).decode('utf-8', 'ignore') else: not_done = False diff --git a/netmiko/fortinet/fortinet_ssh.py b/netmiko/fortinet/fortinet_ssh.py index 0c5b1a855..0c12a1c51 100644 --- a/netmiko/fortinet/fortinet_ssh.py +++ b/netmiko/fortinet/fortinet_ssh.py @@ -105,7 +105,7 @@ def establish_connection(self, sleep_time=3, verbose=True, timeout=8, use_keys=F # Strip the initial router prompt time.sleep(sleep_time) - return self.remote_conn.recv(MAX_BUFFER).decode('utf-8') + return self.remote_conn.recv(MAX_BUFFER).decode('utf-8', 'ignore') def config_mode(self, config_command=''): ''' diff --git a/netmiko/hp/hp_comware_ssh.py b/netmiko/hp/hp_comware_ssh.py index 815107bb8..69ee4d638 100644 --- a/netmiko/hp/hp_comware_ssh.py +++ b/netmiko/hp/hp_comware_ssh.py @@ -62,7 +62,7 @@ def set_base_prompt(self, pri_prompt_terminator='>', alt_prompt_terminator=']', self.remote_conn.sendall("\n") time.sleep(1 * delay_factor) - prompt = self.remote_conn.recv(MAX_BUFFER).decode('utf-8') + prompt = self.remote_conn.recv(MAX_BUFFER).decode('utf-8', 'ignore') prompt = self.normalize_linefeeds(prompt) # If multiple lines in the output take the last line diff --git a/netmiko/huawei/huawei_ssh.py b/netmiko/huawei/huawei_ssh.py index 10ee5c904..a1ad973be 100644 --- a/netmiko/huawei/huawei_ssh.py +++ b/netmiko/huawei/huawei_ssh.py @@ -64,7 +64,7 @@ def set_base_prompt(self, pri_prompt_terminator='>', alt_prompt_terminator=']', self.remote_conn.sendall("\n") time.sleep(1 * delay_factor) - prompt = self.remote_conn.recv(MAX_BUFFER).decode('utf-8') + prompt = self.remote_conn.recv(MAX_BUFFER).decode('utf-8', 'ignore') prompt = self.normalize_linefeeds(prompt) # If multiple lines in the output take the last line diff --git a/netmiko/juniper/juniper_ssh.py b/netmiko/juniper/juniper_ssh.py index a523a2b1b..625ae6041 100644 --- a/netmiko/juniper/juniper_ssh.py +++ b/netmiko/juniper/juniper_ssh.py @@ -31,7 +31,7 @@ def enter_cli_mode(self): while True: self.remote_conn.sendall("\n") time.sleep(1) - cur_prompt = self.remote_conn.recv(MAX_BUFFER).decode('utf-8') + cur_prompt = self.remote_conn.recv(MAX_BUFFER).decode('utf-8', 'ignore') if re.search(r'root@.*%', cur_prompt): self.remote_conn.sendall("cli\n") time.sleep(1)