2021-12-01 23:36:57 -05:00
|
|
|
from datetime import datetime
|
|
|
|
|
|
|
|
|
|
|
|
def formatter(data, headers):
|
|
|
|
"""Pretty-print a buildbot notification."""
|
|
|
|
buildid = data["buildid"]
|
|
|
|
buildstate = data["state_string"]
|
|
|
|
buildlink = data["url"]
|
|
|
|
reason = data["buildset"]["reason"]
|
|
|
|
project = data["properties"]["project"][0]
|
|
|
|
submittime = datetime.fromtimestamp(data["buildset"]["submitted_at"])
|
2022-01-11 22:22:20 -05:00
|
|
|
try:
|
|
|
|
if buildstate == "starting":
|
2021-12-01 23:36:57 -05:00
|
|
|
data["body"] = (
|
|
|
|
f"###Buildbot job #{buildid} for {project} - {buildstate}\n\n"
|
|
|
|
f"{reason}\n\n"
|
|
|
|
f"**started at** {submittime}\n\n"
|
|
|
|
f"[view details]({buildlink})"
|
|
|
|
)
|
2022-01-11 22:22:20 -05:00
|
|
|
elif buildstate == "build successful":
|
2021-12-01 23:36:57 -05:00
|
|
|
data["body"] = (
|
|
|
|
f"###Buildbot job #{buildid} for {project} - {buildstate}\n\n"
|
|
|
|
f"**completed at** {datetime.fromtimestamp(data['complete_at'])}\n\n"
|
|
|
|
f"[view details]({buildlink})"
|
|
|
|
)
|
2022-01-11 22:22:20 -05:00
|
|
|
else:
|
2021-12-01 23:44:59 -05:00
|
|
|
data["body"] = (
|
|
|
|
f"###Buildbot job #{buildid} for {project} - {buildstate}\n\n"
|
|
|
|
f"[view details]({buildlink})"
|
|
|
|
)
|
2022-01-11 22:22:20 -05:00
|
|
|
except Exception as error:
|
|
|
|
print(error)
|
2021-12-01 23:36:57 -05:00
|
|
|
|
|
|
|
return data
|