refactor: clean-up 'weird' formatting
This commit is contained in:
parent
87ac023631
commit
8e5a90ec1f
1 changed files with 7 additions and 7 deletions
|
@ -4,12 +4,14 @@ from datetime import datetime
|
|||
def formatter(data, headers):
|
||||
"""Pretty-print a pingdom notification."""
|
||||
# JSON data formatting was obtained from https://www.pingdom.com/resources/webhooks/
|
||||
# these are common to all check types
|
||||
check_id = data["check_id"]
|
||||
check_name = data["check_name"]
|
||||
current_state = data["current_state"]
|
||||
local_time = datetime.fromtimestamp(data["state_changed_timestamp"])
|
||||
|
||||
if data["check_type"].lower() == "http":
|
||||
# http https or http_custom check types
|
||||
try:
|
||||
check_url = data["check_params"]["full_url"]
|
||||
data["body"] = (
|
||||
|
@ -18,13 +20,11 @@ def formatter(data, headers):
|
|||
f"[view details](https://my.pingdom.com/reports/responsetime#check={check_id})"
|
||||
)
|
||||
except Exception as error:
|
||||
data[
|
||||
"body"
|
||||
] = (
|
||||
f"Error: An attempt to post from pingdom was malformed "
|
||||
"(or I don't know how to handle what was sent).\n\n"
|
||||
f"{repr(error)}"
|
||||
)
|
||||
data["body"] = (
|
||||
f"Error: An attempt to post from pingdom was malformed "
|
||||
"(or I don't know how to handle what was sent).\n\n"
|
||||
f"{repr(error)}"
|
||||
)
|
||||
elif data["check_type"].lower() == "dns":
|
||||
# There are a bunch of values that are blanke when you do a test
|
||||
# so ignore them if value is unset
|
||||
|
|
Loading…
Reference in a new issue