当前位置: 首页>>代码示例>>Python>>正文


Python tbtools.get_current_traceback方法代码示例

本文整理汇总了Python中werkzeug.debug.tbtools.get_current_traceback方法的典型用法代码示例。如果您正苦于以下问题:Python tbtools.get_current_traceback方法的具体用法?Python tbtools.get_current_traceback怎么用?Python tbtools.get_current_traceback使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在werkzeug.debug.tbtools的用法示例。


在下文中一共展示了tbtools.get_current_traceback方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: showtraceback

# 需要导入模块: from werkzeug.debug import tbtools [as 别名]
# 或者: from werkzeug.debug.tbtools import get_current_traceback [as 别名]
def showtraceback(self):
        from werkzeug.debug.tbtools import get_current_traceback
        tb = get_current_traceback(skip=1)
        sys.stdout._write(tb.render_summary()) 
开发者ID:jpush,项目名称:jbox,代码行数:6,代码来源:console.py

示例2: showsyntaxerror

# 需要导入模块: from werkzeug.debug import tbtools [as 别名]
# 或者: from werkzeug.debug.tbtools import get_current_traceback [as 别名]
def showsyntaxerror(self, filename=None):
        from werkzeug.debug.tbtools import get_current_traceback
        tb = get_current_traceback(skip=4)
        sys.stdout._write(tb.render_summary()) 
开发者ID:jpush,项目名称:jbox,代码行数:6,代码来源:console.py

示例3: send_exception

# 需要导入模块: from werkzeug.debug import tbtools [as 别名]
# 或者: from werkzeug.debug.tbtools import get_current_traceback [as 别名]
def send_exception(subject):
    """Send Python exception tracebacks via email to the ADMINS list.

    Use the same HTML styling as Flask tracebacks in debug web servers.

    This function must be called while the exception is happening. It picks up the raised exception with sys.exc_info().

    Positional arguments:
    subject -- subject line of the email (to be prepended by 'Application Error: ').
    """
    # Generate and modify html.
    tb = tbtools.get_current_traceback()  # Get exception information.
    with _override_html():
        html = tb.render_full().encode('utf-8', 'replace')
    html = html.replace('<blockquote>', '<blockquote style="margin: 1em 0 0; padding: 0;">')
    subject = 'Application Error: {}'.format(subject)

    # Apply throttle.
    md5 = hashlib.md5('{}{}'.format(subject, html)).hexdigest()
    seconds = int(current_app.config['MAIL_EXCEPTION_THROTTLE'])
    lock = redis.lock(EMAIL_THROTTLE.format(md5=md5), timeout=seconds)
    have_lock = lock.acquire(blocking=False)
    if not have_lock:
        LOG.debug('Suppressing email: {}'.format(subject))
        return

    # Send email.
    msg = Message(subject=subject, recipients=current_app.config['ADMINS'], html=html)
    mail.send(msg) 
开发者ID:Robpol86,项目名称:Flask-Large-Application-Example,代码行数:31,代码来源:email.py

示例4: query_error

# 需要导入模块: from werkzeug.debug import tbtools [as 别名]
# 或者: from werkzeug.debug.tbtools import get_current_traceback [as 别名]
def query_error(e):
    tb = get_current_traceback()
    return render_template('show_query_error.html', e=e, tb=tb), 500 
开发者ID:EdwardBetts,项目名称:osm-wikidata,代码行数:5,代码来源:view.py

示例5: exception_handler

# 需要导入模块: from werkzeug.debug import tbtools [as 别名]
# 或者: from werkzeug.debug.tbtools import get_current_traceback [as 别名]
def exception_handler(e):
    tb = get_current_traceback()
    last_frame = tb.frames[-1]
    last_frame_args = inspect.getargs(last_frame.code)
    return render_template('show_error.html',
                           tb=tb,
                           last_frame=last_frame,
                           last_frame_args=last_frame_args), 500 
开发者ID:EdwardBetts,项目名称:osm-wikidata,代码行数:10,代码来源:view.py

示例6: debug_application

# 需要导入模块: from werkzeug.debug import tbtools [as 别名]
# 或者: from werkzeug.debug.tbtools import get_current_traceback [as 别名]
def debug_application(self, environ, start_response):
        """Run the application and conserve the traceback frames."""
        app_iter = None
        try:
            app_iter = self.app(environ, start_response)
            for item in app_iter:
                yield item
            if hasattr(app_iter, 'close'):
                app_iter.close()
        except Exception:
            if hasattr(app_iter, 'close'):
                app_iter.close()
            traceback = get_current_traceback(skip=1, show_hidden_frames=
                                              self.show_hidden_frames,
                                              ignore_system_exceptions=True)
            for frame in traceback.frames:
                self.frames[frame.id] = frame
            self.tracebacks[traceback.id] = traceback

            try:
                start_response('500 INTERNAL SERVER ERROR', [
                    ('Content-Type', 'text/html; charset=utf-8'),
                    # Disable Chrome's XSS protection, the debug
                    # output can cause false-positives.
                    ('X-XSS-Protection', '0'),
                ])
            except Exception:
                # if we end up here there has been output but an error
                # occurred.  in that situation we can do nothing fancy any
                # more, better log something into the error log and fall
                # back gracefully.
                environ['wsgi.errors'].write(
                    'Debugging middleware caught exception in streamed '
                    'response at a point where response headers were already '
                    'sent.\n')
            else:
                yield traceback.render_full(evalex=self.evalex,
                                            secret=self.secret) \
                               .encode('utf-8', 'replace')

            traceback.log(environ['wsgi.errors']) 
开发者ID:chalasr,项目名称:Flask-P2P,代码行数:43,代码来源:__init__.py

示例7: render_exception

# 需要导入模块: from werkzeug.debug import tbtools [as 别名]
# 或者: from werkzeug.debug.tbtools import get_current_traceback [as 别名]
def render_exception(self):
        traceback = get_current_traceback()

        for frame in traceback.frames:
            self.debug_app.frames[frame.id] = frame
        self.debug_app.tracebacks[traceback.id] = traceback

        return traceback.render_full(evalex=True,
                                     secret=self.debug_app.secret) 
开发者ID:dongweiming,项目名称:web_develop,代码行数:11,代码来源:app_tornado.py


注:本文中的werkzeug.debug.tbtools.get_current_traceback方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。