def _decode_line(self, line): """ Decodes line if necessary. Put here code to remove colors from terminal etc. :param line: line from device to decode. :return: decoded line. """ line = remove_all_known_special_chars(line) return line
def _decode_line(self, line): """ Method to delete new line chars and other chars we don not need to parse in on_new_line (color escape character) :param line: Line with special chars, raw string from device :return: line without special chars. """ if self.remove_all_known_special_chars_from_terminal_output: line = remove_all_known_special_chars(line) return line
def _verify_shell_is_operable(self, data): self.read_buffer = self.read_buffer + data lines = self.read_buffer.splitlines() for line in lines: line = remove_all_known_special_chars(line) if not re.search(self._re_set_prompt_cmd, line) and re.search( self.target_prompt, line): self._notify_on_connect() self._shell_operable.set() data = re.sub(self.target_prompt, '', self.read_buffer, re.MULTILINE) self.data_received(data) elif not self._export_sent and re.search( self.first_prompt, self.read_buffer, re.MULTILINE): self.send(self.set_prompt_cmd) self._export_sent = True
def utf8decoder_with_vt100_cleaner(data): decoded = data.decode("utf-8") decoded = remove_all_known_special_chars(decoded) return decoded