Esempio n. 1
0
def _build(atype, class_name, comment, *args):
    out = []

    # Header
    if class_name:
        xtermr.add_class_name(out, class_name)

    # Xterm add title
    xtermr.add_title(atype, out, comment)

    # HTMLr open unit
    if _state:
        htmlr.open_unit(_state.model.htmlrstate, atype, class_name, comment)

    # Variables
    count = len(args) / 2
    i = 0
    j = 0
    while j < count:
        # Append variable
        _append_var(atype, out, args[i], args[i + 1])
        i += 2
        j += 1

    # Output to logger
    logging.debug('\n'.join(out))

    # HTMLr close unit
    if _state:
        htmlr.close_unit(_state.model.htmlrstate, atype)
Esempio n. 2
0
def _build_exception(class_name, comment):
    atype = 'error'
    out = []

    # Header
    if class_name:
        xtermr.add_class_name(out, class_name)

    # Xterm add title
    xtermr.add_title(atype, out, comment)

    # HTMLr open unit
    if _state:
        htmlr.open_unit(_state.model.htmlrstate, atype, class_name, comment)

    # Get exception info
    (exc_type, exc_value, exc_traceback) = sys.exc_info()

    # Exception type and value
    if exc_type:
        exc_type = exc_type.__name__
    else:
        exc_type = 'None'

    if not exc_value:
        exc_value = 'None'

    _append_var(atype, out, 'exc', exc_type)
    _append_var(atype, out, 'msg', exc_value)

    # Stack trace
    xtermr.add_stack_trace_separator(out)
    tb = traceback.extract_tb(exc_traceback)
    tb.reverse()
    for t in tb:
        t_file = t[0]
        t_line = t[1]
        t_func = t[2]
        t_text = t[3]
        xtermr.add_stack_trace_entry(out, t_file, t_line, t_func, t_text)
        if _state:
            htmlr.add_stack_trace_entry(_state.model.htmlrstate, t_file, t_line, t_func, t_text)

    # Output to logger
    logging.debug('\n'.join(out))

    # HTMLr close unit
    if _state:
        htmlr.close_unit(_state.model.htmlrstate, atype)
Esempio n. 3
0
def _build_object(class_name, comment, obj):
    atype = 'debug'
    out = []

    # Header
    if class_name:
        xtermr.add_class_name(out, class_name)

    # Xterm add title
    xtermr.add_title(atype, out, comment)

    # HTMLr open unit
    if _state:
        htmlr.open_unit(_state.model.htmlrstate, atype, class_name, comment)

    # Variables
    debug_vars = getattr(obj, 'debug_vars', None)
    if callable(debug_vars):
        args = obj.debug_vars()
        if args:
            count = len(args) / 2
            i = 0
            j = 0
            while j < count:
                # Append variable
                _append_var(atype, out, args[i], args[i + 1])
                i += 2
                j += 1
    else:
        _append_var(atype, out, 'warning', 'This object needs to implement debug_vars()')

    # Output to logger
    logging.debug('\n'.join(out))

    # HTMLr close unit
    if _state:
        htmlr.close_unit(_state.model.htmlrstate, atype)