forked from edward/owl-map
Code formatting
This commit is contained in:
parent
caed12c325
commit
5693bc6265
|
@ -3,13 +3,16 @@ from logging.handlers import SMTPHandler
|
||||||
from logging import Formatter
|
from logging import Formatter
|
||||||
from flask import request
|
from flask import request
|
||||||
|
|
||||||
PROJECT = 'osm-wikidata'
|
PROJECT = "osm-wikidata"
|
||||||
|
|
||||||
|
|
||||||
class MatcherSMTPHandler(SMTPHandler):
|
class MatcherSMTPHandler(SMTPHandler):
|
||||||
def getSubject(self, record): # noqa: N802
|
def getSubject(self, record): # noqa: N802
|
||||||
return (f'{PROJECT} error: {record.exc_info[0].__name__}'
|
return (
|
||||||
|
f"{PROJECT} error: {record.exc_info[0].__name__}"
|
||||||
if (record.exc_info and record.exc_info[0])
|
if (record.exc_info and record.exc_info[0])
|
||||||
else f'{PROJECT} error: {record.pathname}:{record.lineno:d}')
|
else f"{PROJECT} error: {record.pathname}:{record.lineno:d}"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class RequestFormatter(Formatter):
|
class RequestFormatter(Formatter):
|
||||||
|
@ -19,9 +22,10 @@ class RequestFormatter(Formatter):
|
||||||
|
|
||||||
|
|
||||||
def setup_error_mail(app):
|
def setup_error_mail(app):
|
||||||
if not app.config.get('ERROR_MAIL'):
|
if not app.config.get("ERROR_MAIL"):
|
||||||
return
|
return
|
||||||
formatter = RequestFormatter('''
|
formatter = RequestFormatter(
|
||||||
|
"""
|
||||||
Message type: {levelname}
|
Message type: {levelname}
|
||||||
Location: {pathname:s}:{lineno:d}
|
Location: {pathname:s}:{lineno:d}
|
||||||
Module: {module:s}
|
Module: {module:s}
|
||||||
|
@ -33,12 +37,16 @@ def setup_error_mail(app):
|
||||||
Message:
|
Message:
|
||||||
|
|
||||||
{message:s}
|
{message:s}
|
||||||
''', style='{')
|
""",
|
||||||
|
style="{",
|
||||||
|
)
|
||||||
|
|
||||||
mail_handler = MatcherSMTPHandler(app.config['SMTP_HOST'],
|
mail_handler = MatcherSMTPHandler(
|
||||||
app.config['MAIL_FROM'],
|
app.config["SMTP_HOST"],
|
||||||
app.config['ADMINS'],
|
app.config["MAIL_FROM"],
|
||||||
app.name + ' error')
|
app.config["ADMINS"],
|
||||||
|
app.name + " error",
|
||||||
|
)
|
||||||
mail_handler.setFormatter(formatter)
|
mail_handler.setFormatter(formatter)
|
||||||
|
|
||||||
mail_handler.setLevel(logging.ERROR)
|
mail_handler.setLevel(logging.ERROR)
|
||||||
|
|
|
@ -101,6 +101,7 @@ def get_hit_name(hit):
|
||||||
n2 = address_values[1]
|
n2 = address_values[1]
|
||||||
return f"{n1}, {n2}, {country}"
|
return f"{n1}, {n2}, {country}"
|
||||||
|
|
||||||
|
|
||||||
def get_hit_label(hit):
|
def get_hit_label(hit):
|
||||||
tags = hit["extratags"]
|
tags = hit["extratags"]
|
||||||
designation = tags.get("designation")
|
designation = tags.get("designation")
|
||||||
|
|
Loading…
Reference in a new issue