From ba8a714bc27f5ba834abee89bf07eedd9d933caa Mon Sep 17 00:00:00 2001 From: Matthias Bilger Date: Wed, 25 Sep 2019 06:24:34 +0200 Subject: [PATCH 1/5] improved dockerfile Install deps Use a user --- Dockerfile | 11 ++++++++++- requirements.txt | 1 - 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 7cc1534..ee7ddd7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,13 @@ FROM python:3.7 +RUN useradd --create-home appuser + +COPY requirements.txt /home/appuser +RUN pip install -r /home/appuser/requirements.txt + + +WORKDIR /home/appuser +USER appuser + COPY bibcheck.py / -CMD ["python", "bibcheck.py"] +CMD ["python", "./bibcheck.py"] diff --git a/requirements.txt b/requirements.txt index f05f949..b4b3331 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,4 @@ beautifulsoup4==4.8.0 -bs4==0.0.1 certifi==2019.9.11 chardet==3.0.4 html5lib==1.0.1 From defa866a56bd52dfc1701b4de08cebd1b6a3ef82 Mon Sep 17 00:00:00 2001 From: Matthias Bilger Date: Wed, 25 Sep 2019 06:30:25 +0200 Subject: [PATCH 2/5] log somethings --- bibcheck.py | 1 + 1 file changed, 1 insertion(+) diff --git a/bibcheck.py b/bibcheck.py index a9e969c..2152391 100644 --- a/bibcheck.py +++ b/bibcheck.py @@ -27,6 +27,7 @@ def main(): info = list(map(lambda x: str(x.text).strip(), entry.select('td'))) date = datetime.datetime.strptime(info[1], '%d.%m.%Y') delta = date - datetime.datetime.now() + print(delta, info) if delta.days <= 10 or delta.days == 20 or delta.days == 15: pushover.Client('u5w9h8gc7hpzvr5a2kh2xh4m9zpidq').send_message('Bitte an {} denken, Abgabe {}'.format(info[3], info[1]), title="Erinnerung") From 131a90a0e0bc4b844bb2cbf4f9087e109df3c38c Mon Sep 17 00:00:00 2001 From: matthias Date: Wed, 25 Sep 2019 04:42:57 +0000 Subject: [PATCH 3/5] =?UTF-8?q?=E2=80=9EDockerfile=E2=80=9C=20=C3=A4ndern?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index ee7ddd7..7e03a92 100644 --- a/Dockerfile +++ b/Dockerfile @@ -9,5 +9,5 @@ RUN pip install -r /home/appuser/requirements.txt WORKDIR /home/appuser USER appuser -COPY bibcheck.py / +COPY bibcheck.py ./ CMD ["python", "./bibcheck.py"] From bd671a449263c9f8969a48f658fb1c11227a0daa Mon Sep 17 00:00:00 2001 From: matthias Date: Wed, 25 Sep 2019 10:05:24 +0000 Subject: [PATCH 4/5] Added automatic renew of all lent books --- bibcheck.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/bibcheck.py b/bibcheck.py index 2152391..5ae74f3 100644 --- a/bibcheck.py +++ b/bibcheck.py @@ -19,6 +19,8 @@ def main(): response = br.submit() br.follow_link(text_regex=r"Konto") response = br.follow_link(text_regex=r"Ausleihe zeigen") + br.select_form('Form0') + response = self.br.submit(name='textButton$0', label='Alle verlängern') lentlist = bs4.BeautifulSoup(response.read(), 'html.parser') table = lentlist.select('table[class="rTable_table"]')[0] import urllib.request From 9a139de37ae4c851ed08b88c10b478f4a0972305 Mon Sep 17 00:00:00 2001 From: matthias Date: Thu, 26 Sep 2019 04:41:20 +0000 Subject: [PATCH 5/5] =?UTF-8?q?=E2=80=9Ebibcheck.py=E2=80=9C=20=C3=A4ndern?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bibcheck.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bibcheck.py b/bibcheck.py index 5ae74f3..a636a21 100644 --- a/bibcheck.py +++ b/bibcheck.py @@ -20,7 +20,7 @@ def main(): br.follow_link(text_regex=r"Konto") response = br.follow_link(text_regex=r"Ausleihe zeigen") br.select_form('Form0') - response = self.br.submit(name='textButton$0', label='Alle verlängern') + response = br.submit(name='textButton$0', label='Alle verlängern') lentlist = bs4.BeautifulSoup(response.read(), 'html.parser') table = lentlist.select('table[class="rTable_table"]')[0] import urllib.request