Fail on HTTP error, include /v4 path in software

This commit is contained in:
Midgard 2021-06-21 12:42:13 +02:00
parent 18e5b99988
commit ced3864fb6
Signed by: midgard
GPG key ID: 511C112F1331BBB4

View file

@ -10,7 +10,7 @@ from pytz import utc
CHANNEL = os.environ["SUNBOT_ANNOUNCE_CHANNEL"]
AUTHORIZATION = "Bearer " + os.environ["SUNBOT_ANNOUNCE_MATTERMOST_TOKEN"]
URL = os.environ["SUNBOT_ANNOUNCE_MATTERMOST_API_ENDPOINT"] + "/posts"
URL = os.environ["SUNBOT_ANNOUNCE_MATTERMOST_API_ENDPOINT"] + "/v4/posts"
LOCATION = astral.LocationInfo("Gent", "Belgium", "Europe/Brussels", 51.05, 3.72)
@ -24,7 +24,8 @@ def post(message):
"message": message
}
print("Posting " + str(payload), flush=True)
requests.post(URL, json=payload, headers={"Authorization": AUTHORIZATION})
r = requests.post(URL, json=payload, headers={"Authorization": AUTHORIZATION})
r.raise_for_status()
def format_in(diff):