webserver.py 文件源码

python
阅读 35 收藏 0 点赞 0 评论 0

项目:invenio1-orcid 作者: bronger 项目源码 文件源码
def send_error_mail(exception):
        """Sends an error mail to the admin containing the traceback and configuration.
        After that, a custom HTTP 500 page is shown.

        :param exception: the exception raised

        :type exception: ``Exception``

        :return:
          the HTML to send back in the response, and the HTTP code 500.

        :rtype: str, int
        """
        # Inspired from <https://github.com/jasonwyatt/Flask-ErrorMail>.
        message = Message("Join2 ORCID exception: %s" % exception, sender=CFG_SITE_ADMIN_EMAIL,
                          recipients=[CFG_SITE_ADMIN_EMAIL])
        message_contents = ["Traceback:", "=" * 80, traceback.format_exc(), "\n", "Request Information:", "=" * 80]
        environ = request.environ
        for key in sorted(environ.keys()):
            message_contents.append("%s: %s" % (key, environ.get(key)))
        message.body = "\n".join(message_contents) + "\n"
        mailer.send(message)
        return render_template("500.html"), 500
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号