service: more logging

This commit is contained in:
Franzi 2023-12-18 07:58:01 +01:00
parent e3d2fee4f3
commit 5ba190caa3

17
service
View file

@ -58,8 +58,9 @@ def main():
# changes. # changes.
time.sleep(99999999) time.sleep(99999999)
log("event url: {}".format(schedule_url)) log("event url: {}".format(schedule_url))
log("using json flavour: {}".format(config["json_flavour"]))
if config['json_flavour'] == 'pretalx-broadcast-tools': if config["json_flavour"] == "pretalx-broadcast-tools":
if not schedule_url.endswith("/"): if not schedule_url.endswith("/"):
schedule_url = schedule_url + "/" schedule_url = schedule_url + "/"
try: try:
@ -100,7 +101,7 @@ def main():
) )
node.write_json("schedule.json", schedule) node.write_json("schedule.json", schedule)
log("updated schedule json") log("updated schedule json")
elif config['json_flavour'] == 'voc-schema': elif config["json_flavour"] == "voc-schema":
try: try:
r = get(schedule_url) r = get(schedule_url)
r.raise_for_status() r.raise_for_status()
@ -108,15 +109,19 @@ def main():
log("getting schedule.json failed: {}".format(repr(e))) log("getting schedule.json failed: {}".format(repr(e)))
else: else:
raw_schedule = r.json() raw_schedule = r.json()
schedule = {'talks': []} schedule = {"talks": []}
event_start = datetime.strptime(raw_schedule["conference"]["start"][:10], "%Y-%m-%d") event_start = datetime.strptime(
raw_schedule["conference"]["start"][:10], "%Y-%m-%d"
)
event_tz = pytz.timezone(raw_schedule["conference"]["time_zone_name"]) event_tz = pytz.timezone(raw_schedule["conference"]["time_zone_name"])
for day in raw_schedule["days"]: for day in raw_schedule["days"]:
for room in day["rooms"].values(): for room in day["rooms"].values():
for talk in room: for talk in room:
start = datetime.strptime(talk["date"][:19], "%Y-%m-%dT%H:%M%:S").replace(tzinfo=event_tz) start = datetime.strptime(
talk["date"][:19], "%Y-%m-%dT%H:%M%:S"
).replace(tzinfo=event_tz)
d_h, d_m = talk["duration"].split(":") d_h, d_m = talk["duration"].split(":")
end = start + timedelta(hours=int(d_h), minutes=int(d_m)) end = start + timedelta(hours=int(d_h), minutes=int(d_m))
@ -144,6 +149,8 @@ def main():
schedule["talks"].append(talk) schedule["talks"].append(talk)
node.write_json("schedule.json", schedule) node.write_json("schedule.json", schedule)
log("updated schedule json") log("updated schedule json")
else:
log("unknown json flavour, something is very wrong")
idle(30, event_start, event_tz) idle(30, event_start, event_tz)