workaround content-type issue
This commit is contained in:
parent
1b9c895f02
commit
1e0b8d3af9
12
Dockerfile
12
Dockerfile
|
@ -1,3 +1,4 @@
|
||||||
|
## ----------- Step 1
|
||||||
FROM docker.io/python:3.9 AS base
|
FROM docker.io/python:3.9 AS base
|
||||||
|
|
||||||
# Install pdftotext
|
# Install pdftotext
|
||||||
|
@ -10,6 +11,7 @@ ENV HOME=/app
|
||||||
|
|
||||||
WORKDIR ${HOME}
|
WORKDIR ${HOME}
|
||||||
|
|
||||||
|
## ----------- Step 2
|
||||||
FROM base AS builder
|
FROM base AS builder
|
||||||
|
|
||||||
ENV PATH=${PATH}:${HOME}/.poetry/bin
|
ENV PATH=${PATH}:${HOME}/.poetry/bin
|
||||||
|
@ -30,12 +32,22 @@ COPY . ./
|
||||||
|
|
||||||
RUN poetry build --format wheel
|
RUN poetry build --format wheel
|
||||||
|
|
||||||
|
## ----------- Step 3
|
||||||
FROM builder AS installer
|
FROM builder AS installer
|
||||||
|
|
||||||
COPY --from=builder \
|
COPY --from=builder \
|
||||||
/app/dist /app/dist
|
/app/dist /app/dist
|
||||||
RUN pip install /app/dist/pylokid-*-py3-none-any.whl
|
RUN pip install /app/dist/pylokid-*-py3-none-any.whl
|
||||||
|
|
||||||
|
COPY hack/patches/*.patch /tmp
|
||||||
|
|
||||||
|
# The ugliest possible way to workaround https://github.com/MechanicalSoup/MechanicalSoup/issues/356
|
||||||
|
# For some unknown reasons Lodur now wants "Content-Type: application/pdf" set in the multipart
|
||||||
|
# data section. And as I couln't figure out yet how to do that in MechanicalSoup and I only upload PDFs
|
||||||
|
# I just patch it to hardcode it. YOLO
|
||||||
|
RUN patch -p0 /usr/local/lib/python3.9/site-packages/mechanicalsoup/browser.py < /tmp/mechsoup-browser-content-type.patch
|
||||||
|
|
||||||
|
## ----------- Step 4
|
||||||
FROM base AS runtime
|
FROM base AS runtime
|
||||||
|
|
||||||
COPY --from=installer \
|
COPY --from=installer \
|
||||||
|
|
11
hack/patches/mechsoup-browser-content-type.patch
Normal file
11
hack/patches/mechsoup-browser-content-type.patch
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
--- /usr/local/lib/python3.9/site-packages/mechanicalsoup/browser.py.orig 2021-02-13 20:16:45.799025505 +0100
|
||||||
|
+++ /usr/local/lib/python3.9/site-packages/mechanicalsoup/browser.py 2021-02-13 15:29:10.244575346 +0100
|
||||||
|
@@ -201,7 +201,7 @@
|
||||||
|
# If value is the empty string, we still pass it
|
||||||
|
# for consistency with browsers (see
|
||||||
|
# https://github.com/MechanicalSoup/MechanicalSoup/issues/250).
|
||||||
|
- files[name] = (filename, content)
|
||||||
|
+ files[name] = (filename, content, 'application/pdf')
|
||||||
|
else:
|
||||||
|
data.append((name, value))
|
||||||
|
|
|
@ -190,7 +190,7 @@ class Lodur:
|
||||||
def einsatzrapport_alarmdepesche(self, f_id, file_path, webdav_client):
|
def einsatzrapport_alarmdepesche(self, f_id, file_path, webdav_client):
|
||||||
""" Upload a file to Alarmdepesche """
|
""" Upload a file to Alarmdepesche """
|
||||||
|
|
||||||
self.logger.info('[%s] Submitting File to Lodur "Alarmdepesche"', f_id)
|
self.logger.info('[%s] Submitting file %s to Lodur "Alarmdepesche"', f_id, file_path)
|
||||||
|
|
||||||
# Login to lodur
|
# Login to lodur
|
||||||
self.login()
|
self.login()
|
||||||
|
@ -199,7 +199,7 @@ class Lodur:
|
||||||
lodur_id = webdav_client.get_lodur_data(f_id)['event_id']
|
lodur_id = webdav_client.get_lodur_data(f_id)['event_id']
|
||||||
|
|
||||||
# Prepare the form
|
# Prepare the form
|
||||||
self.browser.open(self.url + '?modul=36&what=828&event=' + lodur_id)
|
self.browser.open('{}?modul=36&event={}&what=828'.format(self.url,lodur_id ))
|
||||||
frm_alarmdepesche = self.browser.select_form('#frm_alarmdepesche')
|
frm_alarmdepesche = self.browser.select_form('#frm_alarmdepesche')
|
||||||
|
|
||||||
# Fill in form data
|
# Fill in form data
|
||||||
|
|
|
@ -34,7 +34,7 @@ LODUR_BASE_URL = os.getenv("LODUR_BASE_URL")
|
||||||
HEARTBEAT_URL = os.getenv("HEARTBEAT_URL")
|
HEARTBEAT_URL = os.getenv("HEARTBEAT_URL")
|
||||||
PUSHOVER_API_TOKEN = os.getenv("PUSHOVER_API_TOKEN")
|
PUSHOVER_API_TOKEN = os.getenv("PUSHOVER_API_TOKEN")
|
||||||
PUSHOVER_USER_KEY = os.getenv("PUSHOVER_USER_KEY")
|
PUSHOVER_USER_KEY = os.getenv("PUSHOVER_USER_KEY")
|
||||||
PYLOKID_VERSION = "2.1.2"
|
PYLOKID_VERSION = "2.2.0"
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
""" main """
|
""" main """
|
||||||
|
|
Loading…
Reference in a new issue