unverbraucht / hanazeder_server

MQTT server for reading from Hanazeder FP and SHC heating pumps
Apache License 2.0
3 stars 0 forks source link

Hanazeder_server v1.1.1 does not start with werkzeug>3.x #6

Open da-bernie opened 3 weeks ago

da-bernie commented 3 weeks ago

I updated my Docker images and came across the problem. The server no longer starts with version 3.x of the werkzeug library.

Traceback (most recent call last): File "/usr/local/lib/python3.10/runpy.py", line 196, in _run_module_as_main return _run_code(code, main_globals, None, File "/usr/local/lib/python3.10/runpy.py", line 86, in _run_code exec(code, run_globals) File "/usr/local/lib/python3.10/site-packages/hanazeder_server/mqtt.py", line 6, in <module> from quart import Quart File "/usr/local/lib/python3.10/site-packages/quart/__init__.py", line 5, in <module> from .app import Quart as Quart File "/usr/local/lib/python3.10/site-packages/quart/app.py", line 46, in <module> from werkzeug.urls import url_quote ImportError: cannot import name 'url_quote' from 'werkzeug.urls' (/usr/local/lib/python3.10/site-packages/werkzeug/urls.py)

If I go to version 2.2.2 of Werkzeug, I get the following error message. hanazeder | Traceback (most recent call last): hanazeder | File "/usr/local/lib/python3.10/runpy.py", line 196, in _run_module_as_main hanazeder | return _run_code(code, main_globals, None, hanazeder | File "/usr/local/lib/python3.10/runpy.py", line 86, in _run_code hanazeder | exec(code, run_globals) hanazeder | File "/usr/local/lib/python3.10/site-packages/hanazeder_server/mqtt.py", line 9, in <module> hanazeder | from hanazeder_server.MqttClient import MqttClient hanazeder | File "/usr/local/lib/python3.10/site-packages/hanazeder_server/MqttClient.py", line 1, in <module> hanazeder | from asyncio_mqtt import Client, ProtocolVersion, Will hanazeder | File "/usr/local/lib/python3.10/site-packages/asyncio_mqtt/__init__.py", line 3, in <module> hanazeder | from .client import Client, Will, ProtocolVersion hanazeder | File "/usr/local/lib/python3.10/site-packages/asyncio_mqtt/client.py", line 591, in <module> hanazeder | _PahoSocket = Union[socket.socket, mqtt.WebsocketWrapper] hanazeder | AttributeError: module 'paho.mqtt.client' has no attribute 'WebsocketWrapper'. Did you mean: '_WebsocketWrapper'?

Dockerfile `FROM python:3.10-alpine3.16

RUN apk update && \ apk add usbutils bash wget

RUN pip3 install --no-cache-dir --upgrade pip && \ pip3 install --no-cache-dir hanazeder_server

COPY entrypoint.sh /entrypoint.sh

ENTRYPOINT ["/entrypoint.sh"]`

entrypoint.sh `#!/bin/sh

python -m hanazeder_server.mqtt --serial-port /dev/..... --mqtt-server 192.168.x.x`

unverbraucht commented 2 weeks ago

Hi,

I assume that's due to loose version specification in pyproject.toml. If you remove all the carets (the "^") in the section [tool.poetry.dependencies] it should always stick to the old versions. It should look something like this:

[tool.poetry.dependencies]
python = "3.7"
asyncio-mqtt = "0.12.1"
hanazeder = "1.3.0"
quart = "0.18.0"

I don't have access to a Hanazeder unit anymore, do you think you could test that? You'd have to create the docker image from the local python sources instead of downloading a fixed version of hanazeder_server via pip install.

da-bernie commented 2 weeks ago

Hi, I found a solution at the weekend. I can control the dependencies separately when building the Docker container. With this pip call I was able to create a working version again. pip3 install --no-cache-dir hanazeder_server paho-mqtt==1.6.1 werkzeug==2.2.2

I'm happy to test it with a Hanazeder control...