From 60129403d091ccc56868b9b420c8be8efb284e85 Mon Sep 17 00:00:00 2001 From: Blaise Thompson Date: Sun, 8 Sep 2024 19:27:49 -0500 Subject: from remote --- build.py | 44 ++++++++++++++++++++++++-------------------- 1 file changed, 24 insertions(+), 20 deletions(-) (limited to 'build.py') diff --git a/build.py b/build.py index 91906a2..5a31700 100644 --- a/build.py +++ b/build.py @@ -56,22 +56,25 @@ with open(org_fp, "r") as org: events.append(Event(line)) -url = "https://outlook.office365.com/owa/calendar/db2d3e0f0490459a80c4b837118e4bf1@wisc.edu/f6a2b5209cd6432c96f52939cacdbedd2266851683387467601/calendar.ics" -subprocess.run(["curl", url, "-o", "/home/nginx/pycal2org/uw-madison.ics"]) -proc = subprocess.Popen(["python3", "/home/nginx/pycal2org/pycal2org.py", "/home/nginx/pycal2org/uw-madison.ics", ">", "/home/nginx/pycal2org/uw-madison.org"]) -org = proc.stdout.read() -for line in org: - line = line.strip() - if not line: - continue - if not line[0] == "*": - continue - if ":private:" in line: - continue - if ":info:" in line: - continue - events.append(Event(line)) +subprocess.run(["python3", "/home/nginx/agenda/uw_madison_ics.py"]) + +org_fp = "/home/nginx/org/uw-madison.org" + +events = [] + +with open(org_fp, "r") as org: + for line in org: + line = line.strip() + if not line: + continue + if not line[0] == "*": + continue + if ":private:" in line: + continue + if ":info:" in line: + continue + events.append(Event(line)) # create html ------------------------------------------------------------------------------------- @@ -117,14 +120,15 @@ with open(__here__ / "public" / "index.html", "w") as html: f"

{day.isoformat()} {day.strftime('%A')}

" ) for event in events: - if event.end: + try: + total = event.end - event.timestamp + assert total.days > 0 + elapsed = total - (event.end - day) if event.timestamp <= day and event.end >= day: - total = event.end - event.timestamp - elapsed = total - (event.end - day) - html.write( + html.write( f"(day {elapsed.days+1}/{total.days+1}) {event.description}
" ) - else: + except: if event.timestamp == day: html.write(f"{event.description}
") # increment -- cgit v1.2.3