-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(38c3): first stub to produce engelsystem-specific schedule.xml
- Loading branch information
Showing
6 changed files
with
280 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,222 @@ | ||
#!/usr/bin/env python3 | ||
# -*- coding: UTF-8 -*- | ||
|
||
import os | ||
from typing import List | ||
import requests | ||
import json | ||
import pytz | ||
import sys | ||
import optparse | ||
from datetime import datetime | ||
|
||
from voc import ( | ||
GenericConference, | ||
PretalxConference, | ||
Event, | ||
Schedule, | ||
ScheduleEncoder, | ||
ScheduleException, | ||
Room, | ||
Logger, | ||
) | ||
|
||
from voc.c3data import C3data | ||
from git import Repo | ||
|
||
# from voc.schedule import set_validator_filter | ||
from voc.tools import ( | ||
commit_changes_if_something_relevant_changed, | ||
git, | ||
harmonize_event_type, | ||
write, | ||
ensure_folders_exist, | ||
) | ||
|
||
tz = pytz.timezone("Europe/Amsterdam") | ||
local = False | ||
|
||
parser = optparse.OptionParser() | ||
parser.add_option("--online", action="store_true", dest="online", default=False) | ||
parser.add_option( | ||
"--fail", action="store_true", dest="exit_when_exception_occours", default=local | ||
) | ||
parser.add_option("--stats", action="store_true", dest="only_stats", default=False) | ||
parser.add_option("--git", action="store_true", dest="git", default=False) | ||
parser.add_option("--debug", action="store_true", dest="debug", default=local) | ||
|
||
log = Logger(__name__) | ||
options, args = parser.parse_args() | ||
|
||
xc3 = "38c3" | ||
|
||
main_cfp = GenericConference( | ||
url="https://fahrplan.events.ccc.de/congress/2024/fahrplan/schedule/export/schedule.json", | ||
data={ | ||
}, | ||
) | ||
hub = GenericConference( | ||
url="https://api.events.ccc.de/congress/2024/schedule.json", | ||
data={ | ||
"name": "hub", | ||
}, | ||
) | ||
|
||
base_schedule = Schedule( | ||
conference={ | ||
"url": "https://events.ccc.de/congress/2024/", | ||
"acronym": "38c3", | ||
"title": "38th Chaos Communication Congress", | ||
"start": "2024-12-27T09:30:00+00:00", | ||
"end": "2024-12-30T21:00:00+00:00", | ||
"daysCount": 4, | ||
"timeslot_duration": "00:10", | ||
"time_zone_name": "Europe/Berlin", | ||
}, | ||
version=str(datetime.now().strftime("%Y-%m-%d %H:%M")), | ||
) | ||
|
||
subconferences: List[GenericConference] = [ | ||
PretalxConference( | ||
url="https://cfp.cccv.de/38c3-community-stages", | ||
data={ | ||
"name": "community-stages", | ||
}, | ||
), | ||
PretalxConference( | ||
url="https://cfp.cccv.de/38c3-chaos-computer-music-club", | ||
data={ | ||
"name": "music", | ||
}, | ||
), | ||
# PretalxConference( | ||
# url="https://cfp.cccv.de/38c3-lightningtalks/", | ||
# data={ | ||
# "name": "lightningtalks", | ||
# }, | ||
# ), | ||
PretalxConference( | ||
url="https://pretalx.c3voc.de/38c3-sendezentrum", | ||
data={ | ||
}, | ||
), | ||
PretalxConference( | ||
url="https://pretalx.c3voc.de/38c3-haecksen-workshops-2024", | ||
data={ | ||
}, | ||
), | ||
PretalxConference( | ||
url="https://fahrplan.alpaka.space/jugend-hackt-38c3-2024", | ||
data={ | ||
}, | ||
), | ||
] | ||
|
||
targets = [ | ||
"filesystem", | ||
"c3data", | ||
# "voctoimport", | ||
# "rc3hub" | ||
] | ||
|
||
id_offsets = {} | ||
|
||
# this list/map is required to sort the events in the schedule.xml in the correct way | ||
# other rooms/assemblies are added at the end on demand. | ||
rooms = {} | ||
|
||
channels = {} | ||
|
||
output_dir = "/srv/www/" + xc3 | ||
secondary_output_dir = "./" + xc3 | ||
if len(sys.argv) == 2: | ||
output_dir = sys.argv[1] | ||
|
||
local = ensure_folders_exist(output_dir, secondary_output_dir) | ||
|
||
def create_himmel_schedule(fahrplan): | ||
himmel_schedule = fahrplan.copy("himmel") | ||
himmel_schedule.rename_rooms({ | ||
'Saal 1': Room(name='Saal 1 Evac', guid='ba692ba3-421b-5371-8309-60acc34a3c06'), | ||
'Saal GLITCH': Room(name='Saal GLITCH Evac', guid='7202df07-050c-552f-8318-992f94e40ef1'), | ||
'Saal ZIGZAG': Room(name='Saal ZIGZAG Evac', guid='62251a07-13e4-5a72-bb3c-8528416ee0f3'), | ||
}) | ||
|
||
himmel_schedule.export("himmel") | ||
|
||
return himmel_schedule | ||
|
||
|
||
def main(): | ||
fahrplan = main_cfp.schedule() | ||
create_himmel_schedule(fahrplan) | ||
|
||
everything = hub.schedule() | ||
loaded_schedules = {} | ||
|
||
|
||
|
||
# to get proper a state, we first have to remove all event files from the previous run | ||
if not local or options.git: | ||
git("rm events/* >/dev/null") | ||
os.makedirs("events", exist_ok=True) | ||
|
||
fahrplan.foreach_event(lambda e: e.export("events/", "-origin")) | ||
everything.foreach_event(lambda e: e.export("events/", "-hub")) | ||
#for schedule in loaded_schedules: | ||
# schedule.foreach_event(lambda e: e.export("events/", "-origin")) | ||
|
||
# remove overlapping 'Lötworkshop mit Lötchallenge' | ||
# full_schedule.remove_event(guid='bd75d959-dad1-43b4-81fb-33dfb43c10ec') | ||
|
||
# write all events to one big schedule.json/xml | ||
write("\nExporting... ") | ||
# set_validator_filter('strange') | ||
everything.export("everything") | ||
|
||
|
||
# expose metadata to own file | ||
with open("meta.json", "w") as fp: | ||
json.dump( | ||
{ | ||
"data": { | ||
"version": fahrplan.version(), | ||
"source_urls": list(loaded_schedules.keys()), | ||
"rooms": [ | ||
{ | ||
**room, | ||
"schedule_name": room["name"], | ||
"stream": channels.get( | ||
room.get("guid", room["name"]), Room() | ||
).stream, | ||
} | ||
for room in everything.rooms(mode="v2") | ||
], | ||
"conferences": subconferences, | ||
}, | ||
}, | ||
fp, | ||
indent=2, | ||
cls=ScheduleEncoder, | ||
) | ||
|
||
print("\nDone") | ||
print(" fahrplan version: " + fahrplan.version()) | ||
print(" hub version: " + everything.version()) | ||
|
||
|
||
|
||
if not local or options.git: | ||
commit_changes_if_something_relevant_changed(everything) | ||
# Attention: This method exits the script, if nothing relevant changed | ||
# TOOD: make this fact more obvious or refactor code | ||
|
||
if not local and "c3data" in targets: | ||
print("\n== Updating c3data via API…") | ||
|
||
c3data = C3data(everything) | ||
c3data.process_changed_events(Repo("."), options) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.