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):
|
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/
|
||||||
|
# these are common to all check types
|
||||||
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"]
|
||||||
local_time = datetime.fromtimestamp(data["state_changed_timestamp"])
|
local_time = datetime.fromtimestamp(data["state_changed_timestamp"])
|
||||||
|
|
||||||
if data["check_type"].lower() == "http":
|
if data["check_type"].lower() == "http":
|
||||||
|
# http https or http_custom check types
|
||||||
try:
|
try:
|
||||||
check_url = data["check_params"]["full_url"]
|
check_url = data["check_params"]["full_url"]
|
||||||
data["body"] = (
|
data["body"] = (
|
||||||
|
@ -18,9 +20,7 @@ def formatter(data, headers):
|
||||||
f"[view details](https://my.pingdom.com/reports/responsetime#check={check_id})"
|
f"[view details](https://my.pingdom.com/reports/responsetime#check={check_id})"
|
||||||
)
|
)
|
||||||
except Exception as error:
|
except Exception as error:
|
||||||
data[
|
data["body"] = (
|
||||||
"body"
|
|
||||||
] = (
|
|
||||||
f"Error: An attempt to post from pingdom was malformed "
|
f"Error: An attempt to post from pingdom was malformed "
|
||||||
"(or I don't know how to handle what was sent).\n\n"
|
"(or I don't know how to handle what was sent).\n\n"
|
||||||
f"{repr(error)}"
|
f"{repr(error)}"
|
||||||
|
|
Loading…
Reference in a new issue