'Remove any ANSI (VT100) ESC codes from the output
http://en.wikipedia.org/wiki/ANSI_escape_code
Note: this does not capture ALL possible ANSI Escape Codes only the ones
I have encountered
Current codes that are filtered:
ESC = \'\' or chr(27)
ESC = is the escape character [^ in hex (\'\')
ESC[24;27H   Position cursor
ESC[?25h     Show the cursor
ESC[E        Next line (HP does ESC-E)
ESC[K        Erase line from cursor to the end of line
ESC[2K       Erase entire line
ESC[1;24r    Enable scrolling from start to row end
ESC[?6l      Reset mode screen with options 640 x 200 monochrome (graphics)
ESC[?7l      Disable line wrapping
ESC[2J       Code erase display
HP ProCurve\'s, Cisco SG300, and F5 LTM\'s require this (possible others)'

@staticmethod
def strip_ansi_escape_codes(string_buffer):

    log.debug(u'In    strip_ansi_escape_codes')
    log.debug(u'repr    =    {0}'.format(repr(string_buffer)))
    code_position_cursor = (chr(27) + u'\\[\\d+;\\d+H')
    code_show_cursor = (chr(27) + u'\\[\\?25h')
    code_next_line = (chr(27) + u'E')
    code_erase_line_end = (chr(27) + u'\\[K')
    code_erase_line = (chr(27) + u'\\[2K')
    code_erase_start_line = (chr(27) + u'\\[K')
    code_enable_scroll = (chr(27) + u'\\[\\d+;\\d+r')
    code_form_feed = (chr(27) + u'\\[1L')
    code_carriage_return = (chr(27) + u'\\[1M')
    code_disable_line_wrapping = (chr(27) + u'\\[\\?7l')
    code_reset_mode_screen_options = (chr(27) + u'\\[\\?\\d+l')
    code_erase_display = (chr(27) + u'\\[2J')
    code_set = [code_position_cursor, code_show_cursor, code_erase_line, code_enable_scroll, code_erase_start_line, code_form_feed, code_carriage_return, code_disable_line_wrapping, code_erase_line_end, code_reset_mode_screen_options, code_erase_display]
    output = string_buffer
    for ansi_esc_code in code_set:
        output = re.sub(ansi_esc_code, u'', output)
    output = re.sub(code_next_line, u'\n', output)
    log.debug(u'new_output    =    {0}'.format(output))
    log.debug(u'repr    =    {0}'.format(repr(output)))
    return output
