From 8a652852a92ce0c481aa0128922efc9919bc853c Mon Sep 17 00:00:00 2001 From: Daniel Langbein Date: Thu, 3 Dec 2020 16:30:29 +0100 Subject: [PATCH] build using requirements.txt; improve README; fix: exclude pycache; --- .gitignore | 3 ++- .idea/other.xml | 6 ++++++ Dockerfile | 32 +++++++++++++++++--------------- README.md | 11 +++++++++-- src/langfingaz/plotMeetings.py | 7 ++++++- 5 files changed, 40 insertions(+), 19 deletions(-) create mode 100644 .idea/other.xml diff --git a/.gitignore b/.gitignore index 423987e..9ea0c82 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ /secret/*.txt /data/*.xml -/src/__pycache__/ /plot/*.png + +__pycache__/ diff --git a/.idea/other.xml b/.idea/other.xml new file mode 100644 index 0000000..a708ec7 --- /dev/null +++ b/.idea/other.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 39d04d1..43769ad 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,6 +2,10 @@ FROM python:3.8-alpine WORKDIR /usr/src/ +# setting the correct timezone requires "zdtata" +# numpy (dependency of matplotlib) requires "make automake gcc ..." +# source: https://stackoverflow.com/a/48349161/6334421 +# pillow (dependency of matplotlib) requires "zlib-dev jpeg-dev ..." RUN apk update && \ apk add \ tzdata \ @@ -14,13 +18,7 @@ RUN apk update && \ ENV TZ=Europe/Berlin RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone -# TODO -#COPY requirements.txt ./ -#RUN pip3 install --no-cache-dir -r requirements.txt - -# numpy (dependency of matplotlib) -# requires "make automake gcc ..." -# source: https://stackoverflow.com/a/48349161/6334421 +RUN python3 -m pip install --no-cache-dir --upgrade pip # LDFLAGS required for "pip install pillow" # otherwise this would be necessary: @@ -29,15 +27,19 @@ RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone # source: https://github.com/python-pillow/Pillow/issues/3103#issuecomment-382634946 ENV LDFLAGS=-L/usr/lib/x86_64-linux-gnu/ -RUN python3 -m pip install --no-cache-dir --upgrade pip -RUN python3 -m pip install --no-cache-dir --upgrade requests -RUN python3 -m pip install --no-cache-dir --upgrade setuptools -RUN python3 -m pip install --no-cache-dir --upgrade numpy -RUN python3 -m pip install --no-cache-dir --upgrade pillow -RUN python3 -m pip install --no-cache-dir --upgrade matplotlib +COPY requirements.txt ./ +RUN python3 -m pip install --no-cache-dir --upgrade -r requirements.txt +# +# if the above fails, try using the below instead +# +#RUN python3 -m pip install --no-cache-dir --upgrade requests +#RUN python3 -m pip install --no-cache-dir --upgrade setuptools +#RUN python3 -m pip install --no-cache-dir --upgrade numpy +#RUN python3 -m pip install --no-cache-dir --upgrade pillow +#RUN python3 -m pip install --no-cache-dir --upgrade matplotlib -COPY ./src/ ./ -RUN chmod +x ./langfingaz/main.py +COPY src/ ./ +RUN chmod +x langfingaz/main.py # unbuffered output option otherwise script sleeps before any output appears # python -u diff --git a/README.md b/README.md index e665a27..559fc0a 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,14 @@ Save these two values in the first line of the following files: ## run +Start logging in the background: + +```shell +docker-compose up -d ``` -docker-compose build -docker-compose up + +Generate a new plot with the saved data: + +```shell +sudo docker-compose run bbb-status plot ``` diff --git a/src/langfingaz/plotMeetings.py b/src/langfingaz/plotMeetings.py index 1799711..9e91219 100644 --- a/src/langfingaz/plotMeetings.py +++ b/src/langfingaz/plotMeetings.py @@ -40,7 +40,12 @@ def doPlotMeetings(bbbStati: List[BbbStatus]) -> Path: voices.append(bbbStatus.voiceParticipantCount) # Note that even in the OO-style, we use `.pyplot.figure` to create the figure. - fig, ax = plt.subplots() # Create a figure and an axes. + _a, _b = plt.subplots() # Create a figure and an axes. + fig: plt.Figure = _a + ax = _b # of type plt.axes.Axes ?? + if not (issubclass(type(fig), plt.Figure)): + raise ValueError("expected Figure") + ax.plot(time, participants, label='participants') # Plot some data on the axes. ax.plot(time, videos, label='video') # Plot more data on the axes... ax.plot(time, voices, label='voice') # ... and some more.