-
Notifications
You must be signed in to change notification settings - Fork 18
/
schedule_38C3.py
executable file
·222 lines (183 loc) · 5.9 KB
/
schedule_38C3.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
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()