From 2bb845e17c932d2021fc81bead9c65a4413407de Mon Sep 17 00:00:00 2001 From: Reto Bollinger Date: Thu, 28 Nov 2024 09:02:55 +0100 Subject: [PATCH] Sligtly more elegant workaround for the synchronization/buffering issue. But still only a workaround I's say --- lektor/docker/entrypoint.sh | 7 ++++--- lektor/lektordata/scripts/calendar-fetcher-main.py | 5 ++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lektor/docker/entrypoint.sh b/lektor/docker/entrypoint.sh index d011900..f7e94d2 100644 --- a/lektor/docker/entrypoint.sh +++ b/lektor/docker/entrypoint.sh @@ -1,7 +1,8 @@ #!/bin/bash sh -c ". /opt/venv/bin/activate && exec python /opt/lektor/scripts/calendar-fetcher.py ${CALENDAR_URL} > /opt/lektor/project/content/termine/contents.lr" -# TODO Something with python and reading from docker mounts is broken but only when piping -cp /opt/lektor/project/content/contents.lr /tmp/myshadowcopyformisbehavingpython.txt -sh -c ". /opt/venv/bin/activate && exec python /opt/lektor/scripts/calendar-fetcher-main.py ${CALENDAR_URL} > /opt/lektor/project/content/contents.lr" +# TODO As the file reads from the same file as it's output is afterwards piped into this leads to synchronization/buffering issues, we therefore write to a temporaray file and move it to the right place in a subsequent step +tempfile="/tmp/contents.lr" +sh -c ". /opt/venv/bin/activate && exec python /opt/lektor/scripts/calendar-fetcher-main.py ${CALENDAR_URL} > $tempfile" +mv $tempfile /opt/lektor/project/content/contents.lr /root/.local/bin/lektor --project /opt/lektor/project server --host 0.0.0.0 \ No newline at end of file diff --git a/lektor/lektordata/scripts/calendar-fetcher-main.py b/lektor/lektordata/scripts/calendar-fetcher-main.py index 276d341..a517bcf 100644 --- a/lektor/lektordata/scripts/calendar-fetcher-main.py +++ b/lektor/lektordata/scripts/calendar-fetcher-main.py @@ -10,9 +10,8 @@ import locale if len(sys.argv) != 2: print("Usage: python3 {} ".format(sys.argv[0])) -# this should actually be the following file. But since piping from a Python-script which reads from a Docker-volume is broken we use the entrypoint.sh script to copy the file into the dockercontainer before running and thus we have that od /tmp/ path -# sourcefile = "/opt/lektor/project/content/contents.lr" -sourcefile = "/tmp/myshadowcopyformisbehavingpython.txt" +# TODO Reading from the same file as the output of this script is piped into leads to synchronization/buffering issues, we therefore have to do some quirks in entrypoint.sh +sourcefile = "/opt/lektor/project/content/contents.lr" with open(sourcefile) as fp: soup = BeautifulSoup(fp, 'html.parser')