fix: correct except clauses missing exceptions
This commit is contained in:
parent
1ea47991e4
commit
87ac023631
2 changed files with 4 additions and 7 deletions
|
@ -3,7 +3,7 @@ from datetime import datetime
|
||||||
|
|
||||||
def formatter(data, headers):
|
def formatter(data, headers):
|
||||||
"""Pretty-print a pingdom notification."""
|
"""Pretty-print a pingdom notification."""
|
||||||
#JSON data formatting was obtained from https://www.pingdom.com/resources/webhooks/
|
# JSON data formatting was obtained from https://www.pingdom.com/resources/webhooks/
|
||||||
check_id = data["check_id"]
|
check_id = data["check_id"]
|
||||||
check_name = data["check_name"]
|
check_name = data["check_name"]
|
||||||
current_state = data["current_state"]
|
current_state = data["current_state"]
|
||||||
|
@ -38,11 +38,11 @@ def formatter(data, headers):
|
||||||
second_ip = "unknown"
|
second_ip = "unknown"
|
||||||
try:
|
try:
|
||||||
first_location = data["first_probe"]["location"]
|
first_location = data["first_probe"]["location"]
|
||||||
except:
|
except KeyError:
|
||||||
first_location = "unknown"
|
first_location = "unknown"
|
||||||
try:
|
try:
|
||||||
second_location = data["second_probe"]["location"]
|
second_location = data["second_probe"]["location"]
|
||||||
except:
|
except KeyError:
|
||||||
second_location = "unknown"
|
second_location = "unknown"
|
||||||
try:
|
try:
|
||||||
expected_ip = data["check_params"]["expected_ip"]
|
expected_ip = data["check_params"]["expected_ip"]
|
||||||
|
|
|
@ -37,9 +37,6 @@ async def matrix_webhook(request):
|
||||||
|
|
||||||
if "formatter" in request.rel_url.query:
|
if "formatter" in request.rel_url.query:
|
||||||
try:
|
try:
|
||||||
# data = getattr(formatters, request.rel_url.query["formatter"])(
|
|
||||||
# data, request.headers
|
|
||||||
# )
|
|
||||||
format = request.rel_url.query["formatter"]
|
format = request.rel_url.query["formatter"]
|
||||||
plugin = importlib.import_module(f"matrix_webhook.formatters.{format}", "formatter")
|
plugin = importlib.import_module(f"matrix_webhook.formatters.{format}", "formatter")
|
||||||
data = plugin.formatter(data, request.headers)
|
data = plugin.formatter(data, request.headers)
|
||||||
|
|
Loading…
Reference in a new issue