def get_exception_info(request):   
    # We use Django's debug reporter, even though we are doing our own template.
    # This is because it has a great way of collecting all the useful info we 
    # need, so no reason not to leverage it 
    exc_info = sys.exc_info()
    reporter = ExceptionReporter(request, *exc_info)
    ctx = reporter.get_traceback_data()
    
    # This is a refactor of what the technical_500_template contains, just
    # doing the logic in Python rather than in a template. We collect all this
    # information so that we can log it.
    exception_type = ctx['exception_type'] if 'exception_type' in ctx else "No exception supplied"
    exception_value = ctx['exception_value'] if 'exception_value' in ctx else "No exception supplied"
    django_version = ctx["django_version_info"]
    python_executable = ctx['sys_executable']
    python_version = ctx['sys_version_info']
    python_path = ctx['sys_path']
    server_time = str(ctx['server_time'])
    unicode_hint = None
    if 'unicode_hint' in ctx:
        unicdoe_hint = ctx['unicode_hint']
    last_frame = None
    if 'lastframe' in ctx:
        frame_info = ctx['lastframe']
        last_frame = "%s in %s, line %s" % (frame_info['filename'], frame_info['function'], frame_info['lineno'])
    loaders = []
    if 'template_does_not_exist' in ctx and 'loader_debug_info' in ctx and ctx['loader_debug_info']:
        for loader in ctx['loader_debug_info']:
            loader_info = {"name": loader['loader'], "templates": []}
            for tmpl in loader['templates']:
                loader_info['templates'].append({"file": tmpl['name'], "exists": tmpl['exists']})
            loaders.append(loader_info)
    template_errors = None
    if 'template_info' in ctx and ctx['template_info']:
        template_info = ctx['template_info']
        template_errors = {
            "name": template_info['name'],
            "line": template_info['line'],
            "message": template_info['message']
        }
    exception_info = []
    if 'frames' in ctx:
        frames = ctx['frames']
        for frame in frames:
            frame_info = {
                "filename": frame['filename'],
                "function": frame['function'],
                "line": frame['lineno'],
                "context_line": frame['context_line'],
                "vars": []
            }
            if 'vars' in frame:
                for var in frame['vars']:
                    frame_info['vars'].append({
                        "variable": str(var[0]),
                        "value": format(var[1])
                    })
            exception_info.append(frame_info)
    request_info = {
        "path_info": request.path_info,
        "method": request.META['REQUEST_METHOD'],
        "url": request.build_absolute_uri(),
        "GET": {},
        "POST": {},
        "FILES": {},
        "COOKIES": {},
        "META": {}
    }
    if hasattr(request, "GET"):
        for key, value in request.GET.iteritems():
            request_info['GET'][key] = format(value)
    if "filtered_POST" in ctx:
        for key, value in ctx['filtered_POST'].iteritems():
            request_info['POST'][key] = format(value)
    if hasattr(request, "FILES"):
        for key, value in request.FILES.iteritems():
            request_info['FILES'][key] = format(value)
    if hasattr(request, "COOKIES"):
        for key, value in request.COOKIES.iteritems():
            request_info['COOKIES'][key] = format(value)
    if hasattr(request, "META"):
        for key, value in request.META.iteritems():
            request_info['META'][key] = format(value)
    settings_info = {}
    for key, value in ctx['settings'].iteritems():
        settings_info[key] = format(value)
        
    ctx['errorid'] = errorid = uuid.uuid4().hex
    
    full_info = dict(
        __time=datetime.datetime.now().isoformat(),
        __uuid=errorid,
        settings=settings_info,
        request=request_info,
        traceback=exception_info,
        stack=traceback.format_exc(exc_info[2]),
        last_frame=last_frame,
        template_loaders=loaders,
        template_errors=template_errors,
        unicode_hint=unicdoe_hint,
        exception_type=exception_type,
        exception_value=exception_value,
        django_version=django_version,
        python_version=python_version,
        python_executable=python_executable,
        python_path=python_path,
        server_time=server_time
    )
    
    return (errorid, ctx, full_info)
dataset/ETHPy150Open splunk/splunk-webframework/server/splunkdj/views.py/get_exception_info/original