config.py 文件源码

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

项目:PilosusBot 作者: pilosus 项目源码 文件源码
def init_app(cls, app):
        Config.init_app(app)
        # email errors to the administrators

        # setup Python's logging handler if Sentry's not used
        if not cls.SENTRY_DSN_SECRET:
            from logging.handlers import SMTPHandler
            credentials = None
            secure = None
            if getattr(cls, 'MAIL_USERNAME', None) is not None:
                credentials = (cls.MAIL_USERNAME, cls.MAIL_PASSWORD)
                if getattr(cls, 'MAIL_USE_TLS', None):
                    secure = ()
            mail_handler = SMTPHandler(
                mailhost=(cls.MAIL_SERVER, cls.MAIL_PORT),
                fromaddr=cls.MAIL_USERNAME,
                toaddrs=[cls.APP_ADMIN_EMAIL],
                subject=cls.APP_MAIL_SUBJECT_PREFIX + ' Application Error',
                credentials=credentials,
                secure=secure)
            mail_handler.setLevel(logging.ERROR)
            app.logger.addHandler(mail_handler)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号